/** * @test */ public function shouldUseSandboxApiEndpointIfSandboxTrue() { $testCase = $this; $clientMock = $this->createClientMock(); $clientMock->expects($this->once())->method('send')->will($this->returnCallback(function (FormRequest $request, Response $response) use($testCase) { $testCase->assertEquals('https://api-3t.sandbox.paypal.com/nvp', $request->getUrl()); $response->setHeaders(array('HTTP/1.1 200 OK')); $response->setContent('ACK=Success'); $response->setContent(http_build_query($request->getFields())); })); $api = new Api(array('username' => 'a_username', 'password' => 'a_password', 'signature' => 'a_signature', 'sandbox' => true, 'return_url' => 'optionReturnUrl', 'cancel_url' => 'optionCancelUrl'), $clientMock); $api->setExpressCheckout(array()); }
/** * @test */ public function shouldUseSandboxApiEndpointIfSandboxTrue() { $testCase = $this; $clientMock = $this->createHttpClientMock(); $clientMock->expects($this->once())->method('send')->will($this->returnCallback(function (RequestInterface $request) use($testCase) { $testCase->assertEquals('https://api-3t.sandbox.paypal.com/nvp', $request->getUri()); return new Response(200, [], $request->getBody()); })); $api = new Api(array('username' => 'a_username', 'password' => 'a_password', 'signature' => 'a_signature', 'sandbox' => true, 'return_url' => 'optionReturnUrl', 'cancel_url' => 'optionCancelUrl'), $clientMock, $this->createHttpMessageFactory()); $api->setExpressCheckout(array()); }