Permalink
Browse files

[Translation] fixed name

  • Loading branch information...
1 parent 8220b17 commit 96105a56115a7f8f4e6bf35b9bcd6a7d1b86491a @fabpot fabpot committed Dec 14, 2012
Showing with 43 additions and 45 deletions.
  1. +19 −20 MessageCatalogue.php
  2. +24 −25 Tests/MessageCatalogueTest.php
View
@@ -23,7 +23,7 @@
class MessageCatalogue implements MessageCatalogueInterface
{
private $messages = array();
- private $metaData = array();
+ private $metadata = array();
private $locale;
private $resources;
private $fallbackCatalogue;
@@ -177,8 +177,8 @@ public function addCatalogue(MessageCatalogueInterface $catalogue)
$this->addResource($resource);
}
- $meta = $catalogue->getMetaData();
- $this->addMetaData($meta);
+ $metadata = $catalogue->getMetadata();
+ $this->addMetadata($metadata);
}
/**
@@ -241,10 +241,10 @@ public function addResource(ResourceInterface $resource)
*
* @api
*/
- public function getMetaData($domain = '', $key = '')
+ public function getMetadata($domain = '', $key = '')
{
if (empty($domain)) {
- return $this->metaData;
+ return $this->metadata;
}
if (!is_string($domain)) {
@@ -253,13 +253,13 @@ public function getMetaData($domain = '', $key = '')
if (!is_string($key)) {
throw new \InvalidArgumentException("Key should be an string.");
}
- if (isset($this->metaData[$domain])) {
+ if (isset($this->metadata[$domain])) {
if (!empty($key)) {
- if (isset($this->metaData[$domain][$key])) {
- return $this->metaData[$domain][$key];
+ if (isset($this->metadata[$domain][$key])) {
+ return $this->metadata[$domain][$key];
}
} else {
- return $this->metaData[$domain];
+ return $this->metadata[$domain];
}
}
}
@@ -269,37 +269,37 @@ public function getMetaData($domain = '', $key = '')
*
* @api
*/
- public function setMetaData($key, $value, $domain = 'messages')
+ public function setMetadata($key, $value, $domain = 'messages')
{
if (!is_string($key)) {
throw new \InvalidArgumentException("Key should be an string.");
}
- if (!isset($this->metaData[$domain])) {
- $this->metaData[$domain] = array();
+ if (!isset($this->metadata[$domain])) {
+ $this->metadata[$domain] = array();
}
- $this->metaData[$domain][$key] = $value;
+ $this->metadata[$domain][$key] = $value;
}
/**
* {@inheritdoc}
*
* @api
*/
- public function deleteMetaData($domain = '', $key = '')
+ public function deleteMetadata($domain = '', $key = '')
{
if (empty($domain)) {
- $this->metaData = array();
+ $this->metadata = array();
}
if (!is_string($domain)) {
throw new \InvalidArgumentException("Domain should be an string.");
}
if (empty($key)) {
- unset($this->metaData[$domain]);
+ unset($this->metadata[$domain]);
}
if (!is_string($key)) {
throw new \InvalidArgumentException("Key should be an string.");
}
- unset($this->metaData[$domain][$key]);
+ unset($this->metadata[$domain][$key]);
}
/**
@@ -309,13 +309,12 @@ public function deleteMetaData($domain = '', $key = '')
*
* @param array $values Values to add
*/
- private function addMetaData(array $values)
+ private function addMetadata(array $values)
{
foreach ($values as $domain => $keys) {
foreach ($keys as $key => $value) {
- $this->setMetaData($key, $value, $domain);
+ $this->setMetadata($key, $value, $domain);
}
}
}
-
}
@@ -171,78 +171,77 @@ public function testGetAddResource()
$this->assertEquals(array($r, $r1), $catalogue->getResources());
}
- public function testMetaDataDelete()
+ public function testMetadataDelete()
{
$catalogue = new MessageCatalogue('en');
$expected = array();
- $actual = $catalogue->getMetaData();
+ $actual = $catalogue->getMetadata();
$this->assertEquals($expected, $actual, 'Metadata is empty');
- $catalogue->deleteMetaData('messages', 'key');
- $catalogue->deleteMetaData('messages');
- $catalogue->deleteMetaData();
+ $catalogue->deleteMetadata('messages', 'key');
+ $catalogue->deleteMetadata('messages');
+ $catalogue->deleteMetadata();
}
- public function testMetaDataSetGetDelete()
+ public function testMetadataSetGetDelete()
{
$catalogue = new MessageCatalogue('en');
- $catalogue->setMetaData('key', 'value');
+ $catalogue->setMetadata('key', 'value');
$expected = 'value';
- $actual = $catalogue->getMetaData('messages', 'key');
+ $actual = $catalogue->getMetadata('messages', 'key');
$this->assertEquals($expected, $actual, "Metadata 'key' = 'value'");
- $catalogue->setMetaData('key2', array());
+ $catalogue->setMetadata('key2', array());
$expected = array();
- $actual = $catalogue->getMetaData('messages', 'key2');
+ $actual = $catalogue->getMetadata('messages', 'key2');
$this->assertEquals($expected, $actual, 'Metadata key2 is array');
- $catalogue->deleteMetaData('messages', 'key2');
+ $catalogue->deleteMetadata('messages', 'key2');
$expected = null;
- $actual = $catalogue->getMetaData('messages', 'key2');
+ $actual = $catalogue->getMetadata('messages', 'key2');
$this->assertEquals($expected, $actual, 'Metadata key2 should is deleted.');
- $catalogue->deleteMetaData('domain', 'key2');
+ $catalogue->deleteMetadata('domain', 'key2');
$expected = null;
- $actual = $catalogue->getMetaData('domain', 'key2');
+ $actual = $catalogue->getMetadata('domain', 'key2');
$this->assertEquals($expected, $actual, 'Metadata key2 should is deleted.');
}
/**
* @expectedException \InvalidArgumentException
*/
- public function testMetaDataExceptionsKey()
+ public function testMetadataExceptionsKey()
{
$catalogue = new MessageCatalogue('en');
- $catalogue->deleteMetaData('messages', array());
+ $catalogue->deleteMetadata('messages', array());
}
/**
* @expectedException \InvalidArgumentException
*/
- public function testMetaDataExceptionsDomain()
+ public function testMetadataExceptionsDomain()
{
$catalogue = new MessageCatalogue('en');
- $catalogue->deleteMetaData(array());
+ $catalogue->deleteMetadata(array());
}
- public function testMetaDataMerge()
+ public function testMetadataMerge()
{
$cat1 = new MessageCatalogue('en');
- $cat1->setMetaData('a','b');
+ $cat1->setMetadata('a','b');
$expected = array('messages'=>array('a'=>'b'));
- $actual = $cat1->getMetaData();
+ $actual = $cat1->getMetadata();
$this->assertEquals($expected, $actual, 'Cat1 contains messages metadata.');
$cat2 = new MessageCatalogue('en');
- $cat2->setMetaData('b', 'c', 'domain');
+ $cat2->setMetadata('b', 'c', 'domain');
$expected = array('domain'=>array('b'=>'c'));
- $actual = $cat2->getMetaData();
+ $actual = $cat2->getMetadata();
$this->assertEquals($expected, $actual, 'Cat2 contains domain metadata.');
$cat1->addCatalogue($cat2);
$expected = array('messages'=>array('a'=>'b'),'domain'=>array('b'=>'c'));
- $actual = $cat1->getMetaData();
+ $actual = $cat1->getMetadata();
$this->assertEquals($expected, $actual, 'Cat1 contains merged metadata.');
-
}
}

0 comments on commit 96105a5

Please sign in to comment.