Unit testing coverage

This commit is contained in:
Chris Boden 2011-09-05 17:34:51 -04:00
parent f17f59856e
commit 45fb69d68b
3 changed files with 24 additions and 0 deletions

View File

@ -35,6 +35,10 @@ class Socket {
/**
* @internal
* @param int Specifies the protocol family to be used by the socket.
* @param int The type of communication to be used by the socket
* @param int Sets the specific protocol within the specified domain to be used when communicating on the returned socket
* @return Array
*/
protected static function getConfig($domain = null, $type = null, $protocol = null) {
foreach (static::$_defaults as $key => $val) {
@ -48,11 +52,17 @@ class Socket {
/**
* @internal
* @param string
* @param Array
* @return mixed
* @throws \BadMethodCallException
*/
public function __call($method, $arguments) {
if (function_exists('socket_' . $method)) {
array_unshift($arguments, $this->_socket);
return call_user_func_array('socket_' . $method, $arguments);
}
throw new \BadMethodCallException("{$method} is not a valid socket function");
}
}

View File

@ -23,4 +23,8 @@ class ServerTest extends \PHPUnit_Framework_TestCase {
$constraint = $this->isInstanceOf('\\Ratchet\\Protocol\ProtocolInterface');
$this->assertThat($this->_server, $constraint);
}
public function testGetConfigReturnsArray() {
$this->assertInternalType('array', $this->_server->getDefaultConfig());
}
}

View File

@ -38,4 +38,14 @@ class SocketTest extends \PHPUnit_Framework_TestCase {
$this->setExpectedException('\\Ratchet\\Exception');
$socket = new RealSocket('invalid', 'param', 'derp');
}
public function testConstructAndCallByOpenAndClose() {
$socket = new RealSocket();
$socket->close();
}
public function testInvalidSocketCall() {
$this->setExpectedException('\\BadMethodCallException');
$this->_socket->fake_method();
}
}