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\Model\Import\ImportCommand; |
||
6 | use Kunstmaan\TranslatorBundle\Tests\unit\WebTestCase; |
||
7 | |||
8 | class ImportCommandHandlerTest extends WebTestCase |
||
9 | { |
||
10 | private $importCommandHandler; |
||
11 | |||
12 | View Code Duplication | public function setUp() |
|
13 | { |
||
14 | static::bootKernel(['test_case' => 'TranslatorBundleTest', 'root_config' => 'config.yaml']); |
||
15 | $container = static::$kernel->getContainer(); |
||
16 | static::loadFixtures($container); |
||
0 ignored issues
–
show
|
|||
17 | |||
18 | $this->importCommandHandler = $container->get('kunstmaan_translator.service.importer.command_handler'); |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @group handler |
||
23 | */ |
||
24 | View Code Duplication | public function testExecuteImportCommand() |
|
25 | { |
||
26 | $importCommand = new ImportCommand(); |
||
27 | $importCommand |
||
28 | ->setForce(false) |
||
29 | ->setLocales(false) |
||
30 | ->setGlobals(true) |
||
31 | ->setDefaultBundle(false); |
||
32 | |||
33 | $this->importCommandHandler->executeImportCommand($importCommand); |
||
34 | } |
||
35 | |||
36 | public function testdetermineLocalesToImport() |
||
37 | { |
||
38 | $importCommand = new ImportCommand(); |
||
39 | $importCommand |
||
40 | ->setForce(false) |
||
41 | ->setLocales(false) |
||
42 | ->setGlobals(true) |
||
43 | ->setDefaultBundle(false); |
||
44 | |||
45 | $locales = $this->importCommandHandler->determineLocalesToImport($importCommand); |
||
46 | $this->assertEquals(array('nl', 'en', 'de'), $locales); |
||
47 | } |
||
48 | |||
49 | public function testParseRequestedLocalesMulti() |
||
50 | { |
||
51 | $locale = 'nl,De, FR'; |
||
52 | $expectedArray = array('nl', 'de', 'fr'); |
||
53 | $locales = $this->importCommandHandler->parseRequestedLocales($locale); |
||
54 | $this->assertEquals($expectedArray, $locales); |
||
55 | } |
||
56 | |||
57 | public function testParseRequestedLocalesSingle() |
||
58 | { |
||
59 | $locale = 'dE'; |
||
60 | $expectedArray = array('de'); |
||
61 | $locales = $this->importCommandHandler->parseRequestedLocales($locale); |
||
62 | $this->assertEquals($expectedArray, $locales); |
||
63 | } |
||
64 | |||
65 | public function testParseRequestedLocalesArray() |
||
66 | { |
||
67 | $locale = array('dE', 'NL', 'es'); |
||
68 | $expectedArray = array('de', 'nl', 'es'); |
||
69 | $locales = $this->importCommandHandler->parseRequestedLocales($locale); |
||
70 | $this->assertEquals($expectedArray, $locales); |
||
71 | } |
||
72 | |||
73 | public function testImportGlobalTranslationFiles() |
||
74 | { |
||
75 | } |
||
76 | |||
77 | View Code Duplication | public function testImportBundleTranslationFiles() |
|
78 | { |
||
79 | $importCommand = new ImportCommand(); |
||
80 | $importCommand |
||
81 | ->setForce(false) |
||
82 | ->setLocales(false) |
||
83 | ->setGlobals(true) |
||
84 | ->setDefaultBundle('own'); |
||
85 | |||
86 | $this->importCommandHandler->importBundleTranslationFiles($importCommand); |
||
87 | } |
||
88 | } |
||
89 |
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: