-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/432-reversed-quote-id-test-cover…
…age' into GraphQL-538
- Loading branch information
Showing
13 changed files
with
206 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,8 @@ | |
|
||
namespace Magento\GraphQl\Quote\Customer; | ||
|
||
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; | ||
use Magento\Integration\Api\CustomerTokenServiceInterface; | ||
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; | ||
|
||
|
@@ -25,29 +23,17 @@ class GetAvailablePaymentMethodsTest extends GraphQlAbstract | |
private $customerTokenService; | ||
|
||
/** | ||
* @var QuoteResource | ||
* @var GetMaskedQuoteIdByReservedOrderId | ||
*/ | ||
private $quoteResource; | ||
|
||
/** | ||
* @var QuoteFactory | ||
*/ | ||
private $quoteFactory; | ||
|
||
/** | ||
* @var QuoteIdToMaskedQuoteIdInterface | ||
*/ | ||
private $quoteIdToMaskedId; | ||
private $getMaskedQuoteIdByReservedOrderId; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function setUp() | ||
{ | ||
$objectManager = Bootstrap::getObjectManager(); | ||
$this->quoteResource = $objectManager->get(QuoteResource::class); | ||
$this->quoteFactory = $objectManager->get(QuoteFactory::class); | ||
$this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class); | ||
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); | ||
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class); | ||
} | ||
|
||
|
@@ -56,7 +42,7 @@ protected function setUp() | |
*/ | ||
public function testGetCartWithPaymentMethods() | ||
{ | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items'); | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_item_with_items'); | ||
$query = $this->getQuery($maskedQuoteId); | ||
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap()); | ||
|
||
|
@@ -76,7 +62,7 @@ public function testGetCartWithPaymentMethods() | |
*/ | ||
public function testGetPaymentMethodsFromGuestCart() | ||
{ | ||
$guestQuoteMaskedId = $this->getMaskedQuoteIdByReservedOrderId( | ||
$guestQuoteMaskedId = $this->getMaskedQuoteIdByReservedOrderId->execute( | ||
'test_order_with_virtual_product_without_address' | ||
); | ||
$query = $this->getQuery($guestQuoteMaskedId); | ||
|
@@ -93,7 +79,7 @@ public function testGetPaymentMethodsFromGuestCart() | |
*/ | ||
public function testGetPaymentMethodsFromAnotherCustomerCart() | ||
{ | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items'); | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_item_with_items'); | ||
$query = $this->getQuery($maskedQuoteId); | ||
|
||
$this->expectExceptionMessage( | ||
|
@@ -108,7 +94,7 @@ public function testGetPaymentMethodsFromAnotherCustomerCart() | |
*/ | ||
public function testGetPaymentMethodsIfPaymentsAreNotSet() | ||
{ | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId('test_order_item_with_items'); | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_item_with_items'); | ||
$query = $this->getQuery($maskedQuoteId); | ||
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap()); | ||
|
||
|
@@ -158,16 +144,4 @@ private function getHeaderMap(string $username = '[email protected]', string | |
$headerMap = ['Authorization' => 'Bearer ' . $customerToken]; | ||
return $headerMap; | ||
} | ||
|
||
/** | ||
* @param string $reservedOrderId | ||
* @return string | ||
*/ | ||
private function getMaskedQuoteIdByReservedOrderId(string $reservedOrderId): string | ||
{ | ||
$quote = $this->quoteFactory->create(); | ||
$this->quoteResource->load($quote, $reservedOrderId, 'reserved_order_id'); | ||
|
||
return $this->quoteIdToMaskedId->execute((int)$quote->getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
|
||
namespace Magento\GraphQl\Quote\Customer; | ||
|
||
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId; | ||
use Magento\Integration\Api\CustomerTokenServiceInterface; | ||
use Magento\Quote\Model\QuoteFactory; | ||
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface; | ||
|
@@ -19,6 +20,11 @@ | |
*/ | ||
class SetBillingAddressOnCartTest extends GraphQlAbstract | ||
{ | ||
/** | ||
* @var GetMaskedQuoteIdByReservedOrderId | ||
*/ | ||
private $getMaskedQuoteIdByReservedOrderId; | ||
|
||
/** | ||
* @var QuoteResource | ||
*/ | ||
|
@@ -42,6 +48,7 @@ class SetBillingAddressOnCartTest extends GraphQlAbstract | |
protected function setUp() | ||
{ | ||
$objectManager = Bootstrap::getObjectManager(); | ||
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class); | ||
$this->quoteResource = $objectManager->get(QuoteResource::class); | ||
$this->quoteFactory = $objectManager->get(QuoteFactory::class); | ||
$this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class); | ||
|
@@ -310,7 +317,9 @@ public function testSetNewBillingAddressAndFromAddressBookAtSameTime() | |
*/ | ||
public function testSetBillingAddressToGuestCart() | ||
{ | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_with_simple_product_without_address'); | ||
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute( | ||
'test_order_with_simple_product_without_address' | ||
); | ||
|
||
$query = <<<QUERY | ||
mutation { | ||
|
@@ -480,28 +489,16 @@ private function getHeaderMap(string $username = '[email protected]', string | |
} | ||
|
||
/** | ||
* @param string $reversedQuoteId | ||
* @return string | ||
*/ | ||
private function getMaskedQuoteIdByReversedQuoteId(string $reversedQuoteId): string | ||
{ | ||
$quote = $this->quoteFactory->create(); | ||
$this->quoteResource->load($quote, $reversedQuoteId, 'reserved_order_id'); | ||
|
||
return $this->quoteIdToMaskedId->execute((int)$quote->getId()); | ||
} | ||
|
||
/** | ||
* @param string $reversedQuoteId | ||
* @param string $reversedOrderId | ||
* @param int $customerId | ||
* @return string | ||
*/ | ||
private function assignQuoteToCustomer( | ||
string $reversedQuoteId = 'test_order_with_simple_product_without_address', | ||
string $reversedOrderId = 'test_order_with_simple_product_without_address', | ||
int $customerId = 1 | ||
): string { | ||
$quote = $this->quoteFactory->create(); | ||
$this->quoteResource->load($quote, $reversedQuoteId, 'reserved_order_id'); | ||
$this->quoteResource->load($quote, $reversedOrderId, 'reserved_order_id'); | ||
$quote->setCustomerId($customerId); | ||
$this->quoteResource->save($quote); | ||
return $this->quoteIdToMaskedId->execute((int)$quote->getId()); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -513,16 +513,16 @@ private function getHeaderMap(string $username = '[email protected]', string | |
} | ||
|
||
/** | ||
* @param string $reversedQuoteId | ||
* @param string $reversedOrderId | ||
* @param int $customerId | ||
* @return string | ||
*/ | ||
private function assignQuoteToCustomer( | ||
string $reversedQuoteId = 'test_order_with_simple_product_without_address', | ||
string $reversedOrderId = 'test_order_with_simple_product_without_address', | ||
int $customerId = 1 | ||
): string { | ||
$quote = $this->quoteFactory->create(); | ||
$this->quoteResource->load($quote, $reversedQuoteId, 'reserved_order_id'); | ||
$this->quoteResource->load($quote, $reversedOrderId, 'reserved_order_id'); | ||
$quote->setCustomerId($customerId); | ||
$this->quoteResource->save($quote); | ||
return $this->quoteIdToMaskedId->execute((int)$quote->getId()); | ||
|
Oops, something went wrong.