Example #1
0
 /**
  * Terminates application.
  *
  * Renders content or excute redirecting
  *
  * @param Response $response
  */
 public function terminate(Response $response)
 {
     if ($response->getRedirectUrl() === null) {
         header("Content-Type: {$response->getContentType()}; charset=utf-8");
         http_response_code($response->getStatusCode());
         $response->display();
     } else {
         header("Location: {$response->getRedirectUrl()}");
     }
     exit;
 }
 public function testConstruct()
 {
     $data = array('sid' => '12345', 'total' => '10.00');
     $mock = $this->getMockBuilder('\\Omnipay\\TwoCheckout\\Message\\Request')->disableOriginalConstructor()->getMock();
     $mock->expects($this->once())->method('getAction')->will($this->returnValue('foo'));
     $response = new Response($mock, $data);
     $this->assertFalse($response->isSuccessful());
     $this->assertTrue($response->isRedirect());
     $this->assertNull($response->getTransactionReference());
     $this->assertNull($response->getMessage());
     $this->assertSame('foo', $response->getRedirectUrl());
     $this->assertSame('POST', $response->getRedirectMethod());
     $this->assertSame('POST', $response->getRedirectMethod());
     $this->assertSame($data, $response->getRedirectData());
 }