Fixed Socket bugs from Unit Testing

This commit is contained in:
Chris Boden 2011-09-06 14:30:14 -04:00
parent 203b68b9cb
commit f2423f09e5
4 changed files with 6 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
phpunit.xml
coverage
docs
sandbox

View File

@ -41,9 +41,7 @@ class Socket {
*/
public static function createFromConfig(ProtocolInterface $protocol) {
$config = $protocol::getDefaultConfig();
// todo - this is wrong when class is extended, I don't have internet, can't look up the fn - unit test fails
$class = __CLASS__;
$class = get_called_class();
$socket = new $class($config['domain'] ?: null, $config['type'] ?: null, $config['protocol'] ?: null);
@ -54,6 +52,8 @@ class Socket {
}
}
}
return $socket;
}
/**

View File

@ -30,7 +30,7 @@ class Socket extends RealSocket {
}
public function set_option($level, $optname, $optval) {
if (!is_array($this->_options[$level])) {
if (!isset($this->_options[$level])) {
$this->_options[$level] = Array();
}

View File

@ -54,8 +54,7 @@ class SocketTest extends \PHPUnit_Framework_TestCase {
$protocol = new Protocol();
$socket = Socket::createFromConfig($protocol);
$constraint = $this->isInstanceOf('\\Ratchet\\Socket');
$this->assertThat($socket, $constraint);
$this->assertInstanceOf('\\Ratchet\\Socket', $socket);
}
public function testCreationFromConfigOutputMatchesInput() {