| @@ 40-61 (lines=22) @@ | ||
| 37 | /** |
|
| 38 | * @test |
|
| 39 | */ |
|
| 40 | public function getCategories() |
|
| 41 | { |
|
| 42 | $organizationUuid = Uuid::uuid1(); |
|
| 43 | $url = sprintf(ProductClient::GET_CATEGORIES, (string) $organizationUuid); |
|
| 44 | $data = ['getCategoriesTest']; |
|
| 45 | ||
| 46 | $izettleClientMock = $this->getIzettleGetMock($url, $data); |
|
| 47 | ||
| 48 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 49 | ||
| 50 | $categoryBuilderMock->shouldReceive('buildFromJson')->with(json_encode($data))->once(); |
|
| 51 | ||
| 52 | $productClient = new ProductClient( |
|
| 53 | $izettleClientMock, |
|
| 54 | $organizationUuid, |
|
| 55 | $categoryBuilderMock, |
|
| 56 | $discountBuilderMock, |
|
| 57 | $libraryBuilderMock, |
|
| 58 | $productBuilderMock |
|
| 59 | ); |
|
| 60 | $productClient->getCategories(); |
|
| 61 | } |
|
| 62 | ||
| 63 | /** |
|
| 64 | * @test |
|
| @@ 90-110 (lines=21) @@ | ||
| 87 | /** |
|
| 88 | * @test |
|
| 89 | */ |
|
| 90 | public function getDiscounts() |
|
| 91 | { |
|
| 92 | $organizationUuid = Uuid::uuid1(); |
|
| 93 | $data = ['getDiscountsTest']; |
|
| 94 | $url = sprintf(ProductClient::GET_DISCOUNTS, $organizationUuid); |
|
| 95 | ||
| 96 | $izettleClientMock = $this->getIzettleGetMock($url, $data); |
|
| 97 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 98 | $discountBuilderMock->shouldReceive('buildFromJson')->with(json_encode($data))->once(); |
|
| 99 | ||
| 100 | $productClient = new ProductClient( |
|
| 101 | $izettleClientMock, |
|
| 102 | $organizationUuid, |
|
| 103 | $categoryBuilderMock, |
|
| 104 | $discountBuilderMock, |
|
| 105 | $libraryBuilderMock, |
|
| 106 | $productBuilderMock |
|
| 107 | ); |
|
| 108 | ||
| 109 | $productClient->getDiscounts(); |
|
| 110 | } |
|
| 111 | ||
| 112 | /** |
|
| 113 | * @test |
|
| @@ 195-215 (lines=21) @@ | ||
| 192 | /** |
|
| 193 | * @test |
|
| 194 | */ |
|
| 195 | public function getProducts() |
|
| 196 | { |
|
| 197 | $organizationUuid = Uuid::uuid1(); |
|
| 198 | $data = ['getProductsTest']; |
|
| 199 | $url = sprintf(ProductClient::GET_PRODUCTS, $organizationUuid); |
|
| 200 | ||
| 201 | $izettleClientMock = $this->getIzettleGetMock($url, $data); |
|
| 202 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 203 | $productBuilderMock->shouldReceive('buildFromJson')->with(json_encode($data))->once(); |
|
| 204 | ||
| 205 | $productClient = new ProductClient( |
|
| 206 | $izettleClientMock, |
|
| 207 | $organizationUuid, |
|
| 208 | $categoryBuilderMock, |
|
| 209 | $discountBuilderMock, |
|
| 210 | $libraryBuilderMock, |
|
| 211 | $productBuilderMock |
|
| 212 | ); |
|
| 213 | ||
| 214 | $productClient->getProducts(); |
|
| 215 | } |
|
| 216 | ||
| 217 | /** |
|
| 218 | * @test |
|