SymfonyComponentTranslationTestsCatalogueMergeOperationTest

The Simple Calendar Symfony Component Translation Tests Catalogue MergeOperationTest class.

Defined (1)

The class is defined in the following location(s).

/vendor/symfony/translation/Tests/Catalogue/MergeOperationTest.php  
  1. class MergeOperationTest extends AbstractOperationTest 
  2. public function testGetMessagesFromSingleDomain() 
  3. $operation = $this->createOperation( 
  4. new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))),  
  5. new MessageCatalogue('en', array('messages' => array('a' => 'new_a', 'c' => 'new_c'))) 
  6. ); 
  7.  
  8. $this->assertEquals( 
  9. array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c'),  
  10. $operation->getMessages('messages') 
  11. ); 
  12.  
  13. $this->assertEquals( 
  14. array('c' => 'new_c'),  
  15. $operation->getNewMessages('messages') 
  16. ); 
  17.  
  18. $this->assertEquals( 
  19. array(),  
  20. $operation->getObsoleteMessages('messages') 
  21. ); 
  22.  
  23. public function testGetResultFromSingleDomain() 
  24. $this->assertEquals( 
  25. new MessageCatalogue('en', array( 
  26. 'messages' => array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c'),  
  27. )),  
  28. $this->createOperation( 
  29. new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))),  
  30. new MessageCatalogue('en', array('messages' => array('a' => 'new_a', 'c' => 'new_c'))) 
  31. )->getResult() 
  32. ); 
  33.  
  34. public function testGetResultWithMetadata() 
  35. $leftCatalogue = new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b'))); 
  36. $leftCatalogue->setMetadata('a', 'foo', 'messages'); 
  37. $leftCatalogue->setMetadata('b', 'bar', 'messages'); 
  38. $rightCatalogue = new MessageCatalogue('en', array('messages' => array('b' => 'new_b', 'c' => 'new_c'))); 
  39. $rightCatalogue->setMetadata('b', 'baz', 'messages'); 
  40. $rightCatalogue->setMetadata('c', 'qux', 'messages'); 
  41.  
  42. $mergedCatalogue = new MessageCatalogue('en', array('messages' => array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c'))); 
  43. $mergedCatalogue->setMetadata('a', 'foo', 'messages'); 
  44. $mergedCatalogue->setMetadata('b', 'bar', 'messages'); 
  45. $mergedCatalogue->setMetadata('c', 'qux', 'messages'); 
  46.  
  47. $this->assertEquals( 
  48. $mergedCatalogue,  
  49. $this->createOperation( 
  50. $leftCatalogue,  
  51. $rightCatalogue 
  52. )->getResult() 
  53. ); 
  54.  
  55. protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target) 
  56. return new MergeOperation($source, $target);