magento / graphql-ce

[ARCHIVED] Please use magento/magento2 project
https://github.com/magento/magento2
Open Software License 3.0
131 stars 156 forks source link

[Test coverage] Cover exceptions in CustomerGraphQl\Model\Customer\CheckCustomerPassword #985

Closed TomashKhamlai closed 5 years ago

TomashKhamlai commented 5 years ago

Description:

Cover exceptions with API-functional tests: https://github.com/magento/graphql-ce/blob/6690a49405fa70231aba816267e24510fc9f8689/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php#L54 https://github.com/magento/graphql-ce/blob/6690a49405fa70231aba816267e24510fc9f8689/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php#L56 https://github.com/magento/graphql-ce/blob/6690a49405fa70231aba816267e24510fc9f8689/app/code/Magento/CustomerGraphQl/Model/Customer/CheckCustomerPassword.php#L58

Examples:

Magento\GraphQl\Customer Magento\GraphQl\Quote\Customer

Guide:

Graphql Functional Testing

atwixfirster commented 5 years ago

throw new GraphQlAuthenticationException(__($e->getMessage()), $e);

Test case "Try to change customer password when customer's account is locked" is already covered in dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/ChangeCustomerPasswordTest.php::testChangePasswordIfCustomerIsLocked()

throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);

Impossible to cover this case. Because customer's token is assigned to particular customer ID (see oauth_token.customer_id). So, if we have a token then we have an ID of existing customer.

throw new GraphQlInputException(__($e->getMessage()), $e);

It will never appear because we have input params validations in app/code/Magento/CustomerGraphQl/Model/Resolver/ChangePassword.php and these cases already covered in dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/ChangeCustomerPasswordTest.php.

atwixfirster commented 5 years ago

I've created a PR https://github.com/magento/graphql-ce/pull/995 that removes unnecessary exceptions in Magento\CustomerGraphQl\Model\Customer\CheckCustomerPassword.