EchoServerTest.php 802 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Ratchet\Server;
  3. use Ratchet\Server\EchoServer;
  4. class EchoServerTest extends \PHPUnit_Framework_TestCase {
  5. protected $_conn;
  6. protected $_comp;
  7. public function setUp() {
  8. $this->_conn = $this->getMock('\Ratchet\ConnectionInterface');
  9. $this->_comp = new EchoServer;
  10. }
  11. public function testMessageEchod() {
  12. $message = 'Tillsonburg, my back still aches when I hear that word.';
  13. $this->_conn->expects($this->once())->method('send')->with($message);
  14. $this->_comp->onMessage($this->_conn, $message);
  15. }
  16. public function testErrorClosesConnection() {
  17. ob_start();
  18. $this->_conn->expects($this->once())->method('close');
  19. $this->_comp->onError($this->_conn, new \Exception);
  20. ob_end_clean();
  21. }
  22. }