Skip to content

Commit

Permalink
GraphQL-295: [Place order] Place order mutation
Browse files Browse the repository at this point in the history
  • Loading branch information
naydav committed Apr 3, 2019
1 parent 61b4ec8 commit 2299cf9
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@

namespace Magento\GraphQl\Quote\Customer;

use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Registry;
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Model\ResourceModel\Order\CollectionFactory;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;

Expand All @@ -27,6 +31,21 @@ class PlaceOrderTest extends GraphQlAbstract
*/
private $getMaskedQuoteIdByReservedOrderId;

/**
* @var CollectionFactory
*/
private $orderCollectionFactory;

/**
* @var OrderRepositoryInterface
*/
private $orderRepository;

/**
* @var Registry
*/
private $registry;

/**
* @inheritdoc
*/
Expand All @@ -35,6 +54,9 @@ protected function setUp()
$objectManager = Bootstrap::getObjectManager();
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
$this->orderCollectionFactory = $objectManager->get(CollectionFactory::class);
$this->orderRepository = $objectManager->get(OrderRepositoryInterface::class);
$this->registry = Bootstrap::getObjectManager()->get(Registry::class);
}

/**
Expand Down Expand Up @@ -253,4 +275,22 @@ private function getHeaderMap(string $username = 'customer@example.com', string
$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
return $headerMap;
}

/**
* @inheritdoc
*/
public function tearDown()
{
$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', true);

$orderCollection = $this->orderCollectionFactory->create();
foreach ($orderCollection as $order) {
$this->orderRepository->delete($order);
}
$this->registry->unregister('isSecureArea');
$this->registry->register('isSecureArea', false);

parent::tearDown();
}
}

0 comments on commit 2299cf9

Please sign in to comment.