Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
magento/magento2#675: [Test coverage] Generate customer token
Browse files Browse the repository at this point in the history
- test refactoring
  • Loading branch information
lenaorobei committed Jun 7, 2019
1 parent b75f352 commit 35293ae
Showing 1 changed file with 22 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,7 @@ public function testGenerateCustomerValidToken()
$email = 'customer@example.com';
$password = 'password';

$mutation
= <<<MUTATION
mutation {
generateCustomerToken(
email: "{$email}"
password: "{$password}"
) {
token
}
}
MUTATION;
$mutation = $this->getQuery($email, $password);

$response = $this->graphQlMutation($mutation);
$this->assertArrayHasKey('generateCustomerToken', $response);
Expand All @@ -52,19 +42,9 @@ public function testGenerateCustomerValidToken()
* @param string $password
* @param string $message
*/
public function testGenerateCustomerTokenNegativeCases(string $email, string $password, string $message)
public function testGenerateCustomerTokenInvalidData(string $email, string $password, string $message)
{
$mutation
= <<<MUTATION
mutation {
generateCustomerToken(
email: "{$email}"
password: "{$password}"
) {
token
}
}
MUTATION;
$mutation = $this->getQuery($email, $password);
$this->expectExceptionMessage($message);
$this->graphQlMutation($mutation);
}
Expand All @@ -79,17 +59,7 @@ public function testRegenerateCustomerToken()
$email = 'customer@example.com';
$password = 'password';

$mutation
= <<<MUTATION
mutation {
generateCustomerToken(
email: "{$email}"
password: "{$password}"
) {
token
}
}
MUTATION;
$mutation = $this->getQuery($email, $password);

$response1 = $this->graphQlMutation($mutation);
$token1 = $response1['generateCustomerToken']['token'];
Expand Down Expand Up @@ -131,4 +101,22 @@ public function dataProviderInvalidCustomerInfo(): array
]
];
}

/**
* @param string $email
* @param string $password
* @return string
*/
private function getQuery(string $email, string $password) : string {
return <<<MUTATION
mutation {
generateCustomerToken(
email: "{$email}"
password: "{$password}"
) {
token
}
}
MUTATION;
}
}

0 comments on commit 35293ae

Please sign in to comment.