Example #1
0
 /**
  * @param Message $message
  *
  * @return bool
  */
 public function send(Message $message)
 {
     $headers = array();
     $post_data = array('auth' => $this->auth_token, 'originator' => $message->getFrom(), 'destination' => $message->getTo(), 'message' => $message->getMessage());
     $http_response = \Requests::post(self::API_ENDPOINT, $headers, $post_data);
     $gradwell_response = new Response($http_response->body);
     return $http_response->success && $gradwell_response->isSuccessful();
 }
Example #2
0
 public function testIsSuccessfulReturnsTransactionResult()
 {
     $job = $this->getJobMock(['getTransaction']);
     $transaction = $this->getMock('\\Wirecard\\Element\\Transaction', ['isSuccessful']);
     $transaction->expects($this->once())->method('isSuccessful')->will($this->returnValue(true));
     $job->expects($this->once())->method('getTransaction')->will($this->returnValue($transaction));
     $response = new Response($job);
     $this->assertTrue($response->isSuccessful());
 }
 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());
 }
 /**
  * Checks the success state of a response
  *
  * @param Response $response Response object
  * @param bool $success to define whether the response is expected to be successful
  * @param string $type
  *
  * @return void
  */
 public function isSuccessful($response, $success = true, $type = 'text/html')
 {
     try {
         $crawler = new Crawler();
         $crawler->addContent($response->getContent(), $type);
         if (!count($crawler->filter('title'))) {
             $title = '[' . $response->getStatusCode() . '] - ' . $response->getContent();
         } else {
             $title = $crawler->filter('title')->text();
         }
     } catch (\Exception $e) {
         $title = $e->getMessage();
     }
     if ($success) {
         $this->assertTrue($response->isSuccessful(), 'The Response was not successful: ' . $title);
     } else {
         $this->assertFalse($response->isSuccessful(), 'The Response was successful: ' . $title);
     }
 }