Skip to content

Commit

Permalink
Fixing #1
Browse files Browse the repository at this point in the history
  • Loading branch information
olvlvl committed Jan 19, 2015
1 parent 70c0b9b commit 343be11
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ class Locale implements \ArrayAccess
*/
public function __construct(Repository $repository, $code)
{
if (!$code)
{
throw new \InvalidArgumentException("Locale identifier cannot be empty.");
}

$this->repository = $repository;
$this->code = $code;
}
Expand Down
8 changes: 8 additions & 0 deletions tests/LocaleCollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@ public function test_existing_locale()
$this->assertInstanceOf('ICanBoogie\CLDR\Locale', self::$collection['fr']);
$this->assertInstanceOf('ICanBoogie\CLDR\Locale', self::$collection['en']);
}

/**
* @expectedException \InvalidArgumentException
*/
public function test_empty_identifier()
{
self::$collection[''];
}
}
8 changes: 8 additions & 0 deletions tests/LocaleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ public function provide_test_localize()

];
}

/**
* @expectedException \InvalidArgumentException
*/
public function test_empty_identifier()
{
new Locale(get_repository(), '');
}
}

namespace ICanBoogie\CLDR\LocaleTest;
Expand Down

0 comments on commit 343be11

Please sign in to comment.