1 | <?php |
||
18 | */ |
||
19 | final class LibraryBuilderTest extends TestCase |
||
20 | { |
||
21 | /** |
||
22 | * @test |
||
23 | */ |
||
24 | public function createFromResponse() |
||
25 | { |
||
26 | $json = file_get_contents(dirname(__FILE__) . '/json-files/library.json'); |
||
27 | $data = json_decode($json, true); |
||
28 | |||
29 | $productBuilderMock = Mockery::mock(ProductBuilderInterface::class); |
||
30 | $productBuilderMock->shouldReceive('buildFromArray')->with($data['products']) |
||
31 | ->once()->andReturn(new ProductCollection()); |
||
32 | $productBuilderMock->shouldReceive('buildFromArray')->with($data['deletedProducts']) |
||
33 | ->once()->andReturn(new ProductCollection()); |
||
34 | |||
35 | $discountBuilderMock = Mockery::mock(DiscountBuilderInterface::class); |
||
36 | $discountBuilderMock->shouldReceive('buildFromArray')->with($data['discounts']) |
||
37 | ->once()->andReturn(new DiscountCollection()); |
||
38 | $discountBuilderMock->shouldReceive('buildFromArray')->with($data['deletedDiscounts']) |
||
39 | ->once()->andReturn(new DiscountCollection()); |
||
40 | |||
41 | $builder = new LibraryBuilder($productBuilderMock, $discountBuilderMock); |
||
42 | |||
43 | $library = $builder->buildFromJson($json); |
||
44 | |||
45 | self::assertInstanceOf(Uuid::class, $library->getFromEventLogUuid()); |
||
46 | self::assertInstanceOf(Uuid::class, $library->getUntilEventLogUuid()); |
||
47 | |||
48 | self::assertInstanceOf(ProductCollection::class, $library->getProducts()); |
||
49 | self::assertInstanceOf(DiscountCollection::class, $library->getDiscounts()); |
||
50 | self::assertInstanceOf(ProductCollection::class, $library->getDeletedProducts()); |
||
51 | self::assertInstanceOf(DiscountCollection::class, $library->getDeletedDiscounts()); |
||
52 | } |
||
53 | } |
||
54 |