Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
, "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0"
}
, "require-dev": {
"phpunit/phpunit": "~4.8",
"psr/http-message": "~1.0.1"
"phpunit/phpunit": "^7.5 || ^5.7 || ^4.8.36"
}
}
8 changes: 0 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
forceCoversAnnotation="true"
mapTestClassNameToCoveredClassName="true"
bootstrap="tests/bootstrap.php"
colors="true"
backupGlobals="false"
backupStaticAttributes="false"
syntaxCheck="false"
stopOnError="false"
>

Expand All @@ -16,12 +14,6 @@
</testsuite>
</testsuites>

<testsuites>
<testsuite name="integration">
<directory>./tests/integration/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>./src/</directory>
Expand Down
12 changes: 7 additions & 5 deletions tests/helpers/Ratchet/AbstractMessageComponentTestCase.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace Ratchet;

abstract class AbstractMessageComponentTestCase extends \PHPUnit_Framework_TestCase {
use PHPUnit\Framework\TestCase;

abstract class AbstractMessageComponentTestCase extends TestCase {
protected $_app;
protected $_serv;
protected $_conn;
Expand All @@ -11,10 +13,10 @@ abstract public function getDecoratorClassString();
abstract public function getComponentClassString();

public function setUp() {
$this->_app = $this->getMock($this->getComponentClassString());
$this->_app = $this->getMockBuilder($this->getComponentClassString())->getMock();
$decorator = $this->getDecoratorClassString();
$this->_serv = new $decorator($this->_app);
$this->_conn = $this->getMock('\Ratchet\ConnectionInterface');
$this->_conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock();

$this->doOpen($this->_conn);
}
Expand All @@ -24,12 +26,12 @@ protected function doOpen($conn) {
}

public function isExpectedConnection() {
return new \PHPUnit_Framework_Constraint_IsInstanceOf($this->getConnectionClassString());
return $this->isInstanceOf($this->getConnectionClassString());
}

public function testOpen() {
$this->_app->expects($this->once())->method('onOpen')->with($this->isExpectedConnection());
$this->doOpen($this->getMock('\Ratchet\ConnectionInterface'));
$this->doOpen($this->getMockBuilder('Ratchet\ConnectionInterface')->getMock());
}

public function testOnClose() {
Expand Down
27 changes: 20 additions & 7 deletions tests/unit/AbstractConnectionDecoratorTest.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
<?php
namespace Ratchet;
use PHPUnit\Framework\TestCase;
use Ratchet\Mock\ConnectionDecorator;

/**
* @covers Ratchet\AbstractConnectionDecorator
* @covers Ratchet\ConnectionInterface
*/
class AbstractConnectionDecoratorTest extends \PHPUnit_Framework_TestCase {
class AbstractConnectionDecoratorTest extends TestCase {
protected $mock;
protected $l1;
protected $l2;

public function setUp() {
$this->mock = $this->getMock('\Ratchet\ConnectionInterface');
$this->mock = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock();
$this->l1 = new ConnectionDecorator($this->mock);
$this->l2 = new ConnectionDecorator($this->l1);
}
Expand Down Expand Up @@ -84,7 +85,7 @@ public function testUnsetLevel2() {
}

public function testGetConnection() {
$class = new \ReflectionClass('\\Ratchet\\AbstractConnectionDecorator');
$class = new \ReflectionClass('Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);

Expand All @@ -94,7 +95,7 @@ public function testGetConnection() {
}

public function testGetConnectionLevel2() {
$class = new \ReflectionClass('\\Ratchet\\AbstractConnectionDecorator');
$class = new \ReflectionClass('Ratchet\\AbstractConnectionDecorator');
$method = $class->getMethod('getConnection');
$method->setAccessible(true);

Expand Down Expand Up @@ -135,7 +136,11 @@ public function testWarningGettingNothing() {
$this->markTestSkipped('Requires error_reporting to include E_NOTICE');
}

$this->setExpectedException('PHPUnit_Framework_Error');
if (method_exists($this, 'expectException')) {
$this->expectException(class_exists('PHPUnit\Framework\Error\Error') ? 'PHPUnit\Framework\Error\Error' : 'PHPUnit_Framework_Error');
} else {
$this->setExpectedException('PHPUnit_Framework_Error');
}
$var = $this->mock->nonExistant;
}

Expand All @@ -144,7 +149,11 @@ public function testWarningGettingNothingLevel1() {
$this->markTestSkipped('Requires error_reporting to include E_NOTICE');
}

$this->setExpectedException('PHPUnit_Framework_Error');
if (method_exists($this, 'expectException')) {
$this->expectException(class_exists('PHPUnit\Framework\Error\Error') ? 'PHPUnit\Framework\Error\Error' : 'PHPUnit_Framework_Error');
} else {
$this->setExpectedException('PHPUnit_Framework_Error');
}
$var = $this->l1->nonExistant;
}

Expand All @@ -153,7 +162,11 @@ public function testWarningGettingNothingLevel2() {
$this->markTestSkipped('Requires error_reporting to include E_NOTICE');
}

$this->setExpectedException('PHPUnit_Framework_Error');
if (method_exists($this, 'expectException')) {
$this->expectException(class_exists('PHPUnit\Framework\Error\Error') ? 'PHPUnit\Framework\Error\Error' : 'PHPUnit_Framework_Error');
} else {
$this->setExpectedException('PHPUnit_Framework_Error');
}
$var = $this->l2->nonExistant;
}
}
16 changes: 11 additions & 5 deletions tests/unit/Http/HttpRequestParserTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php
namespace Ratchet\Http;

use PHPUnit\Framework\TestCase;

/**
* @covers Ratchet\Http\HttpRequestParser
*/
class HttpRequestParserTest extends \PHPUnit_Framework_TestCase {
class HttpRequestParserTest extends TestCase {
protected $parser;

public function setUp() {
Expand All @@ -30,21 +32,25 @@ public function testIsEom($expected, $message) {
}

public function testBufferOverflowResponse() {
$conn = $this->getMock('\Ratchet\ConnectionInterface');
$conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock();

$this->parser->maxSize = 20;

$this->assertNull($this->parser->onMessage($conn, "GET / HTTP/1.1\r\n"));

$this->setExpectedException('OverflowException');
if (method_exists($this, 'expectException')) {
$this->expectException('OverflowException');
} else {
$this->setExpectedException('OverflowException');
}

$this->parser->onMessage($conn, "Header-Is: Too Big");
}

public function testReturnTypeIsRequest() {
$conn = $this->getMock('\Ratchet\ConnectionInterface');
$conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock();
$return = $this->parser->onMessage($conn, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n");

$this->assertInstanceOf('\Psr\Http\Message\RequestInterface', $return);
$this->assertInstanceOf('Psr\Http\Message\RequestInterface', $return);
}
}
6 changes: 3 additions & 3 deletions tests/unit/Http/HttpServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public function setUp() {
}

public function getConnectionClassString() {
return '\Ratchet\ConnectionInterface';
return 'Ratchet\ConnectionInterface';
}

public function getDecoratorClassString() {
return '\Ratchet\Http\HttpServer';
return 'Ratchet\Http\HttpServer';
}

public function getComponentClassString() {
return '\Ratchet\Http\HttpServerInterface';
return 'Ratchet\Http\HttpServerInterface';
}

public function testOpen() {
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/Http/OriginCheckTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ class OriginCheckTest extends AbstractMessageComponentTestCase {
protected $_reqStub;

public function setUp() {
$this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface');
$this->_reqStub = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock();
$this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost']));

parent::setUp();

assert($this->_serv instanceof OriginCheck);
$this->_serv->allowedOrigins[] = 'localhost';
}

Expand All @@ -22,15 +23,15 @@ protected function doOpen($conn) {
}

public function getConnectionClassString() {
return '\Ratchet\ConnectionInterface';
return 'Ratchet\ConnectionInterface';
}

public function getDecoratorClassString() {
return '\Ratchet\Http\OriginCheck';
return 'Ratchet\Http\OriginCheck';
}

public function getComponentClassString() {
return '\Ratchet\Http\HttpServerInterface';
return 'Ratchet\Http\HttpServerInterface';
}

public function testCloseOnNonMatchingOrigin() {
Expand Down
Loading