TransportExceptionEventTest.php 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. require_once 'Swift/Tests/SwiftUnitTestCase.php';
  3. require_once 'Swift/Events/TransportExceptionEvent.php';
  4. require_once 'Swift/Transport.php';
  5. require_once 'Swift/TransportException.php';
  6. class Swift_Events_TransportExceptionEventTest extends Swift_Tests_SwiftUnitTestCase
  7. {
  8. public function testExceptionCanBeFetchViaGetter()
  9. {
  10. $ex = $this->_createException();
  11. $transport = $this->_createTransport();
  12. $evt = $this->_createEvent($transport, $ex);
  13. $ref = $evt->getException();
  14. $this->assertReference($ex, $ref,
  15. '%s: Exception should be available via getException()'
  16. );
  17. }
  18. public function testSourceIsTransport()
  19. {
  20. $ex = $this->_createException();
  21. $transport = $this->_createTransport();
  22. $evt = $this->_createEvent($transport, $ex);
  23. $ref = $evt->getSource();
  24. $this->assertReference($transport, $ref,
  25. '%s: Transport should be available via getSource()'
  26. );
  27. }
  28. // -- Creation Methods
  29. private function _createEvent(Swift_Transport $transport,
  30. Swift_TransportException $ex)
  31. {
  32. return new Swift_Events_TransportExceptionEvent($transport, $ex);
  33. }
  34. private function _createTransport()
  35. {
  36. return $this->_stub('Swift_Transport');
  37. }
  38. private function _createException()
  39. {
  40. return new Swift_TransportException('');
  41. }
  42. }