diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php index a52938c13e5c..8100bce4ac71 100644 --- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php +++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php @@ -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,12 +116,13 @@ 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']); @@ -131,9 +130,6 @@ public function testGetCustomerCartAfterTokenRevoked() $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 = <<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()); } /**