File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55use Clue \React \Ami \Protocol \Event ;
66use Clue \React \Ami \Protocol \Action ;
77use Evenement \EventEmitter ;
8- use React \Stream \Stream ;
8+ use React \Stream \StreamInterface ;
99use Clue \React \Ami \Protocol \Parser ;
1010use React \Promise \Deferred ;
1111use Exception ;
@@ -19,7 +19,7 @@ class Client extends EventEmitter
1919 private $ pending = array ();
2020 private $ ending = false ;
2121
22- public function __construct (Stream $ stream , Parser $ parser = null )
22+ public function __construct (StreamInterface $ stream , Parser $ parser = null )
2323 {
2424 if ($ parser === null ) {
2525 $ parser = new Parser ();
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use React \Stream \Stream ;
4+ use Clue \React \Ami \Protocol \Parser ;
5+ use Clue \React \Ami \Client ;
6+ use React \Stream \ThroughStream ;
7+
8+ class ClientTest extends TestCase
9+ {
10+ public function testClosingStreamClosesClient ()
11+ {
12+ $ stream = new ThroughStream ();
13+
14+ $ client = new Client ($ stream );
15+
16+ $ client ->on ('close ' , $ this ->expectCallableOnce ());
17+
18+ $ stream ->close ();
19+ //$stream->emit('close', array($this));
20+ }
21+ }
Original file line number Diff line number Diff line change 44
55class TestCase extends PHPUnit_Framework_TestCase
66{
7+ protected function expectCallableOnce ()
8+ {
9+ $ mock = $ this ->createCallableMock ();
710
11+ if (func_num_args () > 0 ) {
12+ $ mock
13+ ->expects ($ this ->once ())
14+ ->method ('__invoke ' )
15+ ->with ($ this ->equalTo (func_get_arg (0 )));
16+ } else {
17+ $ mock
18+ ->expects ($ this ->once ())
19+ ->method ('__invoke ' );
20+ }
21+
22+ return $ mock ;
23+ }
24+
25+ /**
26+ * @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react)
27+ */
28+ protected function createCallableMock ()
29+ {
30+ return $ this ->getMock ('CallableStub ' );
31+ }
32+ }
33+
34+ class CallableStub
35+ {
36+ public function __invoke ()
37+ {
38+ }
839}
You can’t perform that action at this time.
0 commit comments