[Translation] changed the MetadataAwareInterface method signatures
This commit is contained in:
parent
11ff4330c5
commit
320fb6cedf
@ -177,7 +177,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
|
||||
$this->addResource($resource);
|
||||
}
|
||||
|
||||
$metadata = $catalogue->getMetadata();
|
||||
$metadata = $catalogue->getMetadata('', '');
|
||||
$this->addMetadata($metadata);
|
||||
}
|
||||
|
||||
@ -239,7 +239,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getMetadata($domain = '', $key = '')
|
||||
public function getMetadata($key = '', $domain = 'messages')
|
||||
{
|
||||
if (empty($domain)) {
|
||||
return $this->metadata;
|
||||
@ -267,7 +267,7 @@ class MessageCatalogue implements MessageCatalogueInterface, MetadataAwareInterf
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function deleteMetadata($domain = '', $key = '')
|
||||
public function deleteMetadata($key = '', $domain = 'messages')
|
||||
{
|
||||
if (empty($domain)) {
|
||||
$this->metadata = array();
|
||||
|
@ -23,16 +23,16 @@ interface MetadataAwareInterface
|
||||
/**
|
||||
* Gets meta data for given domain and key.
|
||||
*
|
||||
* @param string $key Key to set
|
||||
* @param string $domain The domain name
|
||||
* @param string $key Key
|
||||
*/
|
||||
public function getMetadata($domain = '', $key = '');
|
||||
public function getMetadata($key = '', $domain = 'messages');
|
||||
|
||||
/**
|
||||
* Adds meta data to a message domain.
|
||||
*
|
||||
* @param string $key Key to set
|
||||
* @param string|array $value Value to store
|
||||
* @param string $key Key
|
||||
* @param string|array $value Value
|
||||
* @param string $domain The domain name
|
||||
*/
|
||||
public function setMetadata($key, $value, $domain = 'messages');
|
||||
@ -40,8 +40,8 @@ interface MetadataAwareInterface
|
||||
/**
|
||||
* Deletes meta data for given key and domain.
|
||||
*
|
||||
* @param string $key Key to set
|
||||
* @param string $domain The domain name
|
||||
* @param string $key Key
|
||||
*/
|
||||
public function deleteMetadata($domain = '', $key = '');
|
||||
public function deleteMetadata($key = '', $domain = 'messages');
|
||||
}
|
||||
|
@ -174,9 +174,9 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
|
||||
public function testMetadataDelete()
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$this->assertEquals(array(), $catalogue->getMetadata(), 'Metadata is empty');
|
||||
$catalogue->deleteMetadata('messages', 'key');
|
||||
$catalogue->deleteMetadata('messages');
|
||||
$this->assertEquals(array(), $catalogue->getMetadata('', ''), 'Metadata is empty');
|
||||
$catalogue->deleteMetadata('key', 'messages');
|
||||
$catalogue->deleteMetadata('', 'messages');
|
||||
$catalogue->deleteMetadata();
|
||||
}
|
||||
|
||||
@ -184,29 +184,29 @@ class MessageCatalogueTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
$catalogue = new MessageCatalogue('en');
|
||||
$catalogue->setMetadata('key', 'value');
|
||||
$this->assertEquals('value', $catalogue->getMetadata('messages', 'key'), "Metadata 'key' = 'value'");
|
||||
$this->assertEquals('value', $catalogue->getMetadata('key', 'messages'), "Metadata 'key' = 'value'");
|
||||
|
||||
$catalogue->setMetadata('key2', array());
|
||||
$this->assertEquals(array(), $catalogue->getMetadata('messages', 'key2'), 'Metadata key2 is array');
|
||||
$this->assertEquals(array(), $catalogue->getMetadata('key2', 'messages'), 'Metadata key2 is array');
|
||||
|
||||
$catalogue->deleteMetadata('messages', 'key2');
|
||||
$this->assertEquals(null, $catalogue->getMetadata('messages', 'key2'), 'Metadata key2 should is deleted.');
|
||||
$catalogue->deleteMetadata('key2', 'messages');
|
||||
$this->assertEquals(null, $catalogue->getMetadata('key2', 'messages'), 'Metadata key2 should is deleted.');
|
||||
|
||||
$catalogue->deleteMetadata('domain', 'key2');
|
||||
$this->assertEquals(null, $catalogue->getMetadata('domain', 'key2'), 'Metadata key2 should is deleted.');
|
||||
$catalogue->deleteMetadata('key2', 'domain');
|
||||
$this->assertEquals(null, $catalogue->getMetadata('key2', 'domain'), 'Metadata key2 should is deleted.');
|
||||
}
|
||||
|
||||
public function testMetadataMerge()
|
||||
{
|
||||
$cat1 = new MessageCatalogue('en');
|
||||
$cat1->setMetadata('a', 'b');
|
||||
$this->assertEquals(array('messages' => array('a' => 'b')), $cat1->getMetadata(), 'Cat1 contains messages metadata.');
|
||||
$this->assertEquals(array('messages' => array('a' => 'b')), $cat1->getMetadata('', ''), 'Cat1 contains messages metadata.');
|
||||
|
||||
$cat2 = new MessageCatalogue('en');
|
||||
$cat2->setMetadata('b', 'c', 'domain');
|
||||
$this->assertEquals(array('domain' => array('b' => 'c')), $cat2->getMetadata(), 'Cat2 contains domain metadata.');
|
||||
$this->assertEquals(array('domain' => array('b' => 'c')), $cat2->getMetadata('', ''), 'Cat2 contains domain metadata.');
|
||||
|
||||
$cat1->addCatalogue($cat2);
|
||||
$this->assertEquals(array('messages' => array('a' => 'b'), 'domain' => array('b' => 'c')), $cat1->getMetadata(), 'Cat1 contains merged metadata.');
|
||||
$this->assertEquals(array('messages' => array('a' => 'b'), 'domain' => array('b' => 'c')), $cat1->getMetadata('', ''), 'Cat1 contains merged metadata.');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user