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
|
phpunit.xml
|
||||||
coverage
|
coverage
|
||||||
|
docs
|
||||||
sandbox
|
sandbox
|
@ -41,9 +41,7 @@ class Socket {
|
|||||||
*/
|
*/
|
||||||
public static function createFromConfig(ProtocolInterface $protocol) {
|
public static function createFromConfig(ProtocolInterface $protocol) {
|
||||||
$config = $protocol::getDefaultConfig();
|
$config = $protocol::getDefaultConfig();
|
||||||
|
$class = get_called_class();
|
||||||
// todo - this is wrong when class is extended, I don't have internet, can't look up the fn - unit test fails
|
|
||||||
$class = __CLASS__;
|
|
||||||
|
|
||||||
$socket = new $class($config['domain'] ?: null, $config['type'] ?: null, $config['protocol'] ?: null);
|
$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) {
|
public function set_option($level, $optname, $optval) {
|
||||||
if (!is_array($this->_options[$level])) {
|
if (!isset($this->_options[$level])) {
|
||||||
$this->_options[$level] = Array();
|
$this->_options[$level] = Array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,8 +54,7 @@ class SocketTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$protocol = new Protocol();
|
$protocol = new Protocol();
|
||||||
$socket = Socket::createFromConfig($protocol);
|
$socket = Socket::createFromConfig($protocol);
|
||||||
|
|
||||||
$constraint = $this->isInstanceOf('\\Ratchet\\Socket');
|
$this->assertInstanceOf('\\Ratchet\\Socket', $socket);
|
||||||
$this->assertThat($socket, $constraint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreationFromConfigOutputMatchesInput() {
|
public function testCreationFromConfigOutputMatchesInput() {
|
||||||
|
Loading…
Reference in New Issue
Block a user