4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Tests\Catalogue;
14 use Symfony\Component\Translation\Catalogue\TargetOperation;
15 use Symfony\Component\Translation\MessageCatalogue;
16 use Symfony\Component\Translation\MessageCatalogueInterface;
18 class TargetOperationTest extends AbstractOperationTest
20 public function testGetMessagesFromSingleDomain()
22 $operation = $this->createOperation(
23 new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))),
24 new MessageCatalogue('en', array('messages' => array('a' => 'new_a', 'c' => 'new_c')))
28 array('a' => 'old_a', 'c' => 'new_c'),
29 $operation->getMessages('messages')
33 array('c' => 'new_c'),
34 $operation->getNewMessages('messages')
38 array('b' => 'old_b'),
39 $operation->getObsoleteMessages('messages')
43 public function testGetResultFromSingleDomain()
46 new MessageCatalogue('en', array(
47 'messages' => array('a' => 'old_a', 'c' => 'new_c'),
49 $this->createOperation(
50 new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))),
51 new MessageCatalogue('en', array('messages' => array('a' => 'new_a', 'c' => 'new_c')))
56 public function testGetResultWithMetadata()
58 $leftCatalogue = new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b')));
59 $leftCatalogue->setMetadata('a', 'foo', 'messages');
60 $leftCatalogue->setMetadata('b', 'bar', 'messages');
61 $rightCatalogue = new MessageCatalogue('en', array('messages' => array('b' => 'new_b', 'c' => 'new_c')));
62 $rightCatalogue->setMetadata('b', 'baz', 'messages');
63 $rightCatalogue->setMetadata('c', 'qux', 'messages');
65 $diffCatalogue = new MessageCatalogue('en', array('messages' => array('b' => 'old_b', 'c' => 'new_c')));
66 $diffCatalogue->setMetadata('b', 'bar', 'messages');
67 $diffCatalogue->setMetadata('c', 'qux', 'messages');
71 $this->createOperation(
78 protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
80 return new TargetOperation($source, $target);