mxmbsocket/tests/Ratchet/Tests/SocketTest.php
Chris Boden 75afa73826 Unit tests
Socket interface update
Server testing
Connection setting
2011-11-24 21:53:04 -05:00

69 lines
2.1 KiB
PHP

<?php
namespace Ratchet\Tests;
use Ratchet\Tests\Mock\FakeSocket as Socket;
use Ratchet\Socket as RealSocket;
use Ratchet\Tests\Mock\Application as TestApp;
/**
* @covers Ratchet\Socket
*/
class SocketTest extends \PHPUnit_Framework_TestCase {
protected $_socket;
protected static function getMethod($name) {
$class = new \ReflectionClass('\\Ratchet\\Tests\\Mock\\FakeSocket');
$method = $class->getMethod($name);
$method->setAccessible(true);
return $method;
}
public function setUp() {
$this->_socket = new Socket();
}
/* (1): I may or may not re-enable this test (need to add code back to FakeSocket), not sure if I'll keep this feature at all
public function testGetDefaultConfigForConstruct() {
$ref_conf = static::getMethod('getConfig');
$config = $ref_conf->invokeArgs($this->_socket, array());
$this->assertEquals(array_values(Socket::$_defaults), $config);
}
/**/
public function testInvalidConstructorArguments() {
$this->setExpectedException('\\Ratchet\\Exception');
$socket = new RealSocket('invalid', 'param', 'derp');
}
public function testConstructAndCallByOpenAndClose() {
$socket = new RealSocket();
$socket->close();
}
public function asArrayProvider() {
return array(
array(array('hello' => 'world'), array('hello' => 'world'))
, array(null, null)
, array(array('hello' => 'world'), new \ArrayObject(array('hello' => 'world')))
);
}
/**
* (1)
* @dataProvider asArrayProvider
* /
public function testMethodMungforselectReturnsExpectedValues($output, $input) {
$method = static::getMethod('mungForSelect');
$return = $method->invokeArgs($this->_socket, array($input));
$this->assertEquals($return, $output);
}
public function NOPEtestMethodMungforselectRejectsNonTraversable() {
$this->setExpectedException('\\InvalidArgumentException');
$method = static::getMethod('mungForSelect');
$method->invokeArgs($this->_socket, array('I am upset with PHP ATM'));
}
*/
}