IoConnectionTest.php 867 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace Ratchet\Application\Server;
  3. use Ratchet\Server\IoConnection;
  4. /**
  5. * @covers Ratchet\Server\IoConnection
  6. */
  7. class IoConnectionTest extends \PHPUnit_Framework_TestCase {
  8. protected $sock;
  9. protected $conn;
  10. public function setUp() {
  11. $this->sock = $this->getMock('\\React\\Socket\\ConnectionInterface');
  12. $this->conn = new IoConnection($this->sock);
  13. }
  14. public function testCloseBubbles() {
  15. $this->sock->expects($this->once())->method('end');
  16. $this->conn->close();
  17. }
  18. public function testSendBubbles() {
  19. $msg = '6 hour rides are productive';
  20. $this->sock->expects($this->once())->method('write')->with($msg);
  21. $this->conn->send($msg);
  22. }
  23. public function testSendReturnsSelf() {
  24. $this->assertSame($this->conn, $this->conn->send('fluent interface'));
  25. }
  26. }