Exemplo n.º 1
0
 /**
  * @return void
  */
 public function testSaveDiscountMustNotSaveSalesDiscountCodesIfUsedCodeCanNotBeFound()
 {
     $discountSaver = $this->getDiscountOrderSaverMock(['persistSalesDiscount', 'persistSalesDiscountCode', 'getDiscountVoucherEntityByCode']);
     $discountSaver->expects($this->once())->method('persistSalesDiscount');
     $discountSaver->expects($this->never())->method('persistSalesDiscountCode');
     $discountSaver->expects($this->once())->method('getDiscountVoucherEntityByCode')->will($this->returnValue(false));
     $calculatedDiscountTransfer = new CalculatedDiscountTransfer();
     $calculatedDiscountTransfer->setVoucherCode(self::USED_CODE_1);
     $quoteTransfer = new QuoteTransfer();
     $orderItemTransfer = new ItemTransfer();
     $orderItemTransfer->addCalculatedDiscount($calculatedDiscountTransfer);
     $quoteTransfer->addItem($orderItemTransfer);
     $checkoutResponseTransfer = new CheckoutResponseTransfer();
     $saverOrderTransfer = new SaveOrderTransfer();
     $saverOrderTransfer->setIdSalesOrder(self::ID_SALES_ORDER);
     $saverOrderTransfer->setOrderItems($quoteTransfer->getItems());
     $checkoutResponseTransfer->setSaveOrder($saverOrderTransfer);
     $discountSaver->saveDiscounts($quoteTransfer, $checkoutResponseTransfer);
 }