Пример #1
0
 /**
  * Load token object given a consumer Id.
  *
  * @param int $consumerId - The Id of the consumer.
  * @return Token
  * @throws \Magento\Framework\Oauth\Exception
  */
 public function getIntegrationTokenByConsumerId($consumerId)
 {
     $token = $this->token->loadByConsumerIdAndUserType($consumerId, UserContextInterface::USER_TYPE_INTEGRATION);
     if (!$token->getId()) {
         throw new \Magento\Framework\Oauth\Exception('A token with consumer ID %1 does not exist', [$consumerId]);
     }
     return $token;
 }
Пример #2
0
 public function testLoadByConsumerIdAndUserType()
 {
     $consumerId = 1;
     $userType = 1;
     $tokenData = 'testToken';
     $data = ['token' => $tokenData];
     $this->resourceMock->expects($this->once())->method('selectTokenByConsumerIdAndUserType')->willReturn($data);
     $actualToken = $this->tokenModel->loadByConsumerIdAndUserType($consumerId, $userType);
     $this->assertEquals($this->tokenModel, $actualToken);
     $this->assertEquals($tokenData, $actualToken->getToken());
 }