Skip to content

Commit

Permalink
Add a test to make sure Response Event fires.
Browse files Browse the repository at this point in the history
  • Loading branch information
BradEstey authored and hkdobrev committed Jan 23, 2015
1 parent c0f2c3a commit 97b9c07
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/src/Swift/Transport/PostmarkTransportTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,47 @@ public function test_send_event_cancelled()
$this->assertSame(0, $result);
}

/**
* @covers Openbuildings\Postmark\Swift_Transport_PostmarkTransport::send
*/
public function testResponseEventFires()
{
$event_dispatcher = $this->getMock('Swift_Events_SimpleEventDispatcher');
$transport = new Swift_Transport_PostmarkTransport($event_dispatcher);
$event = new Swift_Events_ResponseEvent($transport, 1234, true);
$api = $this->getMock('Openbuildings\Postmark\Api', array(), array('POSTMARK_API_TEST'));
$transport->api($api);

$api->expects($this->at(0))
->method('send')
->will($this->returnValue(array('MessageID' => 1234)));

$event_dispatcher->expects($this->once())
->method('createResponseEvent')
->with($this->equalTo($transport), $this->equalTo('1234'), $this->equalTo(true))
->will($this->returnValue($event));

$event_dispatcher->expects($this->once())
->method('dispatchEvent')
->with($this->equalTo($event), $this->equalTo('responseReceived'));

$api->expects($this->at(1))
->method('send')
->will($this->returnValue(array()));

$message = Swift_Message::newInstance();
$message->setFrom('[email protected]');
$message->setTo('[email protected]');
$message->setSubject('Test Big');
$message->setBody('Text Body');

// Response Event should fire.
$transport->send($message);

// Response Event should not fire.
$transport->send($message);
}

/**
* @covers Openbuildings\Postmark\Swift_Transport_PostmarkTransport::__construct
* @covers Openbuildings\Postmark\Swift_Transport_PostmarkTransport::registerPlugin
Expand Down

0 comments on commit 97b9c07

Please sign in to comment.