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() |
|
14 | { |
||
15 | static::bootKernel(['test_case' => 'TranslatorBundleTest', 'root_config' => 'config.yaml']); |
||
16 | $container = static::$kernel->getContainer(); |
||
17 | static::loadFixtures($container); |
||
0 ignored issues
–
show
|
|||
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 |
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: