/**
  * @test
  */
 public function shouldCreateAuthorizeTokenWithAfterPathAlreadyUrl()
 {
     $authorizeToken = new Token();
     $afterToken = new Token();
     $tokenStorageMock = $this->createStorageMock();
     $tokenStorageMock->expects($this->at(0))->method('createModel')->will($this->returnValue($afterToken));
     $tokenStorageMock->expects($this->at(1))->method('updateModel')->with($this->identicalTo($afterToken));
     $tokenStorageMock->expects($this->at(2))->method('createModel')->will($this->returnValue($authorizeToken));
     $tokenStorageMock->expects($this->at(3))->method('updateModel')->with($this->identicalTo($authorizeToken));
     $tokenStorageMock->expects($this->at(4))->method('updateModel')->with($this->identicalTo($authorizeToken));
     $model = new \stdClass();
     $identificator = new Identificator('anId', 'stdClass');
     $paymentName = 'thePaymentName';
     $modelStorage = $this->createStorageMock();
     $modelStorage->expects($this->exactly(2))->method('getIdentificator')->with($this->identicalTo($model))->will($this->returnValue($identificator));
     $storageRegistryMock = $this->createStorageRegistryMock();
     $storageRegistryMock->expects($this->exactly(2))->method('getStorage')->with($this->identicalTo($model))->will($this->returnValue($modelStorage));
     $factory = new GenericTokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com', 'capture.php', 'notify.php', 'authorize.php');
     $actualToken = $factory->createAuthorizeToken($paymentName, $model, 'http://google.com', array('afterKey' => 'afterVal'));
     $this->assertSame($authorizeToken, $actualToken);
     $this->assertEquals($paymentName, $authorizeToken->getPaymentName());
     $this->assertSame($identificator, $authorizeToken->getDetails());
     $this->assertEquals('http://example.com/authorize.php?payum_token=' . $authorizeToken->getHash(), $authorizeToken->getTargetUrl());
     $this->assertEquals('http://google.com?afterKey=afterVal&payum_token=' . $afterToken->getHash(), $authorizeToken->getAfterUrl());
 }
Esempio n. 2
0
 /**
  * @test
  */
 public function shouldAllowCreateAuthorizeToken()
 {
     $gatewayName = 'theGatewayName';
     $model = new \stdClass();
     $authorizePath = 'theAuthorizePath';
     $afterPath = 'theAfterPath';
     $afterUrl = 'theAfterUrl';
     $afterParameters = array('after' => 'val');
     $afterToken = new Token();
     $afterToken->setTargetUrl($afterUrl);
     $authorizeToken = new Token();
     $tokenFactoryMock = $this->createTokenFactoryMock();
     $tokenFactoryMock->expects($this->at(0))->method('createToken')->with($gatewayName, $this->identicalTo($model), $afterPath, $afterParameters, null, array())->willReturn($afterToken);
     $tokenFactoryMock->expects($this->at(1))->method('createToken')->with($gatewayName, $this->identicalTo($model), $authorizePath, array(), $afterUrl, array())->willReturn($authorizeToken);
     $factory = new GenericTokenFactory($tokenFactoryMock, array('authorize' => $authorizePath));
     $actualToken = $factory->createAuthorizeToken($gatewayName, $model, $afterPath, $afterParameters);
     $this->assertSame($authorizeToken, $actualToken);
 }