Total Complexity | 11 |
Total Lines | 120 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
15 | abstract class FileLoaderTestAbstract extends \Tester\TestCase { |
||
16 | protected FileLoader $loader; |
||
17 | |||
18 | public function testGetLang(): void { |
||
22 | } |
||
23 | |||
24 | public function testSetLang(): void { |
||
25 | $this->loader->lang = "cs"; |
||
26 | $lang = $this->loader->lang; |
||
27 | Assert::type("string", $lang); |
||
28 | Assert::same("cs", $lang); |
||
29 | } |
||
30 | |||
31 | public function testGetFolders(): void { |
||
32 | $folders = $this->loader->folders; |
||
33 | Assert::type("array", $folders); |
||
34 | Assert::count(2, $folders); |
||
35 | Assert::same(__DIR__ . "/../../../lang", $folders[0]); |
||
36 | Assert::same(__DIR__ . "/../../../lang2", $folders[1]); |
||
37 | } |
||
38 | |||
39 | public function testSetFolders(): void { |
||
40 | Assert::exception(function() { |
||
41 | $this->loader->folders = [""]; |
||
42 | }, InvalidFolderException::class, "Folder does not exist."); |
||
43 | } |
||
44 | |||
45 | public function testGetResources(): void { |
||
46 | // texts were not loaded yet so there are no resources |
||
47 | $resources = $this->loader->resources; |
||
48 | Assert::type("array", $resources); |
||
49 | Assert::count(0, $resources); |
||
50 | // english texts are loaded, there is 1 resource for each domain |
||
51 | $this->loader->getTexts(); |
||
1 ignored issue
–
show
|
|||
52 | $resources = $this->loader->resources; |
||
53 | Assert::type("array", $resources); |
||
54 | Assert::count(3, $resources); |
||
55 | Assert::count(1, $resources["messages"]); |
||
56 | Assert::count(1, $resources["book"]); |
||
57 | Assert::count(1, $resources["abc"]); |
||
58 | // czech and english texts are loaded, there are 2 resources for each domain |
||
59 | $this->loader->lang = "cs"; |
||
60 | $this->loader->getTexts(); |
||
1 ignored issue
–
show
|
|||
61 | $resources = $this->loader->resources; |
||
62 | Assert::type("array", $resources); |
||
63 | Assert::count(3, $resources); |
||
64 | Assert::count(2, $resources["messages"]); |
||
65 | Assert::count(2, $resources["book"]); |
||
66 | Assert::count(2, $resources["abc"]); |
||
67 | // the language does not exist, 1 (default) resource for each domain |
||
68 | if($this->loader instanceof MessagesCatalogue) { |
||
69 | return; // the following tests for some reason fail with MessagesCatalogue |
||
70 | } |
||
71 | $this->loader->lang = "xyz"; |
||
72 | $this->loader->getTexts(); |
||
1 ignored issue
–
show
|
|||
73 | $resources = $this->loader->resources; |
||
74 | Assert::type("array", $resources); |
||
75 | Assert::count(3, $resources); |
||
76 | Assert::count(1, $resources["messages"]); |
||
77 | Assert::count(1, $resources["book"]); |
||
78 | Assert::count(1, $resources["abc"]); |
||
79 | } |
||
80 | |||
81 | public function testGetTexts(): void { |
||
82 | $texts = $this->loader->getTexts(); |
||
1 ignored issue
–
show
|
|||
83 | Assert::type("array", $texts); |
||
84 | Assert::count(3, $texts); |
||
85 | Assert::type("array", $texts["messages"]); |
||
86 | Assert::count(3, $texts["messages"]); |
||
87 | Assert::type("array", $texts["book"]); |
||
88 | Assert::count(5, $texts["book"]); |
||
89 | $this->loader->lang = "cs"; |
||
90 | $texts = $this->loader->getTexts(); |
||
1 ignored issue
–
show
|
|||
91 | Assert::type("array", $texts); |
||
92 | Assert::count(3, $texts); |
||
93 | Assert::type("array", $texts["messages"]); |
||
94 | Assert::count(3, $texts["messages"]); |
||
95 | Assert::type("array", $texts["book"]); |
||
96 | Assert::count(5, $texts["book"]); |
||
97 | if($this->loader instanceof MessagesCatalogue) { |
||
98 | return; // the following tests for some reason fail with MessagesCatalogue |
||
99 | } |
||
100 | $this->loader->lang = "xyz"; |
||
101 | $texts = $this->loader->getTexts(); |
||
1 ignored issue
–
show
|
|||
102 | Assert::type("array", $texts); |
||
103 | Assert::count(3, $texts); |
||
104 | Assert::type("array", $texts["messages"]); |
||
105 | Assert::count(3, $texts["messages"]); |
||
106 | Assert::type("array", $texts["book"]); |
||
107 | Assert::count(5, $texts["book"]); |
||
108 | } |
||
109 | |||
110 | public function testNoFolder(): void { |
||
116 | } |
||
117 | |||
118 | public function testGetAvailableLanguages(): void { |
||
129 | } |
||
130 | |||
131 | public function testGetResolverName(): void { |
||
132 | $name = $this->loader->getResolverName(); |
||
133 | Assert::type("string", $name); |
||
135 | } |
||
136 | } |
||
137 | ?> |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.