aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue')
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php74
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php60
-rw-r--r--vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php60
3 files changed, 194 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php
new file mode 100644
index 00000000..78023e1b
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/AbstractOperationTest.php
@@ -0,0 +1,74 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\Test\Catalogue;
13
14use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
15use Symfony\Component\Translation\MessageCatalogue;
16use Symfony\Component\Translation\MessageCatalogueInterface;
17
18abstract class AbstractOperationTest extends TestCase
19{
20 public function testGetEmptyDomains()
21 {
22 $this->assertEquals(
23 array(),
24 $this->createOperation(
25 new MessageCatalogue('en'),
26 new MessageCatalogue('en')
27 )->getDomains()
28 );
29 }
30
31 public function testGetMergedDomains()
32 {
33 $this->assertEquals(
34 array('a', 'b', 'c'),
35 $this->createOperation(
36 new MessageCatalogue('en', array('a' => array(), 'b' => array())),
37 new MessageCatalogue('en', array('b' => array(), 'c' => array()))
38 )->getDomains()
39 );
40 }
41
42 public function testGetMessagesFromUnknownDomain()
43 {
44 $this->setExpectedException('InvalidArgumentException');
45 $this->createOperation(
46 new MessageCatalogue('en'),
47 new MessageCatalogue('en')
48 )->getMessages('domain');
49 }
50
51 public function testGetEmptyMessages()
52 {
53 $this->assertEquals(
54 array(),
55 $this->createOperation(
56 new MessageCatalogue('en', array('a' => array())),
57 new MessageCatalogue('en')
58 )->getMessages('a')
59 );
60 }
61
62 public function testGetEmptyResult()
63 {
64 $this->assertEquals(
65 new MessageCatalogue('en'),
66 $this->createOperation(
67 new MessageCatalogue('en'),
68 new MessageCatalogue('en')
69 )->getResult()
70 );
71 }
72
73 abstract protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target);
74}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php
new file mode 100644
index 00000000..b2e852d9
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/DiffOperationTest.php
@@ -0,0 +1,60 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\Test\Catalogue;
13
14use Symfony\Component\Translation\Catalogue\DiffOperation;
15use Symfony\Component\Translation\MessageCatalogue;
16use Symfony\Component\Translation\MessageCatalogueInterface;
17
18class DiffOperationTest extends AbstractOperationTest
19{
20 public function testGetMessagesFromSingleDomain()
21 {
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')))
25 );
26
27 $this->assertEquals(
28 array('a' => 'old_a', 'c' => 'new_c'),
29 $operation->getMessages('messages')
30 );
31
32 $this->assertEquals(
33 array('c' => 'new_c'),
34 $operation->getNewMessages('messages')
35 );
36
37 $this->assertEquals(
38 array('b' => 'old_b'),
39 $operation->getObsoleteMessages('messages')
40 );
41 }
42
43 public function testGetResultFromSingleDomain()
44 {
45 $this->assertEquals(
46 new MessageCatalogue('en', array(
47 'messages' => array('a' => 'old_a', 'c' => 'new_c')
48 )),
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')))
52 )->getResult()
53 );
54 }
55
56 protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
57 {
58 return new DiffOperation($source, $target);
59 }
60}
diff --git a/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php
new file mode 100644
index 00000000..fa5118a7
--- /dev/null
+++ b/vendor/symfony/translation/Symfony/Component/Translation/Tests/Catalogue/MergeOperationTest.php
@@ -0,0 +1,60 @@
1<?php
2
3/*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace Symfony\Component\Translation\Test\Catalogue;
13
14use Symfony\Component\Translation\Catalogue\MergeOperation;
15use Symfony\Component\Translation\MessageCatalogue;
16use Symfony\Component\Translation\MessageCatalogueInterface;
17
18class MergeOperationTest extends AbstractOperationTest
19{
20 public function testGetMessagesFromSingleDomain()
21 {
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')))
25 );
26
27 $this->assertEquals(
28 array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c'),
29 $operation->getMessages('messages')
30 );
31
32 $this->assertEquals(
33 array('c' => 'new_c'),
34 $operation->getNewMessages('messages')
35 );
36
37 $this->assertEquals(
38 array(),
39 $operation->getObsoleteMessages('messages')
40 );
41 }
42
43 public function testGetResultFromSingleDomain()
44 {
45 $this->assertEquals(
46 new MessageCatalogue('en', array(
47 'messages' => array('a' => 'old_a', 'b' => 'old_b', 'c' => 'new_c')
48 )),
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')))
52 )->getResult()
53 );
54 }
55
56 protected function createOperation(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
57 {
58 return new MergeOperation($source, $target);
59 }
60}