/** * @test */ public function getByNotificationShouldDoAGetRequestAddingCredentialsData() { $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><data />'); $this->client->expects($this->once())->method('get')->with('https://ws.test.com/v2/transactions/notifications/1?email=a%40a.com&token=t')->willReturn($xml); $this->decoder->expects($this->once())->method('decode')->with($xml)->willReturn($this->transaction); $service = new Locator($this->credentials, $this->client, $this->decoder); $this->assertSame($this->transaction, $service->getByNotification(1)); }
/** * @test */ public function checkoutShouldDoAPostRequestReturningTheRedirection() { $checkout = $this->getMock('PHPSC\\PagSeguro\\Requests\\Checkout\\Checkout', [], [], '', false); $wsUri = 'https://ws.test.com/v2/checkout?email=test%40test.com&token=test'; $request = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><checkout />'); $response = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?>' . '<checkout><code>123</code><date>2010-12-02T10:11:28.000-02:00</date></checkout>'); $this->serializer->expects($this->once())->method('serialize')->with($checkout)->willReturn($request); $this->client->expects($this->once())->method('post')->with($wsUri, $request)->willReturn($response); $service = new CheckoutService($this->credentials, $this->client, $this->serializer); $redirection = $service->checkout($checkout); $redirectUri = 'https://test.com/v2/checkout/payment.html'; $this->assertInstanceOf('PHPSC\\PagSeguro\\Requests\\Redirection', $redirection); $this->assertAttributeEquals($redirectUri, 'uri', $redirection); $this->assertAttributeEquals('123', 'code', $redirection); $this->assertAttributeEquals(new DateTime('2010-12-02T10:11:28.000-02:00'), 'date', $redirection); }