Skip to content

Commit

Permalink
GraphQL-423: Added RateFactory instead of Rate
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksLi committed Mar 18, 2019
1 parent 112f425 commit d9a5f4a
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
use Magento\Quote\Model\Quote\Address\Rate;
use Magento\Quote\Model\Quote\Address\RateFactory;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteFactory;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
Expand All @@ -35,9 +36,9 @@ class SetShippingMethodsOnCartTest extends GraphQlAbstract
private $productRepository;

/**
* @var Rate
* @var RateFactory
*/
private $rate;
private $rateFactory;

/**
* @var QuoteResource
Expand Down Expand Up @@ -66,7 +67,7 @@ protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->productRepository = $objectManager->get(ProductRepositoryInterface::class);
$this->rate = $objectManager->get(Rate::class);
$this->rateFactory = $objectManager->get(RateFactory::class);
$this->quoteResource = $objectManager->get(QuoteResource::class);
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
$this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
Expand All @@ -88,7 +89,9 @@ public function testShippingMethodWithVirtualProduct()
$this->quoteResource->load($quote, 'test_order_with_virtual_product', 'reserved_order_id');

$shippingAddress = $quote->getShippingAddress();
$rate = $this->rate;

/** @var Rate $rate */
$rate = $this->rateFactory->create();

$rate->setPrice(2)
->setAddressId($shippingAddress->getId())
Expand Down Expand Up @@ -127,7 +130,9 @@ public function testShippingMethodWithSimpleProduct()
$quote->addProduct($product, 1);

$shippingAddress = $quote->getShippingAddress();
$rate = $this->rate;

/** @var Rate $rate */
$rate = $this->rateFactory->create();

$rate->setPrice(2)
->setAddressId($shippingAddress->getId())
Expand Down Expand Up @@ -162,7 +167,9 @@ public function testShippingMethodWithSimpleProductWithoutAddress()
$this->quoteResource->load($quote, 'test_order_with_simple_product_without_address', 'reserved_order_id');

$shippingAddress = $quote->getShippingAddress();
$rate = $this->rate;

/** @var Rate $rate */
$rate = $this->rateFactory->create();

$rate->setPrice(2)
->setAddressId($shippingAddress->getId())
Expand Down Expand Up @@ -225,7 +232,9 @@ public function testSetNonExistentShippingMethod()
$quote->addProduct($product, 1);

$shippingAddress = $quote->getShippingAddress();
$rate = $this->rate;

/** @var Rate $rate */
$rate = $this->rateFactory->create();

$rate->setPrice(2)
->setAddressId($shippingAddress->getId())
Expand Down Expand Up @@ -269,7 +278,9 @@ public function testSetShippingMethodIfAddressIsNotBelongToCart()
$quote->addProduct($product, 1);

$shippingAddress = $quote->getShippingAddress();
$rate = $this->rate;

/** @var Rate $rate */
$rate = $this->rateFactory->create();

$rate->setPrice(2)
->setAddressId($shippingAddress->getId())
Expand Down

0 comments on commit d9a5f4a

Please sign in to comment.