public function testGetAccessSuccess() { $this->_consumerMock->expects($this->any())->method('load')->with(self::VALUE_CONSUMER_ID)->will($this->returnValue($this->_consumerMock)); $this->_tokenMock->expects($this->once())->method('getType')->will($this->returnValue(Token::TYPE_ACCESS)); $this->_tokenProviderMock->expects($this->any())->method('getIntegrationTokenByConsumerId')->will($this->returnValue($this->_tokenMock)); $this->assertEquals($this->_service->getAccessToken(self::VALUE_CONSUMER_ID), $this->_tokenMock); }
/** * @expectedException \Magento\Framework\Oauth\Exception * @expectedExceptionMessage A consumer having the specified key does not exist */ public function testGetConsumerByKeyNonExistentConsumer() { $consumerKeyString = '12345678901234567890123456789012'; $consumerId = null; $this->consumerFactoryMock->expects($this->once())->method('create')->willReturn($this->consumerMock); $this->consumerMock->expects($this->once())->method('loadByKey')->with($consumerKeyString)->willReturnSelf(); $this->consumerMock->expects($this->once())->method('getId')->willReturn($consumerId); $this->tokenProvider->getConsumerByKey($consumerKeyString); }
/** * {@inheritdoc} */ public function deleteIntegrationToken($consumerId) { try { $consumer = $this->_consumerFactory->create()->load($consumerId); $existingToken = $this->_tokenProvider->getIntegrationTokenByConsumerId($consumer->getId()); $existingToken->delete(); return true; } catch (\Exception $e) { return false; } }