|
@@ 25-37 (lines=13) @@
|
| 22 |
|
* @test |
| 23 |
|
* @dataProvider getProductResponseData |
| 24 |
|
*/ |
| 25 |
|
public function createFromResponse(ResponseInterface $response, $data): void |
| 26 |
|
{ |
| 27 |
|
$categories = CategoryParser::createFromResponse($response); |
| 28 |
|
foreach ($categories as $index => $category) { |
| 29 |
|
self::assertInstanceOf(Category::class, $category); |
| 30 |
|
self::assertSame($data[$index]['uuid'], (string) $category->getUuid()); |
| 31 |
|
self::assertSame($data[$index]['name'], $category->getName()); |
| 32 |
|
self::assertSame($data[$index]['etag'], $category->getEtag()); |
| 33 |
|
self::assertEquals(new DateTime($data[$index]['updated']), $category->getUpdatedAt()); |
| 34 |
|
self::assertSame($data[$index]['updatedBy'], (string) $category->getUpdatedBy()); |
| 35 |
|
self::assertEquals(new DateTime($data[$index]['created']), $category->getCreatedAt()); |
| 36 |
|
} |
| 37 |
|
} |
| 38 |
|
|
| 39 |
|
/** |
| 40 |
|
* @test |
|
@@ 43-60 (lines=18) @@
|
| 40 |
|
* @test |
| 41 |
|
* @dataProvider getVariantArrayData |
| 42 |
|
*/ |
| 43 |
|
public function createFromArray(array $data): void |
| 44 |
|
{ |
| 45 |
|
$categoryCollection = CategoryParser::parseArray($data); |
| 46 |
|
|
| 47 |
|
self::assertInstanceOf(CategoryCollection::class, $categoryCollection); |
| 48 |
|
|
| 49 |
|
$i = 0;// we cannot use the array key here |
| 50 |
|
foreach ($categoryCollection->getAll() as $category) { |
| 51 |
|
self::assertSame($data[$i]['uuid'], (string) $category->getUuid()); |
| 52 |
|
self::assertSame($data[$i]['name'], $category->getName()); |
| 53 |
|
self::assertSame($data[$i]['etag'], $category->getEtag()); |
| 54 |
|
self::assertEquals(new DateTime($data[$i]['updated']), $category->getUpdatedAt()); |
| 55 |
|
self::assertSame($data[$i]['updatedBy'], (string) $category->getUpdatedBy()); |
| 56 |
|
self::assertEquals(new DateTime($data[$i]['created']), $category->getCreatedAt()); |
| 57 |
|
|
| 58 |
|
$i++; |
| 59 |
|
} |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
public function getProductResponseData(): array |
| 63 |
|
{ |