6 use Omnipay\Tests\TestCase;
12 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponse')->makePartial();
17 $data = array(
'foo' =>
'bar');
18 $request = $this->getMockRequest();
19 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponse', array($request, $data))->makePartial();
21 $this->assertSame($request, $this->response->getRequest());
22 $this->assertSame($data, $this->response->getData());
27 $this->assertFalse($this->response->isPending());
28 $this->assertFalse($this->response->isRedirect());
29 $this->assertFalse($this->response->isTransparentRedirect());
30 $this->assertFalse($this->response->isCancelled());
31 $this->assertNull($this->response->getData());
32 $this->assertNull($this->response->getTransactionReference());
33 $this->assertNull($this->response->getMessage());
34 $this->assertNull($this->response->getCode());
43 $this->response->getRedirectResponse();
52 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
53 $this->response->shouldReceive(
'isRedirect')->once()->andReturn(
false);
55 $this->response->getRedirectResponse();
60 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
61 $this->response->shouldReceive(
'getRedirectMethod')->andReturn(
'GET');
63 $httpResponse = $this->response->getRedirectResponse();
64 $this->assertSame(302, $httpResponse->getStatusCode());
65 $this->assertSame(
'https://example.com/redirect?a=1&b=2', $httpResponse->getTargetUrl());
70 $data = array(
'foo' =>
'bar',
'key&"' =>
'<value>');
71 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
72 $this->response->shouldReceive(
'getRedirectMethod')->andReturn(
'POST');
73 $this->response->shouldReceive(
'getRedirectData')->andReturn($data);
75 $httpResponse = $this->response->getRedirectResponse();
76 $this->assertSame(200, $httpResponse->getStatusCode());
77 $this->assertContains(
'<form action="https://example.com/redirect?a=1&b=2" method="post">', $httpResponse->getContent());
78 $this->assertContains(
'<input type="hidden" name="foo" value="bar" />', $httpResponse->getContent());
79 $this->assertContains(
'<input type="hidden" name="key&"" value="<value>" />', $httpResponse->getContent());
88 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
89 $this->response->shouldReceive(
'getRedirectMethod')->andReturn(
'DELETE');
91 $this->response->getRedirectResponse();
96 $this->response = m::mock(
'\Omnipay\Common\Message\AbstractResponseTest_MockRedirectResponse')->makePartial();
97 $this->assertNull($this->response->getTransactionId());
120 return 'https://example.com/redirect?a=1&b=2';