Пример #1
0
 public function testCreateRequestToken()
 {
     $entityId = 1;
     $callbackUrl = OauthHelper::CALLBACK_ESTABLISHED;
     $token = 'token';
     $secret = 'secret';
     $this->oauthHelperMock->expects($this->once())->method('generateTokenSecret')->willReturn($secret);
     $this->oauthHelperMock->expects($this->once())->method('generateToken')->willReturn($token);
     $this->tokenModel->setCallbackUrl($callbackUrl);
     $this->keyLengthFactoryMock->expects($this->once())->method('create')->willReturn($this->validatorKeyLengthMock);
     $this->validatorKeyLengthMock->expects($this->exactly(2))->method('setLength');
     $this->validatorKeyLengthMock->expects($this->exactly(2))->method('setName');
     $this->validatorKeyLengthMock->expects($this->exactly(2))->method('isValid')->willReturn(true);
     $this->resourceMock->expects($this->once())->method('save');
     $actualToken = $this->tokenModel->createRequestToken($entityId, $callbackUrl);
     $this->assertEquals($this->tokenModel, $actualToken);
     $this->assertEquals($this->tokenModel->getSecret(), $actualToken->getSecret());
     $this->assertEquals($this->tokenModel->getToken(), $actualToken->getToken());
 }