[Translation] fixed name
This commit is contained in:
parent
5607732a66
commit
23e9e65c00
@ -23,7 +23,7 @@ use Symfony\Component\Config\Resource\ResourceInterface;
|
||||
class MessageCatalogue implements MessageCatalogueInterface
|
||||
{
|
||||
private $messages = array();
|
||||
private $metaData = array();
|
||||
private $metadata = array();
|
||||
private $locale;
|
||||
private $resources;
|
||||
private $fallbackCatalogue;
|
||||
@ -177,8 +177,8 @@ class MessageCatalogue implements MessageCatalogueInterface
|
||||
$this->addResource($resource);
|
||||
}
|
||||
|
||||
$meta = $catalogue->getMetaData();
|
||||
$this->addMetaData($meta);
|
||||
$metadata = $catalogue->getMetadata();
|
||||
$this->addMetadata($metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -241,10 +241,10 @@ class MessageCatalogue implements MessageCatalogueInterface
|
||||
*
|
||||
* @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 @@ class MessageCatalogue implements MessageCatalogueInterface
|
||||
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,15 +269,15 @@ class MessageCatalogue implements MessageCatalogueInterface
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -285,21 +285,21 @@ class MessageCatalogue implements MessageCatalogueInterface
|
||||
*
|
||||
* @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 @@ class MessageCatalogue implements MessageCatalogueInterface
|
||||
*
|
||||
* @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,38 +171,38 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
|
||||
$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.');
|
||||
|
||||
}
|
||||
@ -210,39 +210,38 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
|
||||
/**
|
||||
* @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.');
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user