ResponseEventTest.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. require_once 'Swift/Tests/SwiftUnitTestCase.php';
  3. require_once 'Swift/Events/ResponseEvent.php';
  4. require_once 'Swift/Transport.php';
  5. class Swift_Events_ResponseEventTest extends Swift_Tests_SwiftUnitTestCase
  6. {
  7. public function testResponseCanBeFetchViaGetter()
  8. {
  9. $evt = $this->_createEvent($this->_createTransport(), "250 Ok\r\n", true);
  10. $this->assertEqual("250 Ok\r\n", $evt->getResponse(),
  11. '%s: Response should be available via getResponse()'
  12. );
  13. }
  14. public function testResultCanBeFetchedViaGetter()
  15. {
  16. $evt = $this->_createEvent($this->_createTransport(), "250 Ok\r\n", false);
  17. $this->assertFalse($evt->isValid(),
  18. '%s: Result should be checkable via isValid()'
  19. );
  20. }
  21. public function testSourceIsBuffer()
  22. {
  23. $transport = $this->_createTransport();
  24. $evt = $this->_createEvent($transport, "250 Ok\r\n", true);
  25. $ref = $evt->getSource();
  26. $this->assertReference($transport, $ref);
  27. }
  28. // -- Creation Methods
  29. private function _createEvent(Swift_Transport $source, $response, $result)
  30. {
  31. return new Swift_Events_ResponseEvent($source, $response, $result);
  32. }
  33. private function _createTransport()
  34. {
  35. return $this->_stub('Swift_Transport');
  36. }
  37. }