1 | <?php |
||
51 | class ItemTest extends \PHPUnit_Framework_TestCase |
||
52 | { |
||
53 | /** |
||
54 | * Public function test the item creation |
||
55 | * |
||
56 | * @param string|\stdClass|\stdClass[] $type Item type(s) |
||
57 | * @param array $properties Item properties |
||
58 | * @param $itemId Item id |
||
59 | * @param $itemLanguage Item language |
||
60 | * @param array $expectedTypes Expected item types |
||
61 | * @param array $expectedProperties Expected item properties |
||
62 | * @param string $expectedId Expected item id |
||
63 | * @param string $expectedLanguage Expected language |
||
64 | * @dataProvider creationArgumentProvider |
||
65 | */ |
||
66 | public function testItemCreation( |
||
83 | |||
84 | /** |
||
85 | * Convert a property list to a plain array |
||
86 | * |
||
87 | * @param PropertyListInterface $propertyList Property list |
||
88 | * @return array Property list array |
||
89 | */ |
||
90 | protected function convertPropertyListToArray(PropertyListInterface $propertyList) |
||
98 | |||
99 | /** |
||
100 | * Data provider for item creation tests |
||
101 | * |
||
102 | * @return array Item creation arguments |
||
103 | */ |
||
104 | public function creationArgumentProvider() |
||
189 | |||
190 | /** |
||
191 | * Create a type object |
||
192 | * |
||
193 | * @param string $n Type name |
||
194 | * @param string $p Type profile |
||
195 | * @return object Type object |
||
196 | */ |
||
197 | protected function t($n, $p = '') |
||
201 | |||
202 | /** |
||
203 | * Create a property object |
||
204 | * |
||
205 | * @param string $n Property name |
||
206 | * @param mixed $s Property value(s) |
||
207 | * @param string $p Property profile |
||
208 | * @return \stdClass Property object |
||
209 | */ |
||
210 | protected function p($n, $s, $p = '') |
||
215 | |||
216 | /** |
||
217 | * Create a string value |
||
218 | * |
||
219 | * @param string $s Value |
||
220 | * @return ValueInterface String value |
||
221 | */ |
||
222 | protected function s($s) |
||
226 | |||
227 | /** |
||
228 | * Test the item creation with an empty types list |
||
229 | * |
||
230 | * @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException |
||
231 | * @expectedExceptionCode 1490814631 |
||
232 | */ |
||
233 | public function testEmptyTypesList() |
||
237 | |||
238 | /** |
||
239 | * Test the item creation with an empty types list |
||
240 | * |
||
241 | * @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException |
||
242 | * @expectedExceptionCode 1488314667 |
||
243 | */ |
||
244 | public function testEmptyTypeName() |
||
248 | |||
249 | /** |
||
250 | * Test the item creation with an empty property name |
||
251 | * |
||
252 | * @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException |
||
253 | * @expectedExceptionCode 1488314921 |
||
254 | */ |
||
255 | public function testEmptyPropertyName() |
||
259 | |||
260 | /** |
||
261 | * Test empty property value list |
||
262 | * |
||
263 | * @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException |
||
264 | * @expectedExceptionCode 1490814554 |
||
265 | */ |
||
266 | public function testInvalidPropertyStructure() |
||
270 | |||
271 | /** |
||
272 | * Test the item creation with an invalid property value |
||
273 | * |
||
274 | * @expectedException \Jkphl\Micrometa\Domain\Exceptions\InvalidArgumentException |
||
275 | * @expectedExceptionCode 1488315339 |
||
276 | */ |
||
277 | public function testInvalidPropertyValue() |
||
281 | |||
282 | /** |
||
283 | * Test the item creation with an invalid property value |
||
284 | * |
||
285 | * @expectedException \Jkphl\Micrometa\Domain\Exceptions\OutOfBoundsException |
||
286 | * @expectedExceptionCode 1488315604 |
||
287 | */ |
||
288 | public function testUnknownPropertyName() |
||
293 | |||
294 | /** |
||
295 | * Test the item property getter with an unprofiled property |
||
296 | */ |
||
297 | public function testItemUnprofiledProperty() |
||
302 | |||
303 | /** |
||
304 | * Test the item property getter with a profiled property |
||
305 | */ |
||
306 | public function testItemProfiledProperty() |
||
315 | } |
||
316 |