These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\TranslatorBundle\Tests\Service\Importer; |
||
4 | |||
5 | use Kunstmaan\TranslatorBundle\Repository\TranslationRepository; |
||
6 | use Kunstmaan\TranslatorBundle\Tests\unit\WebTestCase; |
||
7 | |||
8 | class TranslationRepositoryTest extends WebTestCase |
||
9 | { |
||
10 | /** @var TranslationRepository */ |
||
11 | private $translationRepository; |
||
12 | |||
13 | View Code Duplication | public function setUp() |
|
0 ignored issues
–
show
|
|||
14 | { |
||
15 | static::bootKernel(['test_case' => 'TranslatorBundleTest', 'root_config' => 'config.yaml']); |
||
16 | $container = static::$kernel->getContainer(); |
||
17 | static::loadFixtures($container); |
||
18 | |||
19 | $this->translationRepository = $container->get('kunstmaan_translator.repository.translation'); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @group translation-repository |
||
24 | */ |
||
25 | public function testGetAllDomainsByLocale() |
||
26 | { |
||
27 | $result = $this->translationRepository->getAllDomainsByLocale(); |
||
28 | $firstItem = reset($result); |
||
29 | $this->assertArrayHasKey('locale', $firstItem); |
||
30 | $this->assertArrayHasKey('name', $firstItem); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * @group translation-repository |
||
35 | */ |
||
36 | public function testGetLastChangedTranslationDate() |
||
37 | { |
||
38 | $date = $this->translationRepository->getLastChangedTranslationDate(); |
||
39 | $this->assertInstanceOf('\DateTime', $date); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @group translation-repository |
||
44 | */ |
||
45 | public function testGetTranslationsByLocalesAndDomains() |
||
46 | { |
||
47 | $result = $this->translationRepository->getTranslationsByLocalesAndDomains(array('nl'), array('messages')); |
||
48 | $this->assertInstanceOf('Kunstmaan\TranslatorBundle\Entity\Translation', $result[0]); |
||
49 | $this->assertGreaterThan(0, count($result)); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @group translation-repository |
||
54 | */ |
||
55 | public function testFindAllNotDisabled() |
||
56 | { |
||
57 | $result = $this->translationRepository->findAllNotDisabled('nl'); |
||
58 | $this->assertInstanceOf('Kunstmaan\TranslatorBundle\Entity\Translation', $result[0]); |
||
59 | $this->assertGreaterThan(0, count($result)); |
||
60 | } |
||
61 | |||
62 | /** |
||
63 | * @group translation-repository |
||
64 | */ |
||
65 | public function testFindAllDeprecated() |
||
66 | { |
||
67 | $result = $this->translationRepository->findDeprecatedTranslationsBeforeDate(new \DateTime('+5 minutes'), 'messages'); |
||
68 | $this->assertInstanceOf('Kunstmaan\TranslatorBundle\Entity\Translation', $result[0]); |
||
69 | $this->assertGreaterThan(0, count($result)); |
||
70 | } |
||
71 | } |
||
72 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.