6 declare(strict_types=1);
26 public function testRegisteredCustomerWithValidCredentials()
60 $password =
'password';
63 ->get(\
Magento\Integration\Api\CustomerTokenServiceInterface::class);
64 $customerToken = $customerTokenService->createCustomerAccessToken(
$userName, $password);
65 $headerMap = [
'Authorization' =>
'Bearer ' . $customerToken];
71 $this->assertArrayHasKey(
'customer',
$response);
72 $this->assertArrayHasKey(
'addresses',
$response[
'customer']);
74 is_array([
$response[
'customer'][
'addresses']]),
75 " Addresses field must be of an array type." 108 $this->expectException(\Exception::class);
109 $this->expectExceptionMessage(
'GraphQL response contains errors: Current customer' .
' ' .
110 'does not have access to the resource "customer"');
124 [
'response_field' =>
'id',
'expected_value' =>
$customer->getId()],
125 [
'response_field' =>
'created_at',
'expected_value' =>
$customer->getCreatedAt()],
126 [
'response_field' =>
'group_id',
'expected_value' =>
$customer->getGroupId()],
127 [
'response_field' =>
'prefix',
'expected_value' =>
$customer->getPrefix()],
128 [
'response_field' =>
'firstname',
'expected_value' =>
$customer->getFirstname()],
129 [
'response_field' =>
'middlename',
'expected_value' =>
$customer->getMiddlename()],
130 [
'response_field' =>
'lastname',
'expected_value' =>
$customer->getLastname()],
131 [
'response_field' =>
'suffix',
'expected_value' =>
$customer->getSuffix()],
132 [
'response_field' =>
'email',
'expected_value' =>
$customer->getEmail()],
133 [
'response_field' =>
'default_shipping',
'expected_value' => (bool)
$customer->getDefaultShipping()],
134 [
'response_field' =>
'default_billing',
'expected_value' => (bool)
$customer->getDefaultBilling()],
135 [
'response_field' =>
'id',
'expected_value' =>
$customer->getId()]
147 public function assertCustomerAddressesFields(
$customer, $actualResponse)
151 foreach (
$addresses as $addressKey => $addressValue) {
152 $this->assertNotEmpty($addressValue);
154 [
'response_field' =>
'id',
'expected_value' =>
$addresses[$addressKey]->getId()],
155 [
'response_field' =>
'customer_id',
'expected_value' =>
$addresses[$addressKey]->getCustomerId()],
156 [
'response_field' =>
'region_id',
'expected_value' =>
$addresses[$addressKey]->getRegionId()],
157 [
'response_field' =>
'country_id',
'expected_value' =>
$addresses[$addressKey]->getCountryId()],
158 [
'response_field' =>
'telephone',
'expected_value' =>
$addresses[$addressKey]->getTelephone()],
159 [
'response_field' =>
'postcode',
'expected_value' =>
$addresses[$addressKey]->getPostcode()],
160 [
'response_field' =>
'city',
'expected_value' =>
$addresses[$addressKey]->getCity()],
161 [
'response_field' =>
'firstname',
'expected_value' =>
$addresses[$addressKey]->getFirstname()],
162 [
'response_field' =>
'lastname',
'expected_value' =>
$addresses[$addressKey]->getLastname()]
164 $this->
assertResponseFields($actualResponse[
'customer'][
'addresses'][$addressKey], $assertionMap);
assertResponseFields($actualResponse, $assertionMap)
testCustomerWithValidCredentialsWithoutToken()
assertCustomerFields($customer, $actualResponse)
graphQlQuery(string $query, array $variables=[], string $operationName='', array $headers=[])