|
@@ 135-156 (lines=22) @@
|
| 132 |
|
* @expectedException Wambo\Catalog\Error\CatalogException |
| 133 |
|
* @expectedExceptionMessageRegExp /Cannot add a second product with the SKU 'product'/ |
| 134 |
|
*/ |
| 135 |
|
public function getCatalog_ArrayWithSimilarSKUsGiven_CatalogExceptionIsThrown() |
| 136 |
|
{ |
| 137 |
|
// arrange |
| 138 |
|
$catalogData = [ |
| 139 |
|
["sku" => "0001"], |
| 140 |
|
["sku" => "0002"], |
| 141 |
|
["sku" => "0003"], |
| 142 |
|
]; |
| 143 |
|
|
| 144 |
|
$productMapperMock = $this->createMock(ProductMapper::class); |
| 145 |
|
$productMapperMock->method("getProduct")->will($this->onConsecutiveCalls( |
| 146 |
|
new Product(new SKU("product"), new Slug("product-a"), "Product 1", new Content("Summary")), |
| 147 |
|
new Product(new SKU("product"), new Slug("product-b"), "Product 2", new Content("Summary"))) |
| 148 |
|
); |
| 149 |
|
|
| 150 |
|
/** @var ProductMapper $productMapperMock A product mapper instance */ |
| 151 |
|
|
| 152 |
|
$productMapper = new CatalogMapper($productMapperMock); |
| 153 |
|
|
| 154 |
|
// act |
| 155 |
|
$productMapper->getCatalog($catalogData); |
| 156 |
|
} |
| 157 |
|
|
| 158 |
|
/** |
| 159 |
|
* If the the given product catalog data contains products with similar slugs a |
|
@@ 167-188 (lines=22) @@
|
| 164 |
|
* @expectedException Wambo\Catalog\Error\CatalogException |
| 165 |
|
* @expectedExceptionMessageRegExp /Cannot add a second product with the Slug 'a-product'/ |
| 166 |
|
*/ |
| 167 |
|
public function getCatalog_ArrayWithSimilarSlugsGiven_CatalogExceptionIsThrown() |
| 168 |
|
{ |
| 169 |
|
// arrange |
| 170 |
|
$catalogData = [ |
| 171 |
|
["sku" => "0001"], |
| 172 |
|
["sku" => "0002"], |
| 173 |
|
["sku" => "0003"], |
| 174 |
|
]; |
| 175 |
|
|
| 176 |
|
$productMapperMock = $this->getMockBuilder(ProductMapper::class)->disableOriginalConstructor()->getMock(); |
| 177 |
|
$productMapperMock->method("getProduct")->will($this->onConsecutiveCalls( |
| 178 |
|
new Product(new SKU("0001"), new Slug("a-product"), "Product 1", new Content("Summary")), |
| 179 |
|
new Product(new SKU("0002"), new Slug("A-Product"), "Product 2", new Content("Summary"))) |
| 180 |
|
); |
| 181 |
|
|
| 182 |
|
/** @var ProductMapper $productMapperMock A product mapper instance */ |
| 183 |
|
|
| 184 |
|
$productMapper = new CatalogMapper($productMapperMock); |
| 185 |
|
|
| 186 |
|
// act |
| 187 |
|
$productMapper->getCatalog($catalogData); |
| 188 |
|
} |
| 189 |
|
|
| 190 |
|
/** |
| 191 |
|
* @test |