| @@ 66-85 (lines=20) @@ | ||
| 63 | /** |
|
| 64 | * @test |
|
| 65 | */ |
|
| 66 | public function createCategory() |
|
| 67 | { |
|
| 68 | $organizationUuid = Uuid::uuid1(); |
|
| 69 | $category = Category::new('name'); |
|
| 70 | $url = sprintf(ProductClient::POST_CATEGORY, (string) $organizationUuid); |
|
| 71 | ||
| 72 | $izettleClientMock = $this->getIzettlePostMock($url, $category->getCreateData()); |
|
| 73 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 74 | ||
| 75 | $productClient = new ProductClient( |
|
| 76 | $izettleClientMock, |
|
| 77 | $organizationUuid, |
|
| 78 | $categoryBuilderMock, |
|
| 79 | $discountBuilderMock, |
|
| 80 | $libraryBuilderMock, |
|
| 81 | $productBuilderMock |
|
| 82 | ); |
|
| 83 | ||
| 84 | $productClient->createCategory($category); |
|
| 85 | } |
|
| 86 | ||
| 87 | /** |
|
| 88 | * @test |
|
| @@ 115-134 (lines=20) @@ | ||
| 112 | /** |
|
| 113 | * @test |
|
| 114 | */ |
|
| 115 | public function createDiscount() |
|
| 116 | { |
|
| 117 | $discount = $this->getDiscount(); |
|
| 118 | $organizationUuid = Uuid::uuid1(); |
|
| 119 | $url = sprintf(ProductClient::POST_DISCOUNT, (string) $organizationUuid); |
|
| 120 | ||
| 121 | $izettleClientMock = $this->getIzettlePostMock($url, $discount->getCreateData()); |
|
| 122 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 123 | ||
| 124 | $productClient = new ProductClient( |
|
| 125 | $izettleClientMock, |
|
| 126 | $organizationUuid, |
|
| 127 | $categoryBuilderMock, |
|
| 128 | $discountBuilderMock, |
|
| 129 | $libraryBuilderMock, |
|
| 130 | $productBuilderMock |
|
| 131 | ); |
|
| 132 | ||
| 133 | $productClient->createDiscount($discount); |
|
| 134 | } |
|
| 135 | ||
| 136 | /** |
|
| 137 | * @test |
|
| @@ 139-158 (lines=20) @@ | ||
| 136 | /** |
|
| 137 | * @test |
|
| 138 | */ |
|
| 139 | public function deleteDiscount() |
|
| 140 | { |
|
| 141 | $discount = $this->getDiscount(); |
|
| 142 | $organizationUuid = Uuid::uuid1(); |
|
| 143 | $url = sprintf(ProductClient::DELETE_DISCOUNT, (string) $organizationUuid, (string) $discount->getUuid()); |
|
| 144 | ||
| 145 | $izettleClientMock = $this->getIzettleDeleteMock($url); |
|
| 146 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 147 | ||
| 148 | $productClient = new ProductClient( |
|
| 149 | $izettleClientMock, |
|
| 150 | $organizationUuid, |
|
| 151 | $categoryBuilderMock, |
|
| 152 | $discountBuilderMock, |
|
| 153 | $libraryBuilderMock, |
|
| 154 | $productBuilderMock |
|
| 155 | ); |
|
| 156 | ||
| 157 | $productClient->deleteDiscount($discount); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * @test |
|
| @@ 220-239 (lines=20) @@ | ||
| 217 | /** |
|
| 218 | * @test |
|
| 219 | */ |
|
| 220 | public function createProduct() |
|
| 221 | { |
|
| 222 | $product = $this->getProduct(); |
|
| 223 | $organizationUuid = Uuid::uuid1(); |
|
| 224 | $url = sprintf(ProductClient::POST_PRODUCT, (string) $organizationUuid); |
|
| 225 | ||
| 226 | $izettleClientMock = $this->getIzettlePostMock($url, $product->getCreateData()); |
|
| 227 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 228 | ||
| 229 | $productClient = new ProductClient( |
|
| 230 | $izettleClientMock, |
|
| 231 | $organizationUuid, |
|
| 232 | $categoryBuilderMock, |
|
| 233 | $discountBuilderMock, |
|
| 234 | $libraryBuilderMock, |
|
| 235 | $productBuilderMock |
|
| 236 | ); |
|
| 237 | ||
| 238 | $productClient->createProduct($product); |
|
| 239 | } |
|
| 240 | ||
| 241 | /** |
|
| 242 | * @test |
|
| @@ 244-263 (lines=20) @@ | ||
| 241 | /** |
|
| 242 | * @test |
|
| 243 | */ |
|
| 244 | public function deleteProduct() |
|
| 245 | { |
|
| 246 | $product = $this->getProduct(); |
|
| 247 | $organizationUuid = Uuid::uuid1(); |
|
| 248 | $url = sprintf(ProductClient::DELETE_PRODUCT, (string) $organizationUuid, (string) $product->getUuid()); |
|
| 249 | ||
| 250 | $izettleClientMock = $this->getIzettleDeleteMock($url); |
|
| 251 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 252 | ||
| 253 | $productClient = new ProductClient( |
|
| 254 | $izettleClientMock, |
|
| 255 | $organizationUuid, |
|
| 256 | $categoryBuilderMock, |
|
| 257 | $discountBuilderMock, |
|
| 258 | $libraryBuilderMock, |
|
| 259 | $productBuilderMock |
|
| 260 | ); |
|
| 261 | ||
| 262 | $productClient->deleteProduct($product); |
|
| 263 | } |
|
| 264 | ||
| 265 | private function getDiscount(): Discount |
|
| 266 | { |
|