diff --git a/src/Ratchet/Component/WAMP/Command/Action/CallError.php b/src/Ratchet/Component/WAMP/Command/Action/CallError.php index 373e1fa..4aafbee 100644 --- a/src/Ratchet/Component/WAMP/Command/Action/CallError.php +++ b/src/Ratchet/Component/WAMP/Command/Action/CallError.php @@ -43,6 +43,7 @@ class CallError extends SendMessage { if (null !== $details) { $data[] = $details; + $this->_details = $details; } return $this->setMessage(json_encode($data)); diff --git a/tests/Ratchet/Tests/Component/WAMP/Command/Action/CallErrorTest.php b/tests/Ratchet/Tests/Component/WAMP/Command/Action/CallErrorTest.php new file mode 100644 index 0000000..5d93349 --- /dev/null +++ b/tests/Ratchet/Tests/Component/WAMP/Command/Action/CallErrorTest.php @@ -0,0 +1,72 @@ +setError($callId, $uri); + $resultString = $error->getMessage(); + + $this->assertEquals(array(4, $callId, $uri, ''), json_decode($resultString, true)); + } + + public function testDetailedCallError() { + $error = new CallError(new Connection); + + $callId = uniqid(); + $uri = 'http://example.com/end/point'; + $desc = 'beep boop beep'; + $detail = 'Error: Too much awesome'; + + $error->setError($callId, $uri, $desc, $detail); + $resultString = $error->getMessage(); + + $this->assertEquals(array(4, $callId, $uri, $desc, $detail), json_decode($resultString, true)); + } + + public function testGetId() { + $id = uniqid(); + + $error = new CallError(new Connection); + $error->setError($id, 'http://example.com'); + + $this->assertEquals($id, $error->getId()); + } + + public function testGetUri() { + $uri = 'http://example.com/end/point'; + + $error = new CallError(new Connection); + $error->setError(uniqid(), $uri); + + $this->assertEquals($uri, $error->getUri()); + } + + public function testGetDescription() { + $desc = uniqid(); + + $error = new CallError(new Connection); + $error->setError(uniqid(), 'curie', $desc); + + $this->assertEquals($desc, $error->getDescription()); + } + + public function testGetDetails() { + $detail = uniqid(); + + $error = new CallError(new Connection); + $this->assertNull($error->getDetails()); + $error->setError(uniqid(), 'http://socketo.me', 'desc', $detail); + + $this->assertEquals($detail, $error->getDetails()); + } +} \ No newline at end of file diff --git a/tests/Ratchet/Tests/Component/WAMP/Command/Action/CallResultTest.php b/tests/Ratchet/Tests/Component/WAMP/Command/Action/CallResultTest.php new file mode 100644 index 0000000..a931d4b --- /dev/null +++ b/tests/Ratchet/Tests/Component/WAMP/Command/Action/CallResultTest.php @@ -0,0 +1,46 @@ + 'world', 'herp' => 'derp'); + + $result->setResult($callId, $data); + $resultString = $result->getMessage(); + + $this->assertEquals(array(3, $callId, $data), json_decode($resultString, true)); + } + + public function testGetId() { + $id = uniqid(); + + $result = new CallResult(new Connection); + $result->setResult($id, array()); + + $this->assertEquals($id, $result->getId()); + } + + public function testGetData() { + $data = array( + 'hello' => 'world' + , 'recursive' => array( + 'the' => 'quick' + , 'brown' => 'fox' + ) + , 'jumps' + ); + + $result = new CallResult(new Connection); + $result->setResult(uniqid(), $data); + + $this->assertEquals($data, $result->getData()); + } +} \ No newline at end of file diff --git a/tests/Ratchet/Tests/Component/WAMP/Command/Action/EventTest.php b/tests/Ratchet/Tests/Component/WAMP/Command/Action/EventTest.php new file mode 100644 index 0000000..e69de29 diff --git a/tests/Ratchet/Tests/Component/WAMP/WAMPServerComponentTest.php b/tests/Ratchet/Tests/Component/WAMP/WAMPServerComponentTest.php index c784e6c..7e44885 100644 --- a/tests/Ratchet/Tests/Component/WAMP/WAMPServerComponentTest.php +++ b/tests/Ratchet/Tests/Component/WAMP/WAMPServerComponentTest.php @@ -124,53 +124,6 @@ class WAMPServerComponentTest extends \PHPUnit_Framework_TestCase { } - /** - * @covers Ratchet\Component\WAMP\Command\Action\CallResult - */ - public function testCallResponse() { - $result = new CallResult($this->newConn()); - - $callId = uniqid(); - $data = array('hello' => 'world', 'herp' => 'derp'); - - $result->setResult($callId, $data); - $resultString = $result->getMessage(); - - $this->assertEquals(array(3, $callId, $data), json_decode($resultString, true)); - } - - /** - * @covers Ratchet\Component\WAMP\Command\Action\CallError - */ - public function testCallError() { - $error = new CallError($this->newConn()); - - $callId = uniqid(); - $uri = 'http://example.com/end/point'; - - $error->setError($callId, $uri); - $resultString = $error->getMessage(); - - $this->assertEquals(array(4, $callId, $uri, ''), json_decode($resultString, true)); - } - - /** - * @covers Ratchet\Component\WAMP\Command\Action\CallError - */ - public function testDetailedCallError() { - $error = new CallError($this->newConn()); - - $callId = uniqid(); - $uri = 'http://example.com/end/point'; - $desc = 'beep boop beep'; - $detail = 'Error: Too much awesome'; - - $error->setError($callId, $uri, $desc, $detail); - $resultString = $error->getMessage(); - - $this->assertEquals(array(4, $callId, $uri, $desc, $detail), json_decode($resultString, true)); - } - public function eventProvider() { return array( array('http://example.com', array('one', 'two'))