Exemplo n.º 1
0
 public function testGetMethodIfMethodIsNotSet()
 {
     $cartId = 666;
     $countryId = 1;
     $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock));
     $this->shippingAddressMock->expects($this->any())->method('getCountryId')->will($this->returnValue($countryId));
     $this->shippingAddressMock->expects($this->any())->method('getShippingMethod')->will($this->returnValue(null));
     $this->assertNull($this->service->getMethod($cartId));
 }
 public function testGetMethod()
 {
     $storeId = 12;
     $cartId = 666;
     $countryId = 1;
     $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->storeMock->expects($this->once())->method('getId')->will($this->returnValue($storeId));
     $this->quoteLoaderMock->expects($this->once())->method('load')->with($cartId, $storeId)->will($this->returnValue($this->quoteMock));
     $this->quoteMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($this->shippingAddressMock));
     $this->shippingAddressMock->expects($this->any())->method('getCountryId')->will($this->returnValue($countryId));
     $this->shippingAddressMock->expects($this->any())->method('getShippingMethod')->will($this->returnValue('one_two'));
     $this->shippingAddressMock->expects($this->once())->method('getShippingDescription')->will($this->returnValue('carrier - method'));
     $this->shippingAddressMock->expects($this->once())->method('getShippingAmount')->will($this->returnValue(123.56));
     $this->shippingAddressMock->expects($this->once())->method('getBaseShippingAmount')->will($this->returnValue(100.06));
     $output = [ShippingMethod::CARRIER_CODE => 'one', ShippingMethod::METHOD_CODE => 'two', ShippingMethod::CARRIER_TITLE => 'carrier', ShippingMethod::METHOD_TITLE => 'method', ShippingMethod::SHIPPING_AMOUNT => 123.56, ShippingMethod::BASE_SHIPPING_AMOUNT => 100.06, ShippingMethod::AVAILABLE => true];
     $this->methodBuilderMock->expects($this->once())->method('populateWithArray')->with($output)->will($this->returnValue($this->methodBuilderMock));
     $this->methodBuilderMock->expects($this->once())->method('create');
     $this->service->getMethod($cartId);
 }