public function testOnDuplicateAfterSourceProductWithoutPrices()
 {
     $this->productPriceRepository->expects($this->once())->method('getPricesByProduct')->with($this->sourceProduct)->will($this->returnValue([]));
     $this->objectManager->expects($this->never())->method('persist');
     $event = new ProductDuplicateAfterEvent($this->product, $this->sourceProduct);
     $this->listener->onDuplicateAfter($event);
 }
 public function testDeleteByPriceList()
 {
     /** @var PriceList $priceList */
     $priceList = $this->getReference('price_list_1');
     $this->repository->deleteByPriceList($priceList);
     $this->assertEmpty($this->repository->findBy(['priceList' => $priceList->getId()]));
     /** @var PriceList $priceList2 */
     $priceList2 = $this->getReference('price_list_2');
     $this->assertNotEmpty($this->repository->findBy(['priceList' => $priceList2->getId()]));
     $this->repository->deleteByPriceList($priceList2);
     $this->assertEmpty($this->repository->findBy(['priceList' => $priceList2->getId()]));
 }
 public function testOnPostSubmitExistingProduct()
 {
     $product = $this->createProduct(1);
     $event = $this->createEvent($product);
     $priceOne = $this->createProductPrice(1);
     $priceTwo = $this->createProductPrice(2);
     $removedPrice = $this->createProductPrice(3);
     $this->assertPriceAdd($event, [$priceOne, $priceTwo]);
     $this->priceRepository->expects($this->once())->method('getPricesByProduct')->will($this->returnValue([$removedPrice]));
     $this->priceManager->expects($this->once())->method('remove')->with($removedPrice);
     $this->extension->onPostSubmit($event);
     $this->assertEquals($product, $priceOne->getProduct());
     $this->assertEquals($product, $priceTwo->getProduct());
 }