]>
Commit | Line | Data |
---|---|---|
4f5b44bd NL |
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 | ||
12 | namespace Symfony\Component\Translation\Test\Catalogue; | |
13 | ||
14 | use Symfony\Bundle\FrameworkBundle\Tests\TestCase; | |
15 | use Symfony\Component\Translation\MessageCatalogue; | |
16 | use Symfony\Component\Translation\MessageCatalogueInterface; | |
17 | ||
18 | abstract 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 | } |