1 | <?php |
||
18 | abstract class AbstractServiceTest extends TestCase |
||
19 | { |
||
20 | /** |
||
21 | * Purely to attempt to make tests easier to read. |
||
22 | * |
||
23 | * As language parameter is ignored from providers and replced with values in tests, this is used to mark value of |
||
24 | * language argument instead of either askingproviders to use 0, or a valid language array which would then not be |
||
25 | * used. |
||
26 | */ |
||
27 | const LANG_ARG = 0; |
||
28 | |||
29 | /** @var \object|\PHPUnit_Framework_MockObject_MockObject */ |
||
30 | protected $innerApiServiceMock; |
||
31 | |||
32 | /** @var object */ |
||
33 | protected $service; |
||
34 | |||
35 | /** @var \eZ\Publish\API\Repository\LanguageResolver|\PHPUnit_Framework_MockObject_MockObject */ |
||
36 | protected $languageResolverMock; |
||
37 | |||
38 | abstract public function getAPIServiceClassName(); |
||
39 | |||
40 | abstract public function getSiteAccessAwareServiceClassName(); |
||
41 | |||
42 | public function setUp() |
||
56 | |||
57 | protected function tearDown() |
||
64 | |||
65 | /** |
||
66 | * @return array See signature on {@link testForPassTrough} for arguments and their type. |
||
67 | */ |
||
68 | abstract public function providerForPassTroughMethods(); |
||
69 | |||
70 | /** |
||
71 | * Make sure these methods does nothing more then passing the arguments to inner service. |
||
72 | * |
||
73 | * Methods tested here are basically those without as languages argument. |
||
74 | * |
||
75 | * @dataProvider providerForPassTroughMethods |
||
76 | * |
||
77 | * @param string $method |
||
78 | * @param array $arguments |
||
79 | * @param bool $return |
||
80 | */ |
||
81 | final public function testForPassTrough($method, array $arguments, $return = true) |
||
93 | |||
94 | /** |
||
95 | * @return array See signature on {@link testForLanguagesLookup} for arguments and their type. |
||
96 | * NOTE: languages / prioritizedLanguage, can be set to 0, it will be replaced by tests methods. |
||
97 | */ |
||
98 | abstract public function providerForLanguagesLookupMethods(); |
||
99 | |||
100 | /** |
||
101 | * Method to be able to customize the logic for setting expected language argument during {@see testForLanguagesLookup()}. |
||
102 | * |
||
103 | * @param array $arguments |
||
104 | * @param int $languageArgumentIndex |
||
105 | * @param array $languages |
||
106 | * |
||
107 | * @return array |
||
108 | */ |
||
109 | protected function setLanguagesLookupExpectedArguments(array $arguments, $languageArgumentIndex, array $languages) |
||
115 | |||
116 | /** |
||
117 | * Method to be able to customize the logic for setting expected language argument during {@see testForLanguagesLookup()}. |
||
118 | * |
||
119 | * @param array $arguments |
||
120 | * @param int $languageArgumentIndex |
||
121 | * |
||
122 | * @return array |
||
123 | */ |
||
124 | protected function setLanguagesLookupArguments(array $arguments, $languageArgumentIndex) |
||
130 | |||
131 | /** |
||
132 | * Test that language aware methods does a language lookup when language is not set. |
||
133 | * |
||
134 | * @dataProvider providerForLanguagesLookupMethods |
||
135 | * |
||
136 | * @param string $method |
||
137 | * @param array $arguments |
||
138 | * @param mixed|null $return |
||
139 | * @param int $languageArgumentIndex From 0 and up, so the array index on $arguments. |
||
140 | */ |
||
141 | final public function testForLanguagesLookup($method, array $arguments, $return, $languageArgumentIndex, callable $callback = null, int $alwaysAvailableArgumentIndex = null) |
||
181 | |||
182 | /** |
||
183 | * Method to be able to customize the logic for setting expected language argument during {@see testForLanguagesPassTrough()}. |
||
184 | * |
||
185 | * @param array $arguments |
||
186 | * @param int $languageArgumentIndex |
||
187 | * @param array $languages |
||
188 | * |
||
189 | * @return array |
||
190 | */ |
||
191 | protected function setLanguagesPassTroughArguments(array $arguments, $languageArgumentIndex, array $languages) |
||
197 | |||
198 | /** |
||
199 | * Make sure these methods does nothing more then passing the arguments to inner service. |
||
200 | * |
||
201 | * @dataProvider providerForLanguagesLookupMethods |
||
202 | * |
||
203 | * @param string $method |
||
204 | * @param array $arguments |
||
205 | * @param mixed|null $return |
||
206 | * @param int $languageArgumentIndex From 0 and up, so the array index on $arguments. |
||
207 | */ |
||
208 | final public function testForLanguagesPassTrough($method, array $arguments, $return, $languageArgumentIndex, callable $callback = null, int $alwaysAvailableArgumentIndex = null) |
||
243 | |||
244 | /** |
||
245 | * @todo replace with coverage testing (see EZP-31035) |
||
246 | */ |
||
247 | final public function testIfThereIsMissingTest(): void |
||
267 | } |
||
268 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: