Exemplo n.º 1
0
 /**
  * @magentoApiDataFixture Magento/Customer/_files/customer.php
  */
 public function testCreateCustomerAccessToken()
 {
     $customerUserName = '******';
     $password = '******';
     $isTokenCorrect = false;
     $serviceInfo = ['rest' => ['resourcePath' => self::RESOURCE_PATH_CUSTOMER_TOKEN, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST]];
     $requestData = ['username' => $customerUserName, 'password' => $password];
     $accessToken = $this->_webApiCall($serviceInfo, $requestData);
     $customerData = $this->customerAccountManagement->authenticate($customerUserName, $password);
     /** @var $this->tokenCollection \Magento\Integration\Model\Resource\Oauth\Token\Collection */
     $this->tokenCollection->addFilterByCustomerId($customerData->getId());
     foreach ($this->tokenCollection->getItems() as $item) {
         /** @var $item TokenModel */
         if ($item->getToken() == $accessToken) {
             $isTokenCorrect = true;
         }
     }
     $this->assertTrue($isTokenCorrect);
 }