shippingMethodManagementMock = $this->createMock(\Magento\Quote\Model\ShippingMethodManagement::class); $guestCartTestHelper = new GuestCartTestHelper($this); list($this->quoteIdMaskFactoryMock, $this->quoteIdMask) = $guestCartTestHelper->mockQuoteIdMask( $this->maskedCartId, $this->cartId ); $this->shipmentEstimationManagement = $this->getMockForAbstractClass(ShipmentEstimationInterface::class); $this->model = $objectManager->getObject( GuestShippingMethodManagement::class, [ 'shippingMethodManagement' => $this->shippingMethodManagementMock, 'quoteIdMaskFactory' => $this->quoteIdMaskFactoryMock, ] ); $refObject = new \ReflectionClass(GuestShippingMethodManagement::class); $refProperty = $refObject->getProperty('shipmentEstimationManagement'); $refProperty->setAccessible(true); $refProperty->setValue($this->model, $this->shipmentEstimationManagement); } public function testSet() { $carrierCode = 'carrierCode'; $methodCode = 'methodCode'; $retValue = 'retValue'; $this->shippingMethodManagementMock->expects($this->once()) ->method('set') ->with($this->cartId, $carrierCode, $methodCode) ->will($this->returnValue($retValue)); $this->assertEquals($retValue, $this->model->set($this->maskedCartId, $carrierCode, $methodCode)); } public function testGetList() { $retValue = 'retValue'; $this->shippingMethodManagementMock->expects($this->once()) ->method('getList') ->with($this->cartId) ->will($this->returnValue($retValue)); $this->assertEquals($retValue, $this->model->getList($this->maskedCartId)); } public function testGet() { $retValue = 'retValue'; $this->shippingMethodManagementMock->expects($this->once()) ->method('get') ->with($this->cartId) ->will($this->returnValue($retValue)); $this->assertEquals($retValue, $this->model->get($this->maskedCartId)); } /** * @covers \Magento\Quote\Model\GuestCart\GuestShippingMethodManagement::getShipmentEstimationManagement */ public function testEstimateByExtendedAddress() { $address = $this->getMockForAbstractClass(AddressInterface::class); $methodObject = $this->getMockForAbstractClass(ShippingMethodInterface::class); $expectedRates = [$methodObject]; $this->shipmentEstimationManagement->expects(static::once()) ->method('estimateByExtendedAddress') ->with($this->cartId, $address) ->willReturn($expectedRates); $carriersRates = $this->model->estimateByExtendedAddress($this->maskedCartId, $address); static::assertEquals($expectedRates, $carriersRates); } }