/**
  * @test
  */
 public function shouldCreateCaptureTokenWithAfterPathAlreadyUrl()
 {
     $captureToken = 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($captureToken));
     $tokenStorageMock->expects($this->at(3))->method('updateModel')->with($this->identicalTo($captureToken));
     $tokenStorageMock->expects($this->at(4))->method('updateModel')->with($this->identicalTo($captureToken));
     $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');
     $actualToken = $factory->createCaptureToken($paymentName, $model, 'http://google.com', array('afterKey' => 'afterVal'));
     $this->assertSame($captureToken, $actualToken);
     $this->assertEquals($paymentName, $captureToken->getPaymentName());
     $this->assertSame($identificator, $captureToken->getDetails());
     $this->assertEquals('http://example.com/capture.php?payum_token=' . $captureToken->getHash(), $captureToken->getTargetUrl());
     $this->assertEquals('http://google.com?afterKey=afterVal&payum_token=' . $afterToken->getHash(), $captureToken->getAfterUrl());
 }
예제 #2
0
 /**
  * @test
  */
 public function shouldAllowCreateCaptureToken()
 {
     $gatewayName = 'theGatewayName';
     $model = new \stdClass();
     $capturePath = 'theCapturePath';
     $afterPath = 'theAfterPath';
     $afterUrl = 'theAfterUrl';
     $afterParameters = array('after' => 'val');
     $afterToken = new Token();
     $afterToken->setTargetUrl($afterUrl);
     $captureToken = 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), $capturePath, array(), $afterUrl, array())->willReturn($captureToken);
     $factory = new GenericTokenFactory($tokenFactoryMock, array('capture' => $capturePath));
     $actualToken = $factory->createCaptureToken($gatewayName, $model, $afterPath, $afterParameters);
     $this->assertSame($captureToken, $actualToken);
 }