@@ -81,6 +81,38 @@ public function testParsingCommandResponse()
8181 $ this ->assertEquals ("Testing: yes \nAnother Line \n--END COMMAND-- " , $ first ->getFieldValue ('_ ' ));
8282 }
8383
84+ public function testParsingCommandResponseEmpty ()
85+ {
86+ $ parser = new Parser ();
87+ $ this ->assertEquals (array (), $ parser ->push ("Asterisk Call Manager/1.3 \r\n" ));
88+
89+ $ ret = $ parser ->push ("Response: Follows \r\n--END COMMAND-- \r\n\r\n" );
90+ $ this ->assertCount (1 , $ ret );
91+
92+ $ first = reset ($ ret );
93+ /* @var $first Clue\React\Ami\Protocol\Response */
94+
95+ $ this ->assertInstanceOf ('Clue\React\Ami\Protocol\Response ' , $ first );
96+ $ this ->assertEquals ('Follows ' , $ first ->getFieldValue ('Response ' ));
97+ $ this ->assertEquals ("--END COMMAND-- " , $ first ->getFieldValue ('_ ' ));
98+ }
99+
100+ public function testParsingResponseIsNotCommandResponse ()
101+ {
102+ $ parser = new Parser ();
103+ $ this ->assertEquals (array (), $ parser ->push ("Asterisk Call Manager/1.3 \r\n" ));
104+
105+ $ ret = $ parser ->push ("Response: Success \r\nMessage: Some message--END COMMAND-- \r\n\r\n" );
106+ $ this ->assertCount (1 , $ ret );
107+
108+ $ first = reset ($ ret );
109+ /* @var $first Clue\React\Ami\Protocol\Response */
110+
111+ $ this ->assertInstanceOf ('Clue\React\Ami\Protocol\Response ' , $ first );
112+ $ this ->assertEquals ('Success ' , $ first ->getFieldValue ('Response ' ));
113+ $ this ->assertEquals ('Some message--END COMMAND-- ' , $ first ->getFieldValue ('Message ' ));
114+ }
115+
84116 /**
85117 * @expectedException UnexpectedValueException
86118 */
0 commit comments