CommandEventTest.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. require_once 'Swift/Tests/SwiftUnitTestCase.php';
  3. require_once 'Swift/Events/CommandEvent.php';
  4. require_once 'Swift/Transport.php';
  5. class Swift_Events_CommandEventTest extends Swift_Tests_SwiftUnitTestCase
  6. {
  7. public function testCommandCanBeFetchedByGetter()
  8. {
  9. $evt = $this->_createEvent($this->_createTransport(), "FOO\r\n");
  10. $this->assertEqual("FOO\r\n", $evt->getCommand());
  11. }
  12. public function testSuccessCodesCanBeFetchedViaGetter()
  13. {
  14. $evt = $this->_createEvent($this->_createTransport(), "FOO\r\n", array(250));
  15. $this->assertEqual(array(250), $evt->getSuccessCodes());
  16. }
  17. public function testSourceIsBuffer()
  18. {
  19. $transport = $this->_createTransport();
  20. $evt = $this->_createEvent($transport, "FOO\r\n");
  21. $ref = $evt->getSource();
  22. $this->assertReference($transport, $ref);
  23. }
  24. // -- Creation Methods
  25. private function _createEvent(Swift_Transport $source, $command,
  26. $successCodes = array())
  27. {
  28. return new Swift_Events_CommandEvent($source, $command, $successCodes);
  29. }
  30. private function _createTransport()
  31. {
  32. return $this->_stub('Swift_Transport');
  33. }
  34. }