This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENGCOM-6270: Refactor Magento\GraphQl\Quote\Customer\GetCustomerCartT…
…est #1056
- Loading branch information
Showing
1 changed file
with
7 additions
and
39 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 |
---|---|---|
|
@@ -90,10 +90,8 @@ public function testGetLoggedInCustomerCartWithoutMaskedQuoteId() | |
*/ | ||
public function testGetNewCustomerCart() | ||
{ | ||
$customerToken = $this->generateCustomerToken(); | ||
$customerCartQuery = $this->getCustomerCartQuery(); | ||
$headers = ['Authorization' => 'Bearer ' . $customerToken]; | ||
$response = $this->graphQlQuery($customerCartQuery, [], '', $headers); | ||
$response = $this->graphQlQuery($customerCartQuery, [], '', $this->getHeaderMap()); | ||
$this->assertArrayHasKey('customerCart', $response); | ||
$this->assertArrayHasKey('id', $response['customerCart']); | ||
$this->assertNotNull($response['customerCart']['id']); | ||
|
@@ -118,22 +116,20 @@ public function testGetCustomerCartWithNoCustomerToken() | |
* Query for customer cart after customer token is revoked | ||
* | ||
* @magentoApiDataFixture Magento/Customer/_files/customer.php | ||
* @expectedException \Exception | ||
* @expectedExceptionMessage The request is allowed for logged in customer | ||
*/ | ||
public function testGetCustomerCartAfterTokenRevoked() | ||
{ | ||
$customerToken = $this->generateCustomerToken(); | ||
$headers = ['Authorization' => 'Bearer ' . $customerToken]; | ||
$customerCartQuery = $this->getCustomerCartQuery(); | ||
$headers = $this->getHeaderMap(); | ||
$response = $this->graphQlMutation($customerCartQuery, [], '', $headers); | ||
$this->assertArrayHasKey('customerCart', $response); | ||
$this->assertArrayHasKey('id', $response['customerCart']); | ||
$this->assertNotNull($response['customerCart']['id']); | ||
$this->assertNotEmpty($response['customerCart']['id']); | ||
$this->revokeCustomerToken(); | ||
$customerCartQuery = $this->getCustomerCartQuery(); | ||
$this->expectExceptionMessage( | ||
'The request is allowed for logged in customer' | ||
); | ||
$this->graphQlQuery($customerCartQuery, [], '', $headers); | ||
} | ||
|
||
|
@@ -144,16 +140,14 @@ public function testGetCustomerCartAfterTokenRevoked() | |
*/ | ||
public function testRequestCustomerCartTwice() | ||
{ | ||
$customerToken = $this->generateCustomerToken(); | ||
$headers = ['Authorization' => 'Bearer ' . $customerToken]; | ||
$customerCartQuery = $this->getCustomerCartQuery(); | ||
$response = $this->graphQlMutation($customerCartQuery, [], '', $headers); | ||
$response = $this->graphQlMutation($customerCartQuery, [], '', $this->getHeaderMap()); | ||
$this->assertArrayHasKey('customerCart', $response); | ||
$this->assertArrayHasKey('id', $response['customerCart']); | ||
$this->assertNotNull($response['customerCart']['id']); | ||
$cartId = $response['customerCart']['id']; | ||
$customerCartQuery = $this->getCustomerCartQuery(); | ||
$response2 = $this->graphQlQuery($customerCartQuery, [], '', $headers); | ||
$response2 = $this->graphQlQuery($customerCartQuery, [], '', $this->getHeaderMap()); | ||
$this->assertEquals($cartId, $response2['customerCart']['id']); | ||
} | ||
|
||
|
@@ -192,31 +186,6 @@ public function testGetCustomerCartSecondStore() | |
$this->assertEquals($maskedQuoteIdSecondStore, $responseSecondStore['customerCart']['id']); | ||
} | ||
|
||
/** | ||
* Query to generate customer token | ||
* | ||
* @return string | ||
*/ | ||
private function generateCustomerToken(): string | ||
{ | ||
$query = <<<QUERY | ||
mutation { | ||
generateCustomerToken( | ||
email: "[email protected]" | ||
password: "password" | ||
) { | ||
token | ||
} | ||
} | ||
QUERY; | ||
$response = $this->graphQlMutation($query); | ||
self::assertArrayHasKey('generateCustomerToken', $response); | ||
self::assertArrayHasKey('token', $response['generateCustomerToken']); | ||
self::assertNotEmpty($response['generateCustomerToken']['token']); | ||
|
||
return $response['generateCustomerToken']['token']; | ||
} | ||
|
||
/** | ||
* Query to revoke customer token | ||
* | ||
|
@@ -232,8 +201,7 @@ private function revokeCustomerToken(): void | |
} | ||
QUERY; | ||
|
||
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap()); | ||
$this->assertTrue($response['revokeCustomerToken']['result']); | ||
$this->graphQlMutation($query, [], '', $this->getHeaderMap()); | ||
} | ||
|
||
/** | ||
|