Skip to content

Commit

Permalink
GraphQL-423: Fixed some errors. Replaced save quote to save by quote …
Browse files Browse the repository at this point in the history
…repository. Worked on code style.
  • Loading branch information
AleksLi committed Mar 27, 2019
1 parent 1bd2068 commit d280bb0
Showing 1 changed file with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
use Magento\Quote\Model\Quote\Address\Rate;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteFactory;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;

/**
* Test for setting shipping methods on cart for customer
Expand All @@ -30,48 +30,48 @@ class SetShippingMethodsOnCartTest extends GraphQlAbstract
private $customerTokenService;

/**
* @var QuoteResource
* @var ProductRepositoryInterface
*/
private $quoteResource;
private $productRepository;

/**
* @var QuoteFactory
* @var Rate
*/
private $quoteFactory;
private $rate;

/**
* @var QuoteIdToMaskedQuoteIdInterface
* @var QuoteResource
*/
private $quoteIdToMaskedId;
private $quoteResource;

/**
* @var Rate
* @var QuoteFactory
*/
private $rate;
private $quoteFactory;

/**
* @var ProductRepositoryInterface
* @var CartRepositoryInterface
*/
private $productRepository;
private $quoteRepository;

/**
* @var CartRepositoryInterface
* @var QuoteIdToMaskedQuoteIdInterface
*/
private $quoteRepository;
private $quoteIdToMaskedId;

/**
* @inheritdoc
*/
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->productRepository = $objectManager->get(ProductRepositoryInterface::class);
$this->rate = $objectManager->get(Rate::class);
$this->quoteResource = $objectManager->get(QuoteResource::class);
$this->quoteFactory = $objectManager->get(QuoteFactory::class);
$this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
$this->quoteRepository = $objectManager->get(CartRepositoryInterface::class);
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
$this->rate = $objectManager->get(Rate::class);
$this->productRepository = $objectManager->get(ProductRepositoryInterface::class);
}

/**
Expand All @@ -94,8 +94,9 @@ public function testShippingMethodWithVirtualProduct()
->setAddressId($shippingAddress->getId())
->setCode('flatrate_flatrate');
$shippingAddress->setShippingMethod('flatrate_flatrate')
->addShippingRate($rate)
->save();
->addShippingRate($rate);

$this->quoteRepository->save($quote);

$mutation = $this->prepareMutationQuery(
$maskedQuoteId,
Expand Down Expand Up @@ -132,8 +133,9 @@ public function testShippingMethodWithSimpleProduct()
->setAddressId($shippingAddress->getId())
->setCode('flatrate_flatrate');
$shippingAddress->setShippingMethod('flatrate_flatrate')
->addShippingRate($rate)
->save();
->addShippingRate($rate);

$this->quoteRepository->save($quote);

$mutation = $this->prepareMutationQuery(
$maskedQuoteId,
Expand Down Expand Up @@ -166,8 +168,9 @@ public function testShippingMethodWithSimpleProductWithoutAddress()
->setAddressId($shippingAddress->getId())
->setCode('flatrate_flatrate');
$shippingAddress->setShippingMethod('flatrate_flatrate')
->addShippingRate($rate)
->save();
->addShippingRate($rate);

$this->quoteRepository->save($quote);

$mutation = $this->prepareMutationQuery(
$maskedQuoteId,
Expand Down Expand Up @@ -228,8 +231,9 @@ public function testSetNonExistentShippingMethod()
->setAddressId($shippingAddress->getId())
->setCode('flatrate_flatrate');
$shippingAddress->setShippingMethod('flatrate_flatrate')
->addShippingRate($rate)
->save();
->addShippingRate($rate);

$this->quoteRepository->save($quote);

$mutation = $this->prepareMutationQuery(
$maskedQuoteId,
Expand Down Expand Up @@ -271,8 +275,9 @@ public function testSetShippingMethodIfAddressIsNotBelongToCart()
->setAddressId($shippingAddress->getId())
->setCode('flatrate_flatrate');
$shippingAddress->setShippingMethod('flatrate_flatrate')
->addShippingRate($rate)
->save();
->addShippingRate($rate);

$this->quoteRepository->save($quote);

$mutation = $this->prepareMutationQuery(
$maskedQuoteId,
Expand All @@ -295,13 +300,13 @@ public function testSetShippingMethodIfAddressIsNotBelongToCart()
*/
public function testSetShippingMethodToNonExistentCart()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_1');
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('Non_existent_cart_reversed_quote_id');

$mutation = $this->prepareMutationQuery(
$maskedQuoteId,
'flatrate',
'flatrate',
'1'
'80900'
);

$this->graphQlQuery($mutation, [], '', $this->getHeaderMap());
Expand Down Expand Up @@ -528,10 +533,6 @@ private function prepareMutationQuery(
QUERY;
}

private function addShippingMethodToQuote(Quote $quote)
{
}

/**
* @param string $reversedOrderId
* @return string
Expand Down

0 comments on commit d280bb0

Please sign in to comment.