/**
  * @test
  */
 public function shouldAllowCreateCustomTokenWithoutAfterPath()
 {
     $gatewayName = 'theGatewayName';
     $model = new \stdClass();
     $targetPath = 'theTargetPath';
     $targetParameters = array('target' => 'val');
     $token = new Token();
     $tokenFactoryMock = $this->createTokenFactoryMock();
     $tokenFactoryMock->expects($this->once())->method('createToken')->with($gatewayName, $this->identicalTo($model), $targetPath, $targetParameters, null, array())->willReturn($token);
     $factory = new GenericTokenFactory($tokenFactoryMock, array());
     $actualToken = $factory->createToken($gatewayName, $model, $targetPath, $targetParameters);
     $this->assertSame($token, $actualToken);
 }
 /**
  * @test
  */
 public function shouldCreateCustomTokenWithoutAfterUrl()
 {
     $token = new Token();
     $tokenStorageMock = $this->createStorageMock();
     $tokenStorageMock->expects($this->once())->method('createModel')->will($this->returnValue($token));
     $tokenStorageMock->expects($this->once())->method('updateModel')->with($this->identicalTo($token));
     $model = new \stdClass();
     $identificator = new Identificator('anId', 'stdClass');
     $paymentName = 'thePaymentName';
     $modelStorage = $this->createStorageMock();
     $modelStorage->expects($this->once())->method('getIdentificator')->with($this->identicalTo($model))->will($this->returnValue($identificator));
     $storageRegistryMock = $this->createStorageRegistryMock();
     $storageRegistryMock->expects($this->once())->method('getStorage')->with($this->identicalTo($model))->will($this->returnValue($modelStorage));
     $factory = new GenericTokenFactory($tokenStorageMock, $storageRegistryMock, 'http://example.com', 'capture.php', 'notify.php');
     $actualToken = $factory->createToken($paymentName, $model, 'theTargetPath');
     $this->assertSame($token, $actualToken);
     $this->assertEquals($paymentName, $token->getPaymentName());
     $this->assertSame($identificator, $token->getDetails());
     $this->assertEquals('http://example.com/theTargetPath?payum_token=' . $token->getHash(), $token->getTargetUrl());
     $this->assertNull($token->getAfterUrl());
 }