123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
-
- require_once 'Swift/Tests/SwiftUnitTestCase.php';
- require_once 'Swift/Events/SendEvent.php';
- require_once 'Swift/Mime/Message.php';
- require_once 'Swift/Transport.php';
-
- class Swift_Events_SendEventTest extends Swift_Tests_SwiftUnitTestCase
- {
-
- public function testMessageCanBeFetchedViaGetter()
- {
- $message = $this->_createMessage();
- $transport = $this->_createTransport();
-
- $evt = $this->_createEvent($transport, $message);
-
- $ref = $evt->getMessage();
- $this->assertReference($message, $ref,
- '%s: Message should be returned from getMessage()'
- );
- }
-
- public function testTransportCanBeFetchViaGetter()
- {
- $message = $this->_createMessage();
- $transport = $this->_createTransport();
-
- $evt = $this->_createEvent($transport, $message);
-
- $ref = $evt->getTransport();
- $this->assertReference($transport, $ref,
- '%s: Transport should be returned from getTransport()'
- );
- }
-
- public function testTransportCanBeFetchViaGetSource()
- {
- $message = $this->_createMessage();
- $transport = $this->_createTransport();
-
- $evt = $this->_createEvent($transport, $message);
-
- $ref = $evt->getSource();
- $this->assertReference($transport, $ref,
- '%s: Transport should be returned from getSource()'
- );
- }
-
- public function testResultCanBeSetAndGet()
- {
- $message = $this->_createMessage();
- $transport = $this->_createTransport();
-
- $evt = $this->_createEvent($transport, $message);
-
- $evt->setResult(
- Swift_Events_SendEvent::RESULT_SUCCESS | Swift_Events_SendEvent::RESULT_TENTATIVE
- );
-
- $this->assertTrue($evt->getResult() & Swift_Events_SendEvent::RESULT_SUCCESS);
- $this->assertTrue($evt->getResult() & Swift_Events_SendEvent::RESULT_TENTATIVE);
- }
-
- public function testFailedRecipientsCanBeSetAndGet()
- {
- $message = $this->_createMessage();
- $transport = $this->_createTransport();
-
- $evt = $this->_createEvent($transport, $message);
-
- $evt->setFailedRecipients(array('foo@bar', 'zip@button'));
-
- $this->assertEqual(array('foo@bar', 'zip@button'), $evt->getFailedRecipients(),
- '%s: FailedRecipients should be returned from getter'
- );
- }
-
- public function testFailedRecipientsGetsPickedUpCorrectly() {
- $message = $this->_createMessage();
- $transport = $this->_createTransport();
-
- $evt = $this->_createEvent($transport, $message);
- $this->assertEqual(array(), $evt->getFailedRecipients());
- }
-
- // -- Creation Methods
-
- private function _createEvent(Swift_Transport $source,
- Swift_Mime_Message $message)
- {
- return new Swift_Events_SendEvent($source, $message);
- }
-
- private function _createTransport()
- {
- return $this->_stub('Swift_Transport');
- }
-
- private function _createMessage()
- {
- return $this->_stub('Swift_Mime_Message');
- }
-
- }
|