/** * @test */ public function shouldNotAddNotifyUrlIfTokenFactoryNotSet() { $details = new \ArrayObject(array()); $captureToken = new Token(); $captureToken->setGatewayName('theGatewayName'); $captureToken->setDetails($details); $action = new AuthorizeAction(); $action->setGateway($this->createGatewayMock()); $request = new Authorize($captureToken); $request->setModel($details); $action->execute($request); $this->assertArrayNotHasKey('PAYMENTREQUEST_0_NOTIFYURL', $details); }
/** * @test */ public function shouldGeneratePushUriIfNotSet() { $config = new Config(); $config->termsUri = 'theTermsUri'; $token = new Token(); $token->setTargetUrl('theTargetUrl'); $token->setGatewayName('theGatewayName'); $token->setDetails($identity = new Identity('id', 'class')); $notifyToken = new Token(); $notifyToken->setTargetUrl('theNotifyUrl'); $tokenFactory = $this->getMock(GenericTokenFactoryInterface::class); $tokenFactory->expects($this->once())->method('createNotifyToken')->with('theGatewayName', $this->identicalTo($identity))->will($this->returnValue($notifyToken)); $action = new AuthorizeAction('aTemplate'); $action->setGateway($this->createGatewayMock()); $action->setApi($config); $action->setGenericTokenFactory($tokenFactory); $authorize = new Authorize($token); $authorize->setModel(['location' => 'aLocation', 'merchant' => ['confirmation_uri' => 'theConfirmationUri', 'checkout_uri' => 'theCheckoutUri', 'terms_uri' => 'theTermsUri']]); $action->execute($authorize); }
/** * @test */ public function shouldExecuteConvertRequestWithTokenIfOnePresent() { $payment = new Payment(); $token = $this->createTokenMock(); $testCase = $this; $gatewayMock = $this->createGatewayMock(); $gatewayMock->expects($this->at(0))->method('execute')->with($this->isInstanceOf(GetHumanStatus::class))->will($this->returnCallback(function (GetHumanStatus $request) { $request->markNew(); })); $gatewayMock->expects($this->at(1))->method('execute')->with($this->isInstanceOf(Convert::class))->will($this->returnCallback(function (Convert $request) use($testCase, $payment, $token) { $testCase->assertSame($payment, $request->getSource()); $testCase->assertSame($token, $request->getToken()); $request->setResult(array()); })); $action = new AuthorizePaymentAction(); $action->setGateway($gatewayMock); $authorize = new Authorize($token); $authorize->setModel($payment); $action->execute($authorize); $this->assertSame($payment, $authorize->getFirstModel()); $this->assertInstanceOf('ArrayAccess', $authorize->getModel()); $this->assertSame($token, $authorize->getToken()); }