Skip to content

Commit

Permalink
Make getLocales() tests more clear
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanvermeyen committed Mar 31, 2018
1 parent c3e1365 commit f0cb914
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,19 @@ You can get a flattened array, containing only specific locale info. These array

``` php
$locales = $browser->getLocales('locale');
//=> Result: ['en-US', 'en', 'nl-BE', 'nl']
//=> 'en-US,en;q=0.8,nl-NL;q=0.6'
//=> Result: ['en-US', 'en', 'nl-BE']

$languages = $browser->getLocales('language');
//=> 'en-US,en;q=0.8,nl-NL;q=0.6'
//=> Result: ['en', 'nl']

$countries = $browser->getLocales('country');
//=> 'en-US,en;q=0.8,nl-NL;q=0.6,nl;q=0.4'
//=> Result: ['US', 'BE']

$weights = $browser->getLocales('weight');
//=> 'en-US,en;q=0.8,nl-NL;q=0.6,nl;q=0.4'
//=> Result: [1.0, 0.8, 0.6, 0.4]
```

Expand Down
6 changes: 3 additions & 3 deletions tests/BrowserLocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ public function it_returns_an_array_of_all_preferred_locales()
/** @test */
public function it_returns_a_simple_array_of_locale_locales()
{
$browser = new BrowserLocale('en-US,en;q=0.8,nl-NL;q=0.6,nl;q=0.4');
$browser = new BrowserLocale('en-US,en;q=0.8,nl-NL;q=0.6');

$locales = $browser->getLocales('locale');

$this->assertEquals(['en-US', 'en', 'nl-NL', 'nl'], $locales);
$this->assertEquals(['en-US', 'en', 'nl-NL'], $locales);
}

/** @test */
public function it_returns_a_simple_array_of_language_codes()
{
$browser = new BrowserLocale('en-US,en;q=0.8,nl-NL;q=0.6,nl;q=0.4');
$browser = new BrowserLocale('en-US,en;q=0.8,nl-NL;q=0.6');

$locales = $browser->getLocales('language');

Expand Down

0 comments on commit f0cb914

Please sign in to comment.