| @@ 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 |
|
| @@ 221-240 (lines=20) @@ | ||
| 218 | /** |
|
| 219 | * @test |
|
| 220 | */ |
|
| 221 | public function createProduct() |
|
| 222 | { |
|
| 223 | $product = $this->getProduct(); |
|
| 224 | $organizationUuid = Uuid::uuid1(); |
|
| 225 | $url = sprintf(ProductClient::POST_PRODUCT, (string) $organizationUuid); |
|
| 226 | ||
| 227 | $izettleClientMock = $this->getIzettlePostMock($url, $product->getCreateData()); |
|
| 228 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 229 | ||
| 230 | $productClient = new ProductClient( |
|
| 231 | $izettleClientMock, |
|
| 232 | $organizationUuid, |
|
| 233 | $categoryBuilderMock, |
|
| 234 | $discountBuilderMock, |
|
| 235 | $libraryBuilderMock, |
|
| 236 | $productBuilderMock |
|
| 237 | ); |
|
| 238 | ||
| 239 | $productClient->createProduct($product); |
|
| 240 | } |
|
| 241 | ||
| 242 | /** |
|
| 243 | * @test |
|
| @@ 245-264 (lines=20) @@ | ||
| 242 | /** |
|
| 243 | * @test |
|
| 244 | */ |
|
| 245 | public function deleteProduct() |
|
| 246 | { |
|
| 247 | $product = $this->getProduct(); |
|
| 248 | $organizationUuid = Uuid::uuid1(); |
|
| 249 | $url = sprintf(ProductClient::DELETE_PRODUCT, (string) $organizationUuid, (string) $product->getUuid()); |
|
| 250 | ||
| 251 | $izettleClientMock = $this->getIzettleDeleteMock($url); |
|
| 252 | list($categoryBuilderMock, $discountBuilderMock, $libraryBuilderMock, $productBuilderMock) = $this->getMocks(); |
|
| 253 | ||
| 254 | $productClient = new ProductClient( |
|
| 255 | $izettleClientMock, |
|
| 256 | $organizationUuid, |
|
| 257 | $categoryBuilderMock, |
|
| 258 | $discountBuilderMock, |
|
| 259 | $libraryBuilderMock, |
|
| 260 | $productBuilderMock |
|
| 261 | ); |
|
| 262 | ||
| 263 | $productClient->deleteProduct($product); |
|
| 264 | } |
|
| 265 | ||
| 266 | private function getDiscount(): Discount |
|
| 267 | { |
|