Fixed Socket bugs from Unit Testing
This commit is contained in:
parent
203b68b9cb
commit
f2423f09e5
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
phpunit.xml
|
||||
coverage
|
||||
docs
|
||||
sandbox
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user