Пример #1
0
 public function testCollect()
 {
     $this->shippingAssignment->expects($this->exactly(3))->method('getShipping')->willReturn($this->shipping);
     $this->shipping->expects($this->exactly(2))->method('getAddress')->willReturn($this->address);
     $this->shipping->expects($this->once())->method('getMethod')->willReturn('flatrate');
     $this->shippingAssignment->expects($this->atLeastOnce())->method('getItems')->willReturn([$this->cartItem]);
     $this->freeShipping->expects($this->once())->method('isFreeShipping')->with($this->quote, [$this->cartItem])->willReturn(true);
     $this->address->expects($this->once())->method('setFreeShipping')->with(true);
     $this->total->expects($this->atLeastOnce())->method('setTotalAmount');
     $this->total->expects($this->atLeastOnce())->method('setBaseTotalAmount');
     $this->cartItem->expects($this->atLeastOnce())->method('getProduct')->willReturnSelf();
     $this->cartItem->expects($this->atLeastOnce())->method('isVirtual')->willReturn(false);
     $this->cartItem->expects($this->once())->method('getParentItem')->willReturn(false);
     $this->cartItem->expects($this->once())->method('getHasChildren')->willReturn(false);
     $this->cartItem->expects($this->once())->method('getWeight')->willReturn(2);
     $this->cartItem->expects($this->atLeastOnce())->method('getQty')->willReturn(2);
     $this->address->expects($this->once())->method('getFreeShipping')->willReturn(true);
     $this->cartItem->expects($this->once())->method('setRowWeight')->with(0);
     $this->address->expects($this->once())->method('setItemQty')->with(2);
     $this->address->expects($this->atLeastOnce())->method('setWeight');
     $this->address->expects($this->atLeastOnce())->method('setFreeMethodWeight');
     $this->address->expects($this->once())->method('collectShippingRates');
     $this->address->expects($this->once())->method('getAllShippingRates')->willReturn([$this->rate]);
     $this->rate->expects($this->once())->method('getCode')->willReturn('flatrate');
     $this->quote->expects($this->once())->method('getStore')->willReturn($this->store);
     $this->rate->expects($this->atLeastOnce())->method('getPrice')->willReturn(5);
     $this->priceCurrency->expects($this->once())->method('convert')->with(5, $this->store)->willReturn(5);
     $this->total->expects($this->once())->method('setShippingAmount')->with(5);
     $this->rate->expects($this->once())->method('getCarrierTitle')->willReturn('Carrier title');
     $this->rate->expects($this->once())->method('getMethodTitle')->willReturn('Method title');
     $this->address->expects($this->once())->method('setShippingDescription')->with('Carrier title - Method title');
     $this->address->expects($this->once())->method('getShippingDescription')->willReturn('Carrier title - Method title');
     $this->total->expects($this->once())->method('setShippingDescription')->with('Carrier title - Method title');
     $this->shippingModel->collect($this->quote, $this->shippingAssignment, $this->total);
 }