From 6bc3958e43a85b2cf96adf18f04db77d7ae72fe1 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 12 May 2023 18:15:49 +1200 Subject: [PATCH 01/75] Create test --- test | 1 + 1 file changed, 1 insertion(+) create mode 100644 test diff --git a/test b/test new file mode 100644 index 00000000..deba01fc --- /dev/null +++ b/test @@ -0,0 +1 @@ +something From b7aa6a59eee85cb2a39e900adcd2c2bef154dfe5 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 12 May 2023 19:54:34 +1200 Subject: [PATCH 02/75] Add missing properties to IoConnection.php --- .gitignore | 3 ++- src/Ratchet/Server/IoConnection.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 793ef583..dcfc65ec 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ phpunit.xml reports sandbox vendor -composer.lock \ No newline at end of file +composer.lock +.idea/ diff --git a/src/Ratchet/Server/IoConnection.php b/src/Ratchet/Server/IoConnection.php index 9f864bb9..e1b2db60 100644 --- a/src/Ratchet/Server/IoConnection.php +++ b/src/Ratchet/Server/IoConnection.php @@ -11,8 +11,10 @@ class IoConnection implements ConnectionInterface { * @var \React\Socket\ConnectionInterface */ protected $conn; - - + public $httpHeadersReceived; + public $remoteAddress; + public $resourceId; + /** * @param \React\Socket\ConnectionInterface $conn */ From 78c0e0e02e269d58a4f1aa1d86e852b7855d87e7 Mon Sep 17 00:00:00 2001 From: Josh Date: Sat, 13 May 2023 22:51:22 +1200 Subject: [PATCH 03/75] Update to work with PHP 8.2 --- src/Ratchet/Http/HttpRequestParser.php | 34 ++++++++++++ src/Ratchet/Http/HttpServer.php | 35 +++++++++++++ src/Ratchet/Server/IoConnection.php | 17 ++++-- src/Ratchet/Server/IoServer.php | 72 +++++++++++++++++++------- src/Ratchet/WebSocket/WsServer.php | 36 ++++++++++++- 5 files changed, 171 insertions(+), 23 deletions(-) diff --git a/src/Ratchet/Http/HttpRequestParser.php b/src/Ratchet/Http/HttpRequestParser.php index 5043c284..6b8dea87 100644 --- a/src/Ratchet/Http/HttpRequestParser.php +++ b/src/Ratchet/Http/HttpRequestParser.php @@ -19,6 +19,40 @@ class HttpRequestParser implements MessageInterface { */ public $maxSize = 4096; + /** + * Storage for dynamic properties. + * + * @var array + */ + protected $_properties = []; + + /** + * Allow setting dynamic properties. + * + * @param string $key + * @param mixed $value + * + * @return void + */ + public function __set($key, $value) { + if (property_exists($this, $key)) { + $this->_properties[$key] = $value; + } + } + + /** + * Get a property that has been declared dynamically + * + * @param string $key + * + * @return mixed|void + */ + public function __get($key) { + if (isset($this->_properties[$key])) { + return $this->_properties[$key]; + } + } + /** * @param \Ratchet\ConnectionInterface $context * @param string $data Data stream to buffer diff --git a/src/Ratchet/Http/HttpServer.php b/src/Ratchet/Http/HttpServer.php index bbd8d532..188ab3f8 100644 --- a/src/Ratchet/Http/HttpServer.php +++ b/src/Ratchet/Http/HttpServer.php @@ -1,5 +1,6 @@ _reqParser = new HttpRequestParser; } + /** + * Allow setting dynamic properties. + * + * @param string $key + * @param mixed $value + * + * @return void + */ + public function __set($key, $value) { + if (property_exists($this, $key)) { + $this->_properties[$key] = $value; + } + } + + /** + * Get a property that has been declared dynamically + * + * @param string $key + * + * @return mixed|void + */ + public function __get($key) { + if (isset($this->_properties[$key])) { + return $this->_properties[$key]; + } + } + /** * {@inheritdoc} */ diff --git a/src/Ratchet/Server/IoConnection.php b/src/Ratchet/Server/IoConnection.php index e1b2db60..eb510778 100644 --- a/src/Ratchet/Server/IoConnection.php +++ b/src/Ratchet/Server/IoConnection.php @@ -11,9 +11,20 @@ class IoConnection implements ConnectionInterface { * @var \React\Socket\ConnectionInterface */ protected $conn; - public $httpHeadersReceived; - public $remoteAddress; - public $resourceId; + + protected $properties = []; + + public function __set($key, $value) { + if (!property_exists($this, $key)) { + $this->properties[$key] = $value; + } + } + + public function __get($key) { + if (isset($this->properties[$key])) { + return $this->properties[$key]; + } + } /** * @param \React\Socket\ConnectionInterface $conn diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index b3fb7e0e..ddadf95b 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -28,6 +28,13 @@ class IoServer { */ public $socket; + /** + * Storage for dynamic properties. + * + * @var array + */ + protected $_properties = []; + /** * @param \Ratchet\MessageComponentInterface $app The Ratchet application stack to host * @param \React\Socket\ServerInterface $socket The React socket server to run the Ratchet application off of @@ -48,6 +55,33 @@ public function __construct(MessageComponentInterface $app, ServerInterface $soc $socket->on('connection', array($this, 'handleConnect')); } + /** + * Allow setting dynamic properties. + * + * @param string $key + * @param mixed $value + * + * @return void + */ + public function __set($key, $value) { + if (property_exists($this, $key)) { + $this->_properties[$key] = $value; + } + } + + /** + * Get a property that has been declared dynamically + * + * @param string $key + * + * @return mixed|void + */ + public function __get($key) { + if (isset($this->_properties[$key])) { + return $this->_properties[$key]; + } + } + /** * @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received * @param int $port The port to server sockets on @@ -80,25 +114,25 @@ public function run() { * @param \React\Socket\ConnectionInterface $conn */ public function handleConnect($conn) { - $conn->decor = new IoConnection($conn); - $conn->decor->resourceId = (int)$conn->stream; + $io_conn = new IoConnection($conn); + $io_conn->resourceId = (int)$conn->stream; $uri = $conn->getRemoteAddress(); - $conn->decor->remoteAddress = trim( + $io_conn->remoteAddress = trim( parse_url((strpos($uri, '://') === false ? 'tcp://' : '') . $uri, PHP_URL_HOST), '[]' ); - $this->app->onOpen($conn->decor); + $this->app->onOpen($io_conn); - $conn->on('data', function ($data) use ($conn) { - $this->handleData($data, $conn); + $conn->on('data', function ($data) use ($io_conn) { + $this->handleData($data, $io_conn); }); - $conn->on('close', function () use ($conn) { - $this->handleEnd($conn); + $conn->on('close', function () use ($io_conn) { + $this->handleEnd($io_conn); }); - $conn->on('error', function (\Exception $e) use ($conn) { - $this->handleError($e, $conn); + $conn->on('error', function (\Exception $e) use ($io_conn) { + $this->handleError($e, $io_conn); }); } @@ -107,11 +141,11 @@ public function handleConnect($conn) { * @param string $data * @param \React\Socket\ConnectionInterface $conn */ - public function handleData($data, $conn) { + public function handleData($data, $io_conn) { try { - $this->app->onMessage($conn->decor, $data); + $this->app->onMessage($io_conn, $data); } catch (\Exception $e) { - $this->handleError($e, $conn); + $this->handleError($e, $io_conn); } } @@ -119,14 +153,14 @@ public function handleData($data, $conn) { * A connection has been closed by React * @param \React\Socket\ConnectionInterface $conn */ - public function handleEnd($conn) { + public function handleEnd($io_conn) { try { - $this->app->onClose($conn->decor); + $this->app->onClose($io_conn); } catch (\Exception $e) { - $this->handleError($e, $conn); + $this->handleError($e, $io_conn); } - unset($conn->decor); + unset($io_conn); } /** @@ -134,7 +168,7 @@ public function handleEnd($conn) { * @param \Exception $e * @param \React\Socket\ConnectionInterface $conn */ - public function handleError(\Exception $e, $conn) { - $this->app->onError($conn->decor, $e); + public function handleError(\Exception $e, $io_conn) { + $this->app->onError($io_conn, $e); } } diff --git a/src/Ratchet/WebSocket/WsServer.php b/src/Ratchet/WebSocket/WsServer.php index 27795ca7..118c9c3b 100644 --- a/src/Ratchet/WebSocket/WsServer.php +++ b/src/Ratchet/WebSocket/WsServer.php @@ -61,6 +61,13 @@ class WsServer implements HttpServerInterface { */ private $msgCb; + /** + * Storage for dynamic properties. + * + * @var array + */ + protected $_properties = []; + /** * @param \Ratchet\WebSocket\MessageComponentInterface|\Ratchet\MessageComponentInterface $component Your application to run with WebSockets * @note If you want to enable sub-protocols have your component implement WsServerInterface as well @@ -101,6 +108,34 @@ public function __construct(ComponentInterface $component) { }; } + + /** + * Allow setting dynamic properties. + * + * @param string $key + * @param mixed $value + * + * @return void + */ + public function __set($key, $value) { + if (property_exists($this, $key)) { + $this->_properties[$key] = $value; + } + } + + /** + * Get a property that has been declared dynamically + * + * @param string $key + * + * @return mixed|void + */ + public function __get($key) { + if (isset($this->_properties[$key])) { + return $this->_properties[$key]; + } + } + /** * {@inheritdoc} */ @@ -115,7 +150,6 @@ public function onOpen(ConnectionInterface $conn, RequestInterface $request = nu $conn->WebSocket->closing = false; $response = $this->handshakeNegotiator->handshake($request)->withHeader('X-Powered-By', \Ratchet\VERSION); - $conn->send(Message::toString($response)); if (101 !== $response->getStatusCode()) { From 8e6acea2ac0cfcf60d5ec3ebcb7d1d88864ffd51 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 00:39:40 +1200 Subject: [PATCH 04/75] Update tests to run on version upto 8.2 --- .github/workflows/ci.yml | 3 +++ test | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) delete mode 100644 test diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aa12b680..96aeafed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,6 +24,9 @@ jobs: - "7.2" - "7.3" - "7.4" + - "8.0" + - "8.1" + - "8.2" dependencies: - "highest" include: diff --git a/test b/test deleted file mode 100644 index deba01fc..00000000 --- a/test +++ /dev/null @@ -1 +0,0 @@ -something From 5c39aec5e3ec64a2f89c5e09fc4d24eba9f1760a Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 00:44:37 +1200 Subject: [PATCH 05/75] Allow manual workflow run --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 96aeafed..9be5cc60 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: - "master" schedule: - cron: "42 3 * * *" + workflow_dispatch: jobs: phpunit: From 1022815b12c66e33f1f57e3692f325fd04fe4760 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 00:49:52 +1200 Subject: [PATCH 06/75] Update comments --- src/Ratchet/Server/IoServer.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index ddadf95b..f4976da5 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -139,7 +139,7 @@ public function handleConnect($conn) { /** * Data has been received from React * @param string $data - * @param \React\Socket\ConnectionInterface $conn + * @param \React\Socket\ConnectionInterface $io_conn */ public function handleData($data, $io_conn) { try { @@ -151,7 +151,7 @@ public function handleData($data, $io_conn) { /** * A connection has been closed by React - * @param \React\Socket\ConnectionInterface $conn + * @param \React\Socket\ConnectionInterface $io_conn */ public function handleEnd($io_conn) { try { @@ -166,7 +166,7 @@ public function handleEnd($io_conn) { /** * An error has occurred, let the listening application know * @param \Exception $e - * @param \React\Socket\ConnectionInterface $conn + * @param \React\Socket\ConnectionInterface $io_conn */ public function handleError(\Exception $e, $io_conn) { $this->app->onError($io_conn, $e); From 62da503bc0450c15ed02daed7a78010b2c6a7ce5 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 00:58:53 +1200 Subject: [PATCH 07/75] Update tests --- src/Ratchet/Server/IoServer.php | 6 +++--- tests/unit/Server/IoServerTest.php | 5 ++--- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Ratchet/Server/IoServer.php b/src/Ratchet/Server/IoServer.php index f4976da5..3d6749d6 100644 --- a/src/Ratchet/Server/IoServer.php +++ b/src/Ratchet/Server/IoServer.php @@ -139,7 +139,7 @@ public function handleConnect($conn) { /** * Data has been received from React * @param string $data - * @param \React\Socket\ConnectionInterface $io_conn + * @param \Ratchet\ConnectionInterface $io_conn */ public function handleData($data, $io_conn) { try { @@ -151,7 +151,7 @@ public function handleData($data, $io_conn) { /** * A connection has been closed by React - * @param \React\Socket\ConnectionInterface $io_conn + * @param \Ratchet\ConnectionInterface $io_conn */ public function handleEnd($io_conn) { try { @@ -166,7 +166,7 @@ public function handleEnd($io_conn) { /** * An error has occurred, let the listening application know * @param \Exception $e - * @param \React\Socket\ConnectionInterface $io_conn + * @param \Ratchet\ConnectionInterface $io_conn */ public function handleError(\Exception $e, $io_conn) { $this->app->onError($io_conn, $e); diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index e20115f2..67115cf1 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -103,11 +103,10 @@ public function testNoLoopProvidedError() { } public function testOnErrorPassesException() { - $conn = $this->getMock('\\React\\Socket\\ConnectionInterface'); - $conn->decor = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); $err = new \Exception("Nope"); - $this->app->expects($this->once())->method('onError')->with($conn->decor, $err); + $this->app->expects($this->once())->method('onError')->with($conn, $err); $this->server->handleError($err, $conn); } From addf94f59d882dbaa1889b0ff233016ca5823795 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 01:05:48 +1200 Subject: [PATCH 08/75] Update PHPUnit to v9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1dffae6b..29332996 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,6 @@ , "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" } , "require-dev": { - "phpunit/phpunit": "~4.8" + "phpunit/phpunit": "~9" } } From 67f655bd17b176691b4c3fcd4051fe8b8b15c4da Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 01:07:40 +1200 Subject: [PATCH 09/75] Update PHPUnit to v9 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 29332996..34560828 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,6 @@ , "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" } , "require-dev": { - "phpunit/phpunit": "~9" + "phpunit/phpunit": "~4.8 || ~9" } } From 6b88bc19517015c6a5c3aae3fea70c9976155e70 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 01:43:10 +1200 Subject: [PATCH 10/75] Update workflow --- .github/workflows/ci.yml | 25 +++++++++++++++++++++---- composer.json | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9be5cc60..5611ae38 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,6 +28,8 @@ jobs: - "8.0" - "8.1" - "8.2" + phpunit-versions: + - "latest" dependencies: - "highest" include: @@ -46,11 +48,26 @@ jobs: php-version: "${{ matrix.php-version }}" coverage: "none" ini-values: "zend.assertions=1" + tools: phpunit:${{ matrix.phpunit-versions }} + - run: echo "${{ matrix.php-versions }}" - - name: "Install dependencies with Composer" - uses: "ramsey/composer-install@v1" - with: - dependency-versions: "${{ matrix.dependencies }}" + - name: "PHP < 7.0" + if: ${{ matrix.php-versions }} < 7.0 + run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 4.8 + + - name: "PHP 7.0" + if: ${{ matrix.php-versions }} == 7.0 + run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 6.0 + + - name: "PHP 7.4" + if: "${{ matrix.php-versions }} == 7.4" + run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 8.0 + + - name: "PHP >8.0" + if: "${{ matrix.php-versions }} >= 8.0" + run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit + - run: composer install + - name: "Run PHPUnit" run: "vendor/bin/phpunit" diff --git a/composer.json b/composer.json index 34560828..4b908bb5 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,6 @@ , "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" } , "require-dev": { - "phpunit/phpunit": "~4.8 || ~9" + "phpunit/phpunit": "^4.8" } } From 6a6b3f923883f284d87cac879bab4dea29b6e73e Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 01:47:13 +1200 Subject: [PATCH 11/75] Update workflow --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5611ae38..c5848f7d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,14 +49,13 @@ jobs: coverage: "none" ini-values: "zend.assertions=1" tools: phpunit:${{ matrix.phpunit-versions }} - - run: echo "${{ matrix.php-versions }}" - name: "PHP < 7.0" - if: ${{ matrix.php-versions }} < 7.0 + if: "${{ matrix.php-versions }} < 7.0" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 4.8 - name: "PHP 7.0" - if: ${{ matrix.php-versions }} == 7.0 + if: "${{ matrix.php-versions }} == 7.0" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 6.0 - name: "PHP 7.4" @@ -67,7 +66,8 @@ jobs: if: "${{ matrix.php-versions }} >= 8.0" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit - - run: composer install - + - name: "Install dependencies" + - run: composer update + - name: "Run PHPUnit" run: "vendor/bin/phpunit" From 95e07c0360546fc9e680e9de6c99b10e7ae584da Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 01:49:04 +1200 Subject: [PATCH 12/75] Update workflow --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c5848f7d..decdfdea 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,7 +67,7 @@ jobs: run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit - name: "Install dependencies" - - run: composer update + run: composer update - name: "Run PHPUnit" run: "vendor/bin/phpunit" From cb3f72bee5770c7928662e41ef1d344b5a0c669d Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 01:53:28 +1200 Subject: [PATCH 13/75] Update workflow --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index decdfdea..33b91552 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,19 +51,19 @@ jobs: tools: phpunit:${{ matrix.phpunit-versions }} - name: "PHP < 7.0" - if: "${{ matrix.php-versions }} < 7.0" + if: "${{ matrix.php-version }} < 7.0" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 4.8 - name: "PHP 7.0" - if: "${{ matrix.php-versions }} == 7.0" + if: "${{ matrix.php-version }} == 7.0" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 6.0 - name: "PHP 7.4" - if: "${{ matrix.php-versions }} == 7.4" + if: "${{ matrix.php-version }} == 7.4" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 8.0 - name: "PHP >8.0" - if: "${{ matrix.php-versions }} >= 8.0" + if: "${{ matrix.php-version }} >= 8.0" run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit - name: "Install dependencies" From bd33ac5ae6e6311d5692896ab1c2ea3318378c10 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:03:42 +1200 Subject: [PATCH 14/75] Update workflow --- .github/workflows/ci.yml | 72 +++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33b91552..a05b592c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,26 +15,44 @@ jobs: runs-on: "ubuntu-20.04" strategy: + fail-fast: false matrix: - php-version: - - "5.4" - - "5.5" - - "5.6" - - "7.0" - - "7.1" - - "7.2" - - "7.3" - - "7.4" - - "8.0" - - "8.1" - - "8.2" - phpunit-versions: - - "latest" + include: + - php: 5.4 + phpunit: ^4 + can-fail: false + - php: 5.5 + phpunit: ^4 + can-fail: false + - php: 5.6 + phpunit: ^5 + can-fail: false + - php: 7.0 + phpunit: ^6 + can-fail: false + - php: 7.1 + phpunit: ^7 + can-fail: false + - php: 7.2 + phpunit: ^8 + can-fail: false + - php: 7.3 + phpunit: ^9 + can-fail: false + - php: 7.4 + phpunit: ^9 + can-fail: false + - php: 8.0 + phpunit: ^9 + can-fail: false + - php: 8.1 + phpunit: ^10 + can-fail: false + - php: 8.2 + phpunit: ^10 + can-fail: false dependencies: - "highest" - include: - - dependencies: "lowest" - php-version: "5.4" steps: - name: "Checkout" @@ -45,26 +63,12 @@ jobs: - name: "Install PHP" uses: "shivammathur/setup-php@v2" with: - php-version: "${{ matrix.php-version }}" + php-version: "${{ matrix.php }}" coverage: "none" ini-values: "zend.assertions=1" - tools: phpunit:${{ matrix.phpunit-versions }} - - - name: "PHP < 7.0" - if: "${{ matrix.php-version }} < 7.0" - run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 4.8 - - - name: "PHP 7.0" - if: "${{ matrix.php-version }} == 7.0" - run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 6.0 - - - name: "PHP 7.4" - if: "${{ matrix.php-version }} == 7.4" - run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit 8.0 - - name: "PHP >8.0" - if: "${{ matrix.php-version }} >= 8.0" - run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit + - name: "Update PHPUnit version" + run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit ${{ matrix.phpunit }} - name: "Install dependencies" run: composer update From b58f1faebbf0ca0dcac097bf80788b635e3ecfaa Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:04:57 +1200 Subject: [PATCH 15/75] Update workflow --- .github/workflows/ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a05b592c..114b461c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,8 +51,6 @@ jobs: - php: 8.2 phpunit: ^10 can-fail: false - dependencies: - - "highest" steps: - name: "Checkout" From 3020d284b4be493a71766187505a527e6ef30d45 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:08:47 +1200 Subject: [PATCH 16/75] Update workflow --- .github/workflows/ci.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 114b461c..bd4f8ea4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,37 +19,37 @@ jobs: matrix: include: - php: 5.4 - phpunit: ^4 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 5.5 - phpunit: ^4 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 5.6 - phpunit: ^5 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 7.0 - phpunit: ^6 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 7.1 - phpunit: ^7 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 7.2 - phpunit: ^8 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 7.3 - phpunit: ^9 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 7.4 - phpunit: ^9 + phpunit: phpunit/phpunit ~4.8 can-fail: false - php: 8.0 - phpunit: ^9 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 8.1 - phpunit: ^10 + phpunit: phpunit/phpunit ^10 can-fail: false - php: 8.2 - phpunit: ^10 + phpunit: phpunit/phpunit ^10 can-fail: false steps: @@ -66,7 +66,7 @@ jobs: ini-values: "zend.assertions=1" - name: "Update PHPUnit version" - run: composer require --dev --with-all-dependencies --no-install phpunit/phpunit ${{ matrix.phpunit }} + run: composer require --dev --with-all-dependencies --no-install ${{ matrix.phpunit }} - name: "Install dependencies" run: composer update From d14857dd5f392e42cd54e0fe7a3e91482e358919 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:20:58 +1200 Subject: [PATCH 17/75] Update workflow --- .github/workflows/ci.yml | 22 +++++++++---------- .../AbstractMessageComponentTestCase.php | 5 +++-- .../unit/AbstractConnectionDecoratorTest.php | 5 +++-- tests/unit/Http/HttpRequestParserTest.php | 6 +++-- tests/unit/Http/HttpServerTest.php | 4 ++-- tests/unit/Http/OriginCheckTest.php | 4 ++-- tests/unit/Http/RouterTest.php | 13 ++++++----- tests/unit/Server/EchoServerTest.php | 5 +++-- .../unit/Server/FlashPolicyComponentTest.php | 5 +++-- tests/unit/Server/IoConnectionTest.php | 5 +++-- tests/unit/Server/IoServerTest.php | 5 +++-- .../unit/Server/IpBlackListComponentTest.php | 5 +++-- .../unit/Session/Serialize/PhpHandlerTest.php | 5 +++-- tests/unit/Session/SessionComponentTest.php | 6 ++--- .../Storage/VirtualSessionStoragePDOTest.php | 7 +++--- tests/unit/Wamp/ServerProtocolTest.php | 5 +++-- tests/unit/Wamp/TopicManagerTest.php | 6 +++-- tests/unit/Wamp/TopicTest.php | 3 ++- tests/unit/Wamp/WampConnectionTest.php | 5 +++-- 19 files changed, 69 insertions(+), 52 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd4f8ea4..dae8283b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,37 +19,37 @@ jobs: matrix: include: - php: 5.4 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 5.5 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 5.6 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 7.0 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 7.1 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 7.2 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 7.3 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 7.4 - phpunit: phpunit/phpunit ~4.8 + phpunit: phpunit/phpunit ^5.7 can-fail: false - php: 8.0 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^9.3 can-fail: false - php: 8.1 - phpunit: phpunit/phpunit ^10 + phpunit: phpunit/phpunit ^9.3 can-fail: false - php: 8.2 - phpunit: phpunit/phpunit ^10 + phpunit: phpunit/phpunit ^9.3 can-fail: false steps: diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 8c298e5b..9bed9eee 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -1,7 +1,8 @@ _app = $this->getMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index 0887d3e9..e724d780 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -1,17 +1,18 @@ mock = $this->getMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index 6af8402c..b75daa21 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -1,13 +1,15 @@ parser = new HttpRequestParser; } diff --git a/tests/unit/Http/HttpServerTest.php b/tests/unit/Http/HttpServerTest.php index 7041d66b..6c214c16 100644 --- a/tests/unit/Http/HttpServerTest.php +++ b/tests/unit/Http/HttpServerTest.php @@ -6,8 +6,8 @@ * @covers Ratchet\Http\HttpServer */ class HttpServerTest extends AbstractMessageComponentTestCase { - public function setUp() { - parent::setUp(); + public function before() { + parent::before(); $this->_conn->httpHeadersReceived = true; } diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index c1c40120..84025cb2 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -8,11 +8,11 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { protected $_reqStub; - public function setUp() { + public function before() { $this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); - parent::setUp(); + parent::before(); $this->_serv->allowedOrigins[] = 'localhost'; } diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 1ca4cbc8..d74e2a14 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -1,5 +1,6 @@ _conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); @@ -151,10 +152,10 @@ public function testImpatientClientOverflow() { $this->_conn->expects($this->once())->method('close'); $header = "GET /nope HTTP/1.1 -Upgrade: websocket -Connection: upgrade -Host: localhost -Origin: http://localhost +Upgrade: websocket +Connection: upgrade +Host: localhost +Origin: http://localhost Sec-WebSocket-Version: 13\r\n\r\n"; $app = new HttpServer(new Router(new UrlMatcher(new RouteCollection, new RequestContext))); diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 47fb0e28..6d51d356 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -1,12 +1,13 @@ _conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 38fc96a6..2bf77e35 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -1,15 +1,16 @@ _policy = new FlashPolicy(); } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index 07130f6d..37a83e67 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -1,15 +1,16 @@ sock = $this->getMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 67115cf1..97ada305 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -1,5 +1,6 @@ run(); } - public function setUp() { + public function before() { $this->app = $this->getMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index 90f41859..1822033c 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -1,15 +1,16 @@ mock = $this->getMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } diff --git a/tests/unit/Session/Serialize/PhpHandlerTest.php b/tests/unit/Session/Serialize/PhpHandlerTest.php index 4acf5bc6..d5a1ea2b 100644 --- a/tests/unit/Session/Serialize/PhpHandlerTest.php +++ b/tests/unit/Session/Serialize/PhpHandlerTest.php @@ -1,14 +1,15 @@ _handler = new PhpHandler; } diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index ea452db3..7fd368c7 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -10,18 +10,18 @@ * @covers Ratchet\Session\Storage\Proxy\VirtualProxy */ class SessionProviderTest extends AbstractMessageComponentTestCase { - public function setUp() { + public function before() { return $this->markTestIncomplete('Test needs to be updated for ini_set issue in PHP 7.2'); if (!class_exists('Symfony\Component\HttpFoundation\Session\Session')) { return $this->markTestSkipped('Dependency of Symfony HttpFoundation failed'); } - parent::setUp(); + parent::before(); $this->_serv = new SessionProvider($this->_app, new NullSessionHandler); } - public function tearDown() { + public function after() { ini_set('session.serialize_handler', 'php'); } diff --git a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php index 2727484d..40e4f117 100644 --- a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php +++ b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php @@ -1,11 +1,12 @@ markTestSkipped('Session test requires PDO and pdo_sqlite'); } @@ -41,7 +42,7 @@ public function setUp() { $this->_virtualSessionStorage->registerBag(new AttributeBag()); } - public function tearDown() { + public function after() { unlink($this->_pathToDB); } diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index 8ff68c25..afac7870 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -1,5 +1,6 @@ _app = new TestComponent; $this->_comp = new ServerProtocol($this->_app); } diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index b21b6bc0..0acc17fb 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -1,10 +1,12 @@ conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->mock = $this->getMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index b8685b7e..6f77a01a 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -1,10 +1,11 @@ mock = $this->getMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } From 56b8cecfc9d40461e78d815c064952b54167b0b8 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:26:30 +1200 Subject: [PATCH 18/75] Update workflow --- .github/workflows/ci.yml | 22 +++++++++++----------- phpunit.xml.dist | 8 +------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dae8283b..04b66018 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,37 +19,37 @@ jobs: matrix: include: - php: 5.4 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^4 can-fail: false - php: 5.5 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^4 can-fail: false - php: 5.6 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.0 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.1 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.2 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.3 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 7.4 - phpunit: phpunit/phpunit ^5.7 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 8.0 - phpunit: phpunit/phpunit ^9.3 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 8.1 - phpunit: phpunit/phpunit ^9.3 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 8.2 - phpunit: phpunit/phpunit ^9.3 + phpunit: phpunit/phpunit ^9 can-fail: false steps: diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0cc5451b..7f8d6fb4 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -16,15 +16,9 @@ - - - ./tests/integration/ - - - ./src/ - \ No newline at end of file + From cd914b470448bfae3ab18622f428a2462b254658 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:34:10 +1200 Subject: [PATCH 19/75] Update workflow --- tests/helpers/Ratchet/AbstractMessageComponentTestCase.php | 2 +- tests/unit/AbstractConnectionDecoratorTest.php | 2 +- tests/unit/Http/HttpRequestParserTest.php | 2 +- tests/unit/Http/HttpServerTest.php | 4 ++-- tests/unit/Http/OriginCheckTest.php | 4 ++-- tests/unit/Http/RouterTest.php | 2 +- tests/unit/Server/EchoServerTest.php | 2 +- tests/unit/Server/FlashPolicyComponentTest.php | 2 +- tests/unit/Server/IoConnectionTest.php | 2 +- tests/unit/Server/IoServerTest.php | 2 +- tests/unit/Server/IpBlackListComponentTest.php | 2 +- tests/unit/Session/Serialize/PhpHandlerTest.php | 2 +- tests/unit/Session/SessionComponentTest.php | 6 +++--- tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php | 4 ++-- tests/unit/Wamp/ServerProtocolTest.php | 2 +- tests/unit/Wamp/TopicManagerTest.php | 2 +- tests/unit/Wamp/WampConnectionTest.php | 2 +- 17 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 9bed9eee..7ea127ae 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -11,7 +11,7 @@ abstract public function getConnectionClassString(); abstract public function getDecoratorClassString(); abstract public function getComponentClassString(); - public function before() { + public function setUp() { $this->_app = $this->getMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index e724d780..aefe20c1 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -12,7 +12,7 @@ class AbstractConnectionDecoratorTest extends TestCase { protected $l1; protected $l2; - public function before() { + public function setUp() { $this->mock = $this->getMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index b75daa21..6bbec51e 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -9,7 +9,7 @@ class HttpRequestParserTest extends TestCase { protected $parser; - public function before() { + public function setUp() { $this->parser = new HttpRequestParser; } diff --git a/tests/unit/Http/HttpServerTest.php b/tests/unit/Http/HttpServerTest.php index 6c214c16..7041d66b 100644 --- a/tests/unit/Http/HttpServerTest.php +++ b/tests/unit/Http/HttpServerTest.php @@ -6,8 +6,8 @@ * @covers Ratchet\Http\HttpServer */ class HttpServerTest extends AbstractMessageComponentTestCase { - public function before() { - parent::before(); + public function setUp() { + parent::setUp(); $this->_conn->httpHeadersReceived = true; } diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index 84025cb2..c1c40120 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -8,11 +8,11 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { protected $_reqStub; - public function before() { + public function setUp() { $this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); - parent::before(); + parent::setUp(); $this->_serv->allowedOrigins[] = 'localhost'; } diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index d74e2a14..0d31f642 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -19,7 +19,7 @@ class RouterTest extends TestCase { protected $_uri; protected $_req; - public function before() { + public function setUp() { $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 6d51d356..92114f2c 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -7,7 +7,7 @@ class EchoServerTest extends TestCase { protected $_conn; protected $_comp; - public function before() { + public function setUp() { $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 2bf77e35..51f86ddb 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -10,7 +10,7 @@ class FlashPolicyTest extends TestCase { protected $_policy; - public function before() { + public function setUp() { $this->_policy = new FlashPolicy(); } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index 37a83e67..60f4d36a 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -10,7 +10,7 @@ class IoConnectionTest extends TestCase { protected $sock; protected $conn; - public function before() { + public function setUp() { $this->sock = $this->getMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 97ada305..a4048df6 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -26,7 +26,7 @@ protected function tickLoop(LoopInterface $loop) { $loop->run(); } - public function before() { + public function setUp() { $this->app = $this->getMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index 1822033c..fea658e9 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -10,7 +10,7 @@ class IpBlackListTest extends TestCase { protected $blocker; protected $mock; - public function before() { + public function setUp() { $this->mock = $this->getMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } diff --git a/tests/unit/Session/Serialize/PhpHandlerTest.php b/tests/unit/Session/Serialize/PhpHandlerTest.php index d5a1ea2b..2a7586c4 100644 --- a/tests/unit/Session/Serialize/PhpHandlerTest.php +++ b/tests/unit/Session/Serialize/PhpHandlerTest.php @@ -9,7 +9,7 @@ class PhpHandlerTest extends TestCase { protected $_handler; - public function before() { + public function setUp() { $this->_handler = new PhpHandler; } diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index 7fd368c7..ea452db3 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -10,18 +10,18 @@ * @covers Ratchet\Session\Storage\Proxy\VirtualProxy */ class SessionProviderTest extends AbstractMessageComponentTestCase { - public function before() { + public function setUp() { return $this->markTestIncomplete('Test needs to be updated for ini_set issue in PHP 7.2'); if (!class_exists('Symfony\Component\HttpFoundation\Session\Session')) { return $this->markTestSkipped('Dependency of Symfony HttpFoundation failed'); } - parent::before(); + parent::setUp(); $this->_serv = new SessionProvider($this->_app, new NullSessionHandler); } - public function after() { + public function tearDown() { ini_set('session.serialize_handler', 'php'); } diff --git a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php index 40e4f117..1f6466e6 100644 --- a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php +++ b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php @@ -14,7 +14,7 @@ class VirtualSessionStoragePDOTest extends TestCase { protected $_pathToDB; - public function before() { + public function setUp() { if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { return $this->markTestSkipped('Session test requires PDO and pdo_sqlite'); } @@ -42,7 +42,7 @@ public function before() { $this->_virtualSessionStorage->registerBag(new AttributeBag()); } - public function after() { + public function tearDown() { unlink($this->_pathToDB); } diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index afac7870..f0762e20 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -14,7 +14,7 @@ class ServerProtocolTest extends TestCase { protected $_app; - public function before() { + public function setUp() { $this->_app = new TestComponent; $this->_comp = new ServerProtocol($this->_app); } diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index 0acc17fb..b1eeac61 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -19,7 +19,7 @@ class TopicManagerTest extends TestCase { */ private $conn; - public function before() { + public function setUp() { $this->conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->mock = $this->getMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index fe9da046..62f51d4a 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -9,7 +9,7 @@ class WampConnectionTest extends TestCase { protected $conn; protected $mock; - public function before() { + public function setUp() { $this->mock = $this->getMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } From 129c47ee88667582e9fc4493afe3f4bde81e719e Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:38:37 +1200 Subject: [PATCH 20/75] Update workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04b66018..facafb06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,13 +28,13 @@ jobs: phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.0 - phpunit: phpunit/phpunit ^5 + phpunit: phpunit/phpunit ^6 can-fail: false - php: 7.1 - phpunit: phpunit/phpunit ^5 + phpunit: phpunit/phpunit ^7 can-fail: false - php: 7.2 - phpunit: phpunit/phpunit ^5 + phpunit: phpunit/phpunit ^8 can-fail: false - php: 7.3 phpunit: phpunit/phpunit ^9 From 4110b83f38c9f6b9bcd4f5d0e03fc7febbda8744 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:40:15 +1200 Subject: [PATCH 21/75] Update workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index facafb06..85fed8fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,10 +34,10 @@ jobs: phpunit: phpunit/phpunit ^7 can-fail: false - php: 7.2 - phpunit: phpunit/phpunit ^8 + phpunit: phpunit/phpunit ^7 can-fail: false - php: 7.3 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^7 can-fail: false - php: 7.4 phpunit: phpunit/phpunit ^9 From 158e94429fae90d5180906d2d2265354999189cf Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:43:46 +1200 Subject: [PATCH 22/75] Update workflow --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 85fed8fe..facafb06 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,10 +34,10 @@ jobs: phpunit: phpunit/phpunit ^7 can-fail: false - php: 7.2 - phpunit: phpunit/phpunit ^7 + phpunit: phpunit/phpunit ^8 can-fail: false - php: 7.3 - phpunit: phpunit/phpunit ^7 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 7.4 phpunit: phpunit/phpunit ^9 From 6bddff9d58d6eb9c667e3635a274e2b280799395 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 02:45:24 +1200 Subject: [PATCH 23/75] Update workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index facafb06..04b66018 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,13 +28,13 @@ jobs: phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.0 - phpunit: phpunit/phpunit ^6 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.1 - phpunit: phpunit/phpunit ^7 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.2 - phpunit: phpunit/phpunit ^8 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.3 phpunit: phpunit/phpunit ^9 From 2112cd073310e9a4eb536a32933c303334730227 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:04:42 +1200 Subject: [PATCH 24/75] Update workflow --- tests/unit/Http/RouterTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 0d31f642..8177f5a4 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -42,6 +42,7 @@ public function setUp() { }))->will($this->returnSelf()); $this->_uri->expects($this->any())->method('getQuery')->will($this->returnCallback([$this, 'getResult'])); $this->_req->expects($this->any())->method('withUri')->will($this->returnSelf()); + $this->_uri->setResult(''); } public function testFourOhFour() { From 572f3d0a54fc97e980ec7168011eb56e704d7443 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:08:39 +1200 Subject: [PATCH 25/75] Update workflow --- tests/unit/Http/RouterTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 8177f5a4..0d31f642 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -42,7 +42,6 @@ public function setUp() { }))->will($this->returnSelf()); $this->_uri->expects($this->any())->method('getQuery')->will($this->returnCallback([$this, 'getResult'])); $this->_req->expects($this->any())->method('withUri')->will($this->returnSelf()); - $this->_uri->setResult(''); } public function testFourOhFour() { From be721b45cc52e29bb19def4ff5038eb81ed680a1 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:17:02 +1200 Subject: [PATCH 26/75] Update workflow --- tests/unit/Http/RouterTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 0d31f642..236a1db0 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -36,11 +36,13 @@ public function setUp() { $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); $this->_uri->expects($this->any())->method('withQuery')->with($this->callback(function($val) { - $this->setResult($val); + $this->query_string = $val; return true; }))->will($this->returnSelf()); - $this->_uri->expects($this->any())->method('getQuery')->will($this->returnCallback([$this, 'getResult'])); + $this->_uri->expects($this->any())->method('getQuery')->will($this->callback(function() { + return $this->query_string ?: ''; + })); $this->_req->expects($this->any())->method('withUri')->will($this->returnSelf()); } From a7ffaa1939d1d3e3e70daa2cbe8997aeb23b746a Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:19:13 +1200 Subject: [PATCH 27/75] Update workflow --- tests/unit/Http/RouterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 236a1db0..a3eea304 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -40,7 +40,7 @@ public function setUp() { return true; }))->will($this->returnSelf()); - $this->_uri->expects($this->any())->method('getQuery')->will($this->callback(function() { + $this->_uri->expects($this->any())->method('getQuery')->will($this->returnCallback(function() { return $this->query_string ?: ''; })); $this->_req->expects($this->any())->method('withUri')->will($this->returnSelf()); From e9d5aee12e80e3db02134b1d223c7370e88c72d9 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:22:35 +1200 Subject: [PATCH 28/75] Update workflow --- tests/unit/Http/RouterTest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index a3eea304..0a53b089 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -21,7 +21,17 @@ class RouterTest extends TestCase { public function setUp() { $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); - $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); + $uri = $this->getMock('Psr\Http\Message\UriInterface'); + $uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); + $uri->expects($this->any())->method('withQuery')->with($this->callback(function($val) use (&$uri) { + $uri->query_string = $val; + + return true; + }))->will($this->returnSelf()); + $uri->expects($this->any())->method('getQuery')->will($this->returnCallback(function() use (&$uri) { + return $uri->query_string ?: ''; + })); + $this->_uri = $uri; $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); $this->_req ->expects($this->any()) @@ -33,16 +43,6 @@ public function setUp() { ->method('getContext') ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))); $this->_router = new Router($this->_matcher); - - $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); - $this->_uri->expects($this->any())->method('withQuery')->with($this->callback(function($val) { - $this->query_string = $val; - - return true; - }))->will($this->returnSelf()); - $this->_uri->expects($this->any())->method('getQuery')->will($this->returnCallback(function() { - return $this->query_string ?: ''; - })); $this->_req->expects($this->any())->method('withUri')->will($this->returnSelf()); } From cf012e1f1e53d1197a7790758bac4873b58e01ea Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:31:55 +1200 Subject: [PATCH 29/75] Update workflow --- tests/unit/Http/RouterTest.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 0a53b089..297522eb 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -21,17 +21,7 @@ class RouterTest extends TestCase { public function setUp() { $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); - $uri = $this->getMock('Psr\Http\Message\UriInterface'); - $uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); - $uri->expects($this->any())->method('withQuery')->with($this->callback(function($val) use (&$uri) { - $uri->query_string = $val; - - return true; - }))->will($this->returnSelf()); - $uri->expects($this->any())->method('getQuery')->will($this->returnCallback(function() use (&$uri) { - return $uri->query_string ?: ''; - })); - $this->_uri = $uri; + $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); $this->_req ->expects($this->any()) @@ -43,6 +33,16 @@ public function setUp() { ->method('getContext') ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))); $this->_router = new Router($this->_matcher); + + $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); + $this->_uri->expects($this->any())->method('withQuery')->with($this->callback(function($val) { + $this->setResult($val); + + return true; + }))->will($this->returnSelf()); + $this->_uri->expects($this->any())->method('getQuery')->will($this->returnCallback(function() { + return $this->getResult() ?: ''; + })); $this->_req->expects($this->any())->method('withUri')->will($this->returnSelf()); } From 353284dd72cb4b46e78581179b6319155b58fce6 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:33:48 +1200 Subject: [PATCH 30/75] Update workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04b66018..dc9e9b70 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -37,13 +37,13 @@ jobs: phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.3 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 7.4 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 8.0 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^5 can-fail: false - php: 8.1 phpunit: phpunit/phpunit ^9 From 6bfc3fb104a9093900ed85a0cdbceb14ec8499df Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:35:24 +1200 Subject: [PATCH 31/75] Update workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc9e9b70..5b954619 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,13 +43,13 @@ jobs: phpunit: phpunit/phpunit ^5 can-fail: false - php: 8.0 - phpunit: phpunit/phpunit ^5 + phpunit: phpunit/phpunit ^8 can-fail: false - php: 8.1 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^8 can-fail: false - php: 8.2 - phpunit: phpunit/phpunit ^9 + phpunit: phpunit/phpunit ^8 can-fail: false steps: From e2ab1f2c006f59501052cca86ca11168200b0dd3 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:40:55 +1200 Subject: [PATCH 32/75] Update workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b954619..a6eb44aa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,13 +43,13 @@ jobs: phpunit: phpunit/phpunit ^5 can-fail: false - php: 8.0 - phpunit: phpunit/phpunit ^8 + phpunit: phpunit/phpunit ^7 can-fail: false - php: 8.1 - phpunit: phpunit/phpunit ^8 + phpunit: phpunit/phpunit ^7 can-fail: false - php: 8.2 - phpunit: phpunit/phpunit ^8 + phpunit: phpunit/phpunit ^7 can-fail: false steps: From ee9e32f34d84d1b8e45985da8a5ed2c37d3795c7 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 03:42:25 +1200 Subject: [PATCH 33/75] Update workflow --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6eb44aa..f2db8690 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,13 +43,13 @@ jobs: phpunit: phpunit/phpunit ^5 can-fail: false - php: 8.0 - phpunit: phpunit/phpunit ^7 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 8.1 - phpunit: phpunit/phpunit ^7 + phpunit: phpunit/phpunit ^9 can-fail: false - php: 8.2 - phpunit: phpunit/phpunit ^7 + phpunit: phpunit/phpunit ^9 can-fail: false steps: From 3eb5ebdc233c4121bcd0623f03b0cae228c5d174 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 13:23:17 +1200 Subject: [PATCH 34/75] Update test to use @before/@after annotations instead of setUp/tearDown --- .../Ratchet/AbstractMessageComponentTestCase.php | 5 ++++- tests/unit/AbstractConnectionDecoratorTest.php | 5 ++++- tests/unit/Http/HttpRequestParserTest.php | 5 ++++- tests/unit/Http/HttpServerTest.php | 7 +++++-- tests/unit/Http/OriginCheckTest.php | 7 +++++-- tests/unit/Http/RouterTest.php | 5 ++++- tests/unit/Server/EchoServerTest.php | 5 ++++- tests/unit/Server/FlashPolicyComponentTest.php | 5 ++++- tests/unit/Server/IoConnectionTest.php | 5 ++++- tests/unit/Server/IoServerTest.php | 5 ++++- tests/unit/Server/IpBlackListComponentTest.php | 5 ++++- tests/unit/Session/Serialize/PhpHandlerTest.php | 5 ++++- tests/unit/Session/SessionComponentTest.php | 12 +++++++++--- .../Session/Storage/VirtualSessionStoragePDOTest.php | 10 ++++++++-- tests/unit/Wamp/ServerProtocolTest.php | 5 ++++- tests/unit/Wamp/TopicManagerTest.php | 5 ++++- tests/unit/Wamp/WampConnectionTest.php | 5 ++++- 17 files changed, 79 insertions(+), 22 deletions(-) diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 7ea127ae..21190c72 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -11,7 +11,10 @@ abstract public function getConnectionClassString(); abstract public function getDecoratorClassString(); abstract public function getComponentClassString(); - public function setUp() { + /** + * @before + */ + public function before() { $this->_app = $this->getMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index aefe20c1..d1d8ac8d 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -12,7 +12,10 @@ class AbstractConnectionDecoratorTest extends TestCase { protected $l1; protected $l2; - public function setUp() { + /** + * @before + */ + public function before() { $this->mock = $this->getMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index 6bbec51e..db27eecd 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -9,7 +9,10 @@ class HttpRequestParserTest extends TestCase { protected $parser; - public function setUp() { + /** + * @before + */ + public function before() { $this->parser = new HttpRequestParser; } diff --git a/tests/unit/Http/HttpServerTest.php b/tests/unit/Http/HttpServerTest.php index 7041d66b..6aa70fed 100644 --- a/tests/unit/Http/HttpServerTest.php +++ b/tests/unit/Http/HttpServerTest.php @@ -6,8 +6,11 @@ * @covers Ratchet\Http\HttpServer */ class HttpServerTest extends AbstractMessageComponentTestCase { - public function setUp() { - parent::setUp(); + /** + * @before + */ + public function before() { + parent::before(); $this->_conn->httpHeadersReceived = true; } diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index c1c40120..97c2fd84 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -8,11 +8,14 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { protected $_reqStub; - public function setUp() { + /** + * @before + */ + public function before() { $this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); - parent::setUp(); + parent::before(); $this->_serv->allowedOrigins[] = 'localhost'; } diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 297522eb..4ea0fcc2 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -19,7 +19,10 @@ class RouterTest extends TestCase { protected $_uri; protected $_req; - public function setUp() { + /** + * @before + */ + public function before() { $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 92114f2c..6584ea17 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -7,7 +7,10 @@ class EchoServerTest extends TestCase { protected $_conn; protected $_comp; - public function setUp() { + /** + * @before + */ + public function before() { $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 51f86ddb..290a74f1 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -10,7 +10,10 @@ class FlashPolicyTest extends TestCase { protected $_policy; - public function setUp() { + /** + * @before + */ + public function before() { $this->_policy = new FlashPolicy(); } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index 60f4d36a..c54ff40c 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -10,7 +10,10 @@ class IoConnectionTest extends TestCase { protected $sock; protected $conn; - public function setUp() { + /** + * @before + */ + public function before() { $this->sock = $this->getMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index a4048df6..4480c09b 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -26,7 +26,10 @@ protected function tickLoop(LoopInterface $loop) { $loop->run(); } - public function setUp() { + /** + * @before + */ + public function before() { $this->app = $this->getMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index fea658e9..2d86e6f1 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -10,7 +10,10 @@ class IpBlackListTest extends TestCase { protected $blocker; protected $mock; - public function setUp() { + /** + * @before + */ + public function before() { $this->mock = $this->getMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } diff --git a/tests/unit/Session/Serialize/PhpHandlerTest.php b/tests/unit/Session/Serialize/PhpHandlerTest.php index 2a7586c4..fa5a90ce 100644 --- a/tests/unit/Session/Serialize/PhpHandlerTest.php +++ b/tests/unit/Session/Serialize/PhpHandlerTest.php @@ -9,7 +9,10 @@ class PhpHandlerTest extends TestCase { protected $_handler; - public function setUp() { + /** + * @before + */ + public function before() { $this->_handler = new PhpHandler; } diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index ea452db3..3611c788 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -10,18 +10,24 @@ * @covers Ratchet\Session\Storage\Proxy\VirtualProxy */ class SessionProviderTest extends AbstractMessageComponentTestCase { - public function setUp() { + /** + * @before + */ + public function before() { return $this->markTestIncomplete('Test needs to be updated for ini_set issue in PHP 7.2'); if (!class_exists('Symfony\Component\HttpFoundation\Session\Session')) { return $this->markTestSkipped('Dependency of Symfony HttpFoundation failed'); } - parent::setUp(); + parent::before(); $this->_serv = new SessionProvider($this->_app, new NullSessionHandler); } - public function tearDown() { + /** + * @after + */ + public function after() { ini_set('session.serialize_handler', 'php'); } diff --git a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php index 1f6466e6..2f028833 100644 --- a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php +++ b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php @@ -14,7 +14,10 @@ class VirtualSessionStoragePDOTest extends TestCase { protected $_pathToDB; - public function setUp() { + /** + * @before + */ + public function before() { if (!extension_loaded('PDO') || !extension_loaded('pdo_sqlite')) { return $this->markTestSkipped('Session test requires PDO and pdo_sqlite'); } @@ -42,7 +45,10 @@ public function setUp() { $this->_virtualSessionStorage->registerBag(new AttributeBag()); } - public function tearDown() { + /** + * @after + */ + public function after() { unlink($this->_pathToDB); } diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index f0762e20..82b74fbf 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -14,7 +14,10 @@ class ServerProtocolTest extends TestCase { protected $_app; - public function setUp() { + /** + * @before + */ + public function before() { $this->_app = new TestComponent; $this->_comp = new ServerProtocol($this->_app); } diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index b1eeac61..86f688fe 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -19,7 +19,10 @@ class TopicManagerTest extends TestCase { */ private $conn; - public function setUp() { + /** + * @before + */ + public function before() { $this->conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->mock = $this->getMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index 62f51d4a..aac57f3d 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -9,7 +9,10 @@ class WampConnectionTest extends TestCase { protected $conn; protected $mock; - public function setUp() { + /** + * @before + */ + public function before() { $this->mock = $this->getMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } From 1b8afc567fe699776958a1078d8f0f0f09ca91fa Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 13:54:31 +1200 Subject: [PATCH 35/75] Remove invalid configurations and add missing @covers --- phpunit.xml.dist | 7 ------- tests/unit/Server/EchoServerTest.php | 3 +++ .../unit/Session/Storage/VirtualSessionStoragePDOTest.php | 3 +++ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7f8d6fb4..d6057bc9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,7 +1,6 @@ ./tests/unit/ - - - - ./src/ - - diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 6584ea17..44384b14 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -3,6 +3,9 @@ use PHPUnit\Framework\TestCase; use Ratchet\Server\EchoServer; +/** + * @covers \Ratchet\Server\EchoServer + */ class EchoServerTest extends TestCase { protected $_conn; protected $_comp; diff --git a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php index 2f028833..137593a0 100644 --- a/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php +++ b/tests/unit/Session/Storage/VirtualSessionStoragePDOTest.php @@ -6,6 +6,9 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBag; use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; +/** + * @covers \Ratchet\Session\Storage\VirtualSessionStorage + */ class VirtualSessionStoragePDOTest extends TestCase { /** * @var VirtualSessionStorage From 203b09f397dc3dac85b629892ece2af56edd6466 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 13:58:04 +1200 Subject: [PATCH 36/75] Remove unused syntaxCheck from PHPUnit config --- phpunit.xml.dist | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d6057bc9..97dcf809 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,7 +5,6 @@ colors="true" backupGlobals="false" backupStaticAttributes="false" - syntaxCheck="false" stopOnError="false" > From f03ed0d3953467d1aec140eae3e168e8fe52db18 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:16:45 +1200 Subject: [PATCH 37/75] Remove usage of symfony/http-foundation >= 6 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4b908bb5..7ae23381 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ , "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5" , "react/event-loop": ">=0.4" , "guzzlehttp/psr7": "^1.7|^2.0" - , "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0" + , "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0" , "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" } , "require-dev": { From 6fa228f8c5985f0115abb862bb4036fdea1a8e95 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:22:27 +1200 Subject: [PATCH 38/75] Test switching to createMock --- tests/unit/AbstractConnectionDecoratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index d1d8ac8d..b0ce9132 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -16,7 +16,7 @@ class AbstractConnectionDecoratorTest extends TestCase { * @before */ public function before() { - $this->mock = $this->getMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->createMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); } From 672cac4498c4127ea99d67237e5e337a0fbe08d8 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:26:25 +1200 Subject: [PATCH 39/75] Test switching to expectedException --- tests/unit/AbstractConnectionDecoratorTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index b0ce9132..a3466c6e 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -135,17 +135,17 @@ public function testDecoratorRecursionLevel2() { } public function testWarningGettingNothing() { - $this->setExpectedException('PHPUnit_Framework_Error'); + $this->expectedException('PHPUnit_Framework_Error'); $var = $this->mock->nonExistant; } public function testWarningGettingNothingLevel1() { - $this->setExpectedException('PHPUnit_Framework_Error'); + $this->expectedException('PHPUnit_Framework_Error'); $var = $this->l1->nonExistant; } public function testWarningGettingNothingLevel2() { - $this->setExpectedException('PHPUnit_Framework_Error'); + $this->expectedException('PHPUnit_Framework_Error'); $var = $this->l2->nonExistant; } } From b7de82167c3cc8d6be6e93796fdeac1d2653ad61 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:39:55 +1200 Subject: [PATCH 40/75] Test switching to createMock --- .../AbstractMessageComponentTestCase.php | 6 +++--- tests/unit/AbstractConnectionDecoratorTest.php | 6 +++--- tests/unit/Http/HttpRequestParserTest.php | 4 ++-- tests/unit/Http/OriginCheckTest.php | 2 +- tests/unit/Http/RouterTest.php | 16 ++++++++-------- tests/unit/Server/EchoServerTest.php | 2 +- tests/unit/Server/FlashPolicyComponentTest.php | 8 ++++---- tests/unit/Server/IoConnectionTest.php | 2 +- tests/unit/Server/IoServerTest.php | 6 +++--- tests/unit/Server/IpBlackListComponentTest.php | 4 ++-- tests/unit/Session/SessionComponentTest.php | 16 ++++++++-------- tests/unit/Wamp/ServerProtocolTest.php | 2 +- tests/unit/Wamp/TopicManagerTest.php | 6 +++--- tests/unit/Wamp/TopicTest.php | 18 +++++++++--------- tests/unit/Wamp/WampConnectionTest.php | 4 ++-- 15 files changed, 51 insertions(+), 51 deletions(-) diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 21190c72..44fd58de 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -15,10 +15,10 @@ abstract public function getComponentClassString(); * @before */ public function before() { - $this->_app = $this->getMock($this->getComponentClassString()); + $this->_app = $this->createMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); - $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->createMock('\Ratchet\ConnectionInterface'); $this->doOpen($this->_conn); } @@ -33,7 +33,7 @@ public function isExpectedConnection() { public function testOpen() { $this->_app->expects($this->once())->method('onOpen')->with($this->isExpectedConnection()); - $this->doOpen($this->getMock('\Ratchet\ConnectionInterface')); + $this->doOpen($this->createMock('\Ratchet\ConnectionInterface')); } public function testOnClose() { diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index a3466c6e..b0ce9132 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -135,17 +135,17 @@ public function testDecoratorRecursionLevel2() { } public function testWarningGettingNothing() { - $this->expectedException('PHPUnit_Framework_Error'); + $this->setExpectedException('PHPUnit_Framework_Error'); $var = $this->mock->nonExistant; } public function testWarningGettingNothingLevel1() { - $this->expectedException('PHPUnit_Framework_Error'); + $this->setExpectedException('PHPUnit_Framework_Error'); $var = $this->l1->nonExistant; } public function testWarningGettingNothingLevel2() { - $this->expectedException('PHPUnit_Framework_Error'); + $this->setExpectedException('PHPUnit_Framework_Error'); $var = $this->l2->nonExistant; } } diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index db27eecd..353bf51e 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -35,7 +35,7 @@ public function testIsEom($expected, $message) { } public function testBufferOverflowResponse() { - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->createMock('\Ratchet\ConnectionInterface'); $this->parser->maxSize = 20; @@ -47,7 +47,7 @@ public function testBufferOverflowResponse() { } public function testReturnTypeIsRequest() { - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->createMock('\Ratchet\ConnectionInterface'); $return = $this->parser->onMessage($conn, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n"); $this->assertInstanceOf('\Psr\Http\Message\RequestInterface', $return); diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index 97c2fd84..af07cdf7 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -12,7 +12,7 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { * @before */ public function before() { - $this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface'); + $this->_reqStub = $this->createMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); parent::before(); diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 4ea0fcc2..e0cfa80e 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -23,18 +23,18 @@ class RouterTest extends TestCase { * @before */ public function before() { - $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); - $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); - $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); + $this->_conn = $this->createMock('\Ratchet\ConnectionInterface'); + $this->_uri = $this->createMock('Psr\Http\Message\UriInterface'); + $this->_req = $this->createMock('\Psr\Http\Message\RequestInterface'); $this->_req ->expects($this->any()) ->method('getUri') ->will($this->returnValue($this->_uri)); - $this->_matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $this->_matcher = $this->createMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $this->_matcher ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))); + ->will($this->returnValue($this->createMock('Symfony\Component\Routing\RequestContext'))); $this->_router = new Router($this->_matcher); $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); @@ -117,7 +117,7 @@ public function testRouterGeneratesRouteParameters() { $this->_matcher->expects($this->any())->method('match')->will( $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->getMock('Ratchet\Mock\Connection'); + $conn = $this->createMock('Ratchet\Mock\Connection'); $router = new Router($this->_matcher); @@ -132,8 +132,8 @@ public function testQueryParams() { $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->getMock('Ratchet\Mock\Connection'); - $request = $this->getMock('Psr\Http\Message\RequestInterface'); + $conn = $this->createMock('Ratchet\Mock\Connection'); + $request = $this->createMock('Psr\Http\Message\RequestInterface'); $uri = new \GuzzleHttp\Psr7\Uri('ws://doesnt.matter/endpoint?hello=world&foo=nope'); $request->expects($this->any())->method('getUri')->will($this->returnCallback(function() use (&$uri) { diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 44384b14..a7c06252 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -14,7 +14,7 @@ class EchoServerTest extends TestCase { * @before */ public function before() { - $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->createMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 290a74f1..8abfae85 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -127,7 +127,7 @@ public function testSetSiteControlThrowsException() { } public function testErrorClosesConnection() { - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('close'); $this->_policy->onError($conn, new \Exception); @@ -136,7 +136,7 @@ public function testErrorClosesConnection() { public function testOnMessageSendsString() { $this->_policy->addAllowedAccess('*', '*'); - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('send')->with($this->isType('string')); $this->_policy->onMessage($conn, ' '); @@ -144,13 +144,13 @@ public function testOnMessageSendsString() { public function testOnOpenExists() { $this->assertTrue(method_exists($this->_policy, 'onOpen')); - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->createMock('\Ratchet\ConnectionInterface'); $this->_policy->onOpen($conn); } public function testOnCloseExists() { $this->assertTrue(method_exists($this->_policy, 'onClose')); - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->createMock('\Ratchet\ConnectionInterface'); $this->_policy->onClose($conn); } } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index c54ff40c..766ce1ac 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -14,7 +14,7 @@ class IoConnectionTest extends TestCase { * @before */ public function before() { - $this->sock = $this->getMock('\\React\\Socket\\ConnectionInterface'); + $this->sock = $this->createMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 4480c09b..6908e17e 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -30,7 +30,7 @@ protected function tickLoop(LoopInterface $loop) { * @before */ public function before() { - $this->app = $this->getMock('\\Ratchet\\MessageComponentInterface'); + $this->app = $this->createMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; $this->reactor = new Server(0, $loop); @@ -107,7 +107,7 @@ public function testNoLoopProvidedError() { } public function testOnErrorPassesException() { - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); $err = new \Exception("Nope"); $this->app->expects($this->once())->method('onError')->with($conn, $err); @@ -118,7 +118,7 @@ public function testOnErrorPassesException() { public function onErrorCalledWhenExceptionThrown() { $this->markTestIncomplete("Need to learn how to throw an exception from a mock"); - $conn = $this->getMock('\\React\\Socket\\ConnectionInterface'); + $conn = $this->createMock('\\React\\Socket\\ConnectionInterface'); $this->server->handleConnect($conn); $e = new \Exception; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index 2d86e6f1..f4cec3c4 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -14,7 +14,7 @@ class IpBlackListTest extends TestCase { * @before */ public function before() { - $this->mock = $this->getMock('\\Ratchet\\MessageComponentInterface'); + $this->mock = $this->createMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } @@ -121,7 +121,7 @@ public function testUnblockingSilentlyFails() { } protected function newConn() { - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); $conn->remoteAddress = '127.0.0.1'; return $conn; diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index 3611c788..95cbf6d6 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -58,7 +58,7 @@ public function testToClassCase($in, $out) { $method = $ref->getMethod('toClassCase'); $method->setAccessible(true); - $component = new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface')); + $component = new SessionProvider($this->createMock($this->getComponentClassString()), $this->createMock('\SessionHandlerInterface')); $this->assertEquals($out, $method->invokeArgs($component, array($in))); } @@ -87,10 +87,10 @@ public function testConnectionValueFromPdo() { $pdoHandler = new PdoSessionHandler($pdo, $dbOptions); $pdoHandler->write($sessionId, '_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'); - $component = new SessionProvider($this->getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); - $connection = $this->getMock('Ratchet\\ConnectionInterface'); + $component = new SessionProvider($this->createMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); + $connection = $this->createMock('Ratchet\\ConnectionInterface'); - $headers = $this->getMock('Psr\Http\Message\RequestInterface'); + $headers = $this->createMock('Psr\Http\Message\RequestInterface'); $headers->expects($this->once())->method('getHeader')->will($this->returnValue([ini_get('session.name') . "={$sessionId};"])); $component->onOpen($connection, $headers); @@ -99,9 +99,9 @@ public function testConnectionValueFromPdo() { } protected function newConn() { - $conn = $this->getMock('Ratchet\ConnectionInterface'); + $conn = $this->createMock('Ratchet\ConnectionInterface'); - $headers = $this->getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); + $headers = $this->createMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null)); return $conn; @@ -120,11 +120,11 @@ public function testRejectInvalidSeralizers() { ini_set('session.serialize_handler', 'wddx'); $this->setExpectedException('\RuntimeException'); - new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface')); + new SessionProvider($this->createMock($this->getComponentClassString()), $this->createMock('\SessionHandlerInterface')); } protected function doOpen($conn) { - $request = $this->getMock('Psr\Http\Message\RequestInterface'); + $request = $this->createMock('Psr\Http\Message\RequestInterface'); $request->expects($this->any())->method('getHeader')->will($this->returnValue([])); $this->_serv->onOpen($conn, $request); diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index 82b74fbf..57e2b4fd 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -245,7 +245,7 @@ public function testGetSubProtocolsGetFromApp() { } public function testWampOnMessageApp() { - $app = $this->getMock('\\Ratchet\\Wamp\\WampServerInterface'); + $app = $this->createMock('\\Ratchet\\Wamp\\WampServerInterface'); $wamp = new ServerProtocol($app); $this->assertContains('wamp', $wamp->getSubProtocols()); diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index 86f688fe..02762e71 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -23,8 +23,8 @@ class TopicManagerTest extends TestCase { * @before */ public function before() { - $this->conn = $this->getMock('\Ratchet\ConnectionInterface'); - $this->mock = $this->getMock('\Ratchet\Wamp\WampServerInterface'); + $this->conn = $this->createMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->createMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); $this->conn->WAMP = new \StdClass; @@ -222,7 +222,7 @@ public function testGetSubProtocolsReturnsArray() { public function testGetSubProtocolsBubbles() { $subs = array('hello', 'world'); - $app = $this->getMock('Ratchet\Wamp\Stub\WsWampServerInterface'); + $app = $this->createMock('Ratchet\Wamp\Stub\WsWampServerInterface'); $app->expects($this->once())->method('getSubProtocols')->will($this->returnValue($subs)); $mngr = new TopicManager($app); diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index 6f77a01a..d1a990a3 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -41,8 +41,8 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -64,9 +64,9 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -91,9 +91,9 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -160,6 +160,6 @@ public function testDoesNotHaveAfterRemove() { } protected function newConn() { - return new WampConnection($this->getMock('\\Ratchet\\ConnectionInterface')); + return new WampConnection($this->createMock('\\Ratchet\\ConnectionInterface')); } } diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index aac57f3d..76cd25f1 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -13,7 +13,7 @@ class WampConnectionTest extends TestCase { * @before */ public function before() { - $this->mock = $this->getMock('\\Ratchet\\ConnectionInterface'); + $this->mock = $this->createMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } @@ -71,7 +71,7 @@ public function testGetUriWhenNoCurieGiven() { } public function testClose() { - $mock = $this->getMock('\\Ratchet\\ConnectionInterface'); + $mock = $this->createMock('\\Ratchet\\ConnectionInterface'); $conn = new WampConnection($mock); $mock->expects($this->once())->method('close'); From 5bbdaa3e3d5c8174d7b76d558fdc350ffde9e171 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:46:11 +1200 Subject: [PATCH 41/75] Revert to getMock --- .../AbstractMessageComponentTestCase.php | 6 +++--- tests/unit/Http/HttpRequestParserTest.php | 4 ++-- tests/unit/Http/OriginCheckTest.php | 2 +- tests/unit/Http/RouterTest.php | 16 ++++++++-------- tests/unit/Server/EchoServerTest.php | 2 +- tests/unit/Server/FlashPolicyComponentTest.php | 8 ++++---- tests/unit/Server/IoConnectionTest.php | 2 +- tests/unit/Server/IoServerTest.php | 6 +++--- tests/unit/Server/IpBlackListComponentTest.php | 4 ++-- tests/unit/Session/SessionComponentTest.php | 16 ++++++++-------- tests/unit/Wamp/ServerProtocolTest.php | 2 +- tests/unit/Wamp/TopicManagerTest.php | 6 +++--- tests/unit/Wamp/TopicTest.php | 18 +++++++++--------- tests/unit/Wamp/WampConnectionTest.php | 4 ++-- 14 files changed, 48 insertions(+), 48 deletions(-) diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 44fd58de..21190c72 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -15,10 +15,10 @@ abstract public function getComponentClassString(); * @before */ public function before() { - $this->_app = $this->createMock($this->getComponentClassString()); + $this->_app = $this->getMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); - $this->_conn = $this->createMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->doOpen($this->_conn); } @@ -33,7 +33,7 @@ public function isExpectedConnection() { public function testOpen() { $this->_app->expects($this->once())->method('onOpen')->with($this->isExpectedConnection()); - $this->doOpen($this->createMock('\Ratchet\ConnectionInterface')); + $this->doOpen($this->getMock('\Ratchet\ConnectionInterface')); } public function testOnClose() { diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index 353bf51e..db27eecd 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -35,7 +35,7 @@ public function testIsEom($expected, $message) { } public function testBufferOverflowResponse() { - $conn = $this->createMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->parser->maxSize = 20; @@ -47,7 +47,7 @@ public function testBufferOverflowResponse() { } public function testReturnTypeIsRequest() { - $conn = $this->createMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMock('\Ratchet\ConnectionInterface'); $return = $this->parser->onMessage($conn, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n"); $this->assertInstanceOf('\Psr\Http\Message\RequestInterface', $return); diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index af07cdf7..97c2fd84 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -12,7 +12,7 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { * @before */ public function before() { - $this->_reqStub = $this->createMock('Psr\Http\Message\RequestInterface'); + $this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); parent::before(); diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index e0cfa80e..4ea0fcc2 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -23,18 +23,18 @@ class RouterTest extends TestCase { * @before */ public function before() { - $this->_conn = $this->createMock('\Ratchet\ConnectionInterface'); - $this->_uri = $this->createMock('Psr\Http\Message\UriInterface'); - $this->_req = $this->createMock('\Psr\Http\Message\RequestInterface'); + $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); + $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); $this->_req ->expects($this->any()) ->method('getUri') ->will($this->returnValue($this->_uri)); - $this->_matcher = $this->createMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $this->_matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $this->_matcher ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->createMock('Symfony\Component\Routing\RequestContext'))); + ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))); $this->_router = new Router($this->_matcher); $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); @@ -117,7 +117,7 @@ public function testRouterGeneratesRouteParameters() { $this->_matcher->expects($this->any())->method('match')->will( $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->createMock('Ratchet\Mock\Connection'); + $conn = $this->getMock('Ratchet\Mock\Connection'); $router = new Router($this->_matcher); @@ -132,8 +132,8 @@ public function testQueryParams() { $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->createMock('Ratchet\Mock\Connection'); - $request = $this->createMock('Psr\Http\Message\RequestInterface'); + $conn = $this->getMock('Ratchet\Mock\Connection'); + $request = $this->getMock('Psr\Http\Message\RequestInterface'); $uri = new \GuzzleHttp\Psr7\Uri('ws://doesnt.matter/endpoint?hello=world&foo=nope'); $request->expects($this->any())->method('getUri')->will($this->returnCallback(function() use (&$uri) { diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index a7c06252..44384b14 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -14,7 +14,7 @@ class EchoServerTest extends TestCase { * @before */ public function before() { - $this->_conn = $this->createMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 8abfae85..290a74f1 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -127,7 +127,7 @@ public function testSetSiteControlThrowsException() { } public function testErrorClosesConnection() { - $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('close'); $this->_policy->onError($conn, new \Exception); @@ -136,7 +136,7 @@ public function testErrorClosesConnection() { public function testOnMessageSendsString() { $this->_policy->addAllowedAccess('*', '*'); - $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('send')->with($this->isType('string')); $this->_policy->onMessage($conn, ' '); @@ -144,13 +144,13 @@ public function testOnMessageSendsString() { public function testOnOpenExists() { $this->assertTrue(method_exists($this->_policy, 'onOpen')); - $conn = $this->createMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_policy->onOpen($conn); } public function testOnCloseExists() { $this->assertTrue(method_exists($this->_policy, 'onClose')); - $conn = $this->createMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMock('\Ratchet\ConnectionInterface'); $this->_policy->onClose($conn); } } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index 766ce1ac..c54ff40c 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -14,7 +14,7 @@ class IoConnectionTest extends TestCase { * @before */ public function before() { - $this->sock = $this->createMock('\\React\\Socket\\ConnectionInterface'); + $this->sock = $this->getMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 6908e17e..4480c09b 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -30,7 +30,7 @@ protected function tickLoop(LoopInterface $loop) { * @before */ public function before() { - $this->app = $this->createMock('\\Ratchet\\MessageComponentInterface'); + $this->app = $this->getMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; $this->reactor = new Server(0, $loop); @@ -107,7 +107,7 @@ public function testNoLoopProvidedError() { } public function testOnErrorPassesException() { - $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); $err = new \Exception("Nope"); $this->app->expects($this->once())->method('onError')->with($conn, $err); @@ -118,7 +118,7 @@ public function testOnErrorPassesException() { public function onErrorCalledWhenExceptionThrown() { $this->markTestIncomplete("Need to learn how to throw an exception from a mock"); - $conn = $this->createMock('\\React\\Socket\\ConnectionInterface'); + $conn = $this->getMock('\\React\\Socket\\ConnectionInterface'); $this->server->handleConnect($conn); $e = new \Exception; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index f4cec3c4..2d86e6f1 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -14,7 +14,7 @@ class IpBlackListTest extends TestCase { * @before */ public function before() { - $this->mock = $this->createMock('\\Ratchet\\MessageComponentInterface'); + $this->mock = $this->getMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } @@ -121,7 +121,7 @@ public function testUnblockingSilentlyFails() { } protected function newConn() { - $conn = $this->createMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); $conn->remoteAddress = '127.0.0.1'; return $conn; diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index 95cbf6d6..3611c788 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -58,7 +58,7 @@ public function testToClassCase($in, $out) { $method = $ref->getMethod('toClassCase'); $method->setAccessible(true); - $component = new SessionProvider($this->createMock($this->getComponentClassString()), $this->createMock('\SessionHandlerInterface')); + $component = new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface')); $this->assertEquals($out, $method->invokeArgs($component, array($in))); } @@ -87,10 +87,10 @@ public function testConnectionValueFromPdo() { $pdoHandler = new PdoSessionHandler($pdo, $dbOptions); $pdoHandler->write($sessionId, '_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'); - $component = new SessionProvider($this->createMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); - $connection = $this->createMock('Ratchet\\ConnectionInterface'); + $component = new SessionProvider($this->getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); + $connection = $this->getMock('Ratchet\\ConnectionInterface'); - $headers = $this->createMock('Psr\Http\Message\RequestInterface'); + $headers = $this->getMock('Psr\Http\Message\RequestInterface'); $headers->expects($this->once())->method('getHeader')->will($this->returnValue([ini_get('session.name') . "={$sessionId};"])); $component->onOpen($connection, $headers); @@ -99,9 +99,9 @@ public function testConnectionValueFromPdo() { } protected function newConn() { - $conn = $this->createMock('Ratchet\ConnectionInterface'); + $conn = $this->getMock('Ratchet\ConnectionInterface'); - $headers = $this->createMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); + $headers = $this->getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null)); return $conn; @@ -120,11 +120,11 @@ public function testRejectInvalidSeralizers() { ini_set('session.serialize_handler', 'wddx'); $this->setExpectedException('\RuntimeException'); - new SessionProvider($this->createMock($this->getComponentClassString()), $this->createMock('\SessionHandlerInterface')); + new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface')); } protected function doOpen($conn) { - $request = $this->createMock('Psr\Http\Message\RequestInterface'); + $request = $this->getMock('Psr\Http\Message\RequestInterface'); $request->expects($this->any())->method('getHeader')->will($this->returnValue([])); $this->_serv->onOpen($conn, $request); diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index 57e2b4fd..82b74fbf 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -245,7 +245,7 @@ public function testGetSubProtocolsGetFromApp() { } public function testWampOnMessageApp() { - $app = $this->createMock('\\Ratchet\\Wamp\\WampServerInterface'); + $app = $this->getMock('\\Ratchet\\Wamp\\WampServerInterface'); $wamp = new ServerProtocol($app); $this->assertContains('wamp', $wamp->getSubProtocols()); diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index 02762e71..86f688fe 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -23,8 +23,8 @@ class TopicManagerTest extends TestCase { * @before */ public function before() { - $this->conn = $this->createMock('\Ratchet\ConnectionInterface'); - $this->mock = $this->createMock('\Ratchet\Wamp\WampServerInterface'); + $this->conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->getMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); $this->conn->WAMP = new \StdClass; @@ -222,7 +222,7 @@ public function testGetSubProtocolsReturnsArray() { public function testGetSubProtocolsBubbles() { $subs = array('hello', 'world'); - $app = $this->createMock('Ratchet\Wamp\Stub\WsWampServerInterface'); + $app = $this->getMock('Ratchet\Wamp\Stub\WsWampServerInterface'); $app->expects($this->once())->method('getSubProtocols')->will($this->returnValue($subs)); $mngr = new TopicManager($app); diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index d1a990a3..6f77a01a 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -41,8 +41,8 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -64,9 +64,9 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -91,9 +91,9 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->createMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->createMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -160,6 +160,6 @@ public function testDoesNotHaveAfterRemove() { } protected function newConn() { - return new WampConnection($this->createMock('\\Ratchet\\ConnectionInterface')); + return new WampConnection($this->getMock('\\Ratchet\\ConnectionInterface')); } } diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index 76cd25f1..aac57f3d 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -13,7 +13,7 @@ class WampConnectionTest extends TestCase { * @before */ public function before() { - $this->mock = $this->createMock('\\Ratchet\\ConnectionInterface'); + $this->mock = $this->getMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } @@ -71,7 +71,7 @@ public function testGetUriWhenNoCurieGiven() { } public function testClose() { - $mock = $this->createMock('\\Ratchet\\ConnectionInterface'); + $mock = $this->getMock('\\Ratchet\\ConnectionInterface'); $conn = new WampConnection($mock); $mock->expects($this->once())->method('close'); From 51f73d32cb433f060e4353e99dc27337a2f2e27c Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:48:10 +1200 Subject: [PATCH 42/75] Revert to getMock --- tests/unit/AbstractConnectionDecoratorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index b0ce9132..d1d8ac8d 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -16,7 +16,7 @@ class AbstractConnectionDecoratorTest extends TestCase { * @before */ public function before() { - $this->mock = $this->createMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->getMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); } From 395352794a14027824405ec15f3b88f853b0fafb Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 14:50:11 +1200 Subject: [PATCH 43/75] Update checkout version --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2db8690..c9a0434a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: steps: - name: "Checkout" - uses: "actions/checkout@v2" + uses: "actions/checkout@v3" with: fetch-depth: 2 From eba9487fb30328e7c6754c89a98798a1d218c913 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 15:18:26 +1200 Subject: [PATCH 44/75] Test extended testcase to allow switching between getMock/createMock --- tests/RatchetTestCase.php | 24 +++++++++++++++++++ .../unit/AbstractConnectionDecoratorTest.php | 5 ++-- 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 tests/RatchetTestCase.php diff --git a/tests/RatchetTestCase.php b/tests/RatchetTestCase.php new file mode 100644 index 00000000..cf7bcbcc --- /dev/null +++ b/tests/RatchetTestCase.php @@ -0,0 +1,24 @@ +_version() < 9) { + return call_user_func_array([$this, 'getMock'], $params); + } else { + return call_user_func_array([$this, 'createMock'], $params); + } + } +} diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index d1d8ac8d..c17ab9ce 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -1,13 +1,12 @@ mock = $this->getMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->_getMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); } From f662dfd666291d89cbe1905d0f8dbc22cea058c3 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 15:21:39 +1200 Subject: [PATCH 45/75] Test extended testcase to allow switching between getMock/createMock --- tests/{ => helpers/Ratchet}/RatchetTestCase.php | 0 tests/unit/AbstractConnectionDecoratorTest.php | 1 + 2 files changed, 1 insertion(+) rename tests/{ => helpers/Ratchet}/RatchetTestCase.php (100%) diff --git a/tests/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php similarity index 100% rename from tests/RatchetTestCase.php rename to tests/helpers/Ratchet/RatchetTestCase.php diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index c17ab9ce..c110790b 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -1,5 +1,6 @@ Date: Sun, 14 May 2023 15:49:22 +1200 Subject: [PATCH 46/75] Test extended testcase to allow switching between getMock/createMock --- composer.json | 2 +- .../AbstractMessageComponentTestCase.php | 10 ++++---- tests/helpers/Ratchet/RatchetTestCase.php | 10 ++++++++ .../unit/AbstractConnectionDecoratorTest.php | 6 ++--- tests/unit/Http/HttpRequestParserTest.php | 10 ++++---- tests/unit/Http/OriginCheckTest.php | 2 +- tests/unit/Http/RouterTest.php | 24 +++++++++---------- tests/unit/Server/EchoServerTest.php | 6 ++--- .../unit/Server/FlashPolicyComponentTest.php | 20 ++++++++-------- tests/unit/Server/IoConnectionTest.php | 6 ++--- tests/unit/Server/IoServerTest.php | 12 +++++----- .../unit/Server/IpBlackListComponentTest.php | 8 +++---- tests/unit/Session/SessionComponentTest.php | 18 +++++++------- tests/unit/Wamp/ServerProtocolTest.php | 18 +++++++------- tests/unit/Wamp/TopicManagerTest.php | 10 ++++---- tests/unit/Wamp/TopicTest.php | 23 +++++++++--------- tests/unit/Wamp/WampConnectionTest.php | 8 +++---- 17 files changed, 101 insertions(+), 92 deletions(-) diff --git a/composer.json b/composer.json index 7ae23381..f695bbed 100644 --- a/composer.json +++ b/composer.json @@ -35,6 +35,6 @@ , "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" } , "require-dev": { - "phpunit/phpunit": "^4.8" + "phpunit/phpunit": "^9" } } diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 21190c72..987262ed 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -1,8 +1,8 @@ _app = $this->getMock($this->getComponentClassString()); + $this->_app = $this->_getMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); - $this->_conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->doOpen($this->_conn); } @@ -33,7 +33,7 @@ public function isExpectedConnection() { public function testOpen() { $this->_app->expects($this->once())->method('onOpen')->with($this->isExpectedConnection()); - $this->doOpen($this->getMock('\Ratchet\ConnectionInterface')); + $this->doOpen($this->_getMock('\Ratchet\ConnectionInterface')); } public function testOnClose() { diff --git a/tests/helpers/Ratchet/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php index cf7bcbcc..27ba700e 100644 --- a/tests/helpers/Ratchet/RatchetTestCase.php +++ b/tests/helpers/Ratchet/RatchetTestCase.php @@ -21,4 +21,14 @@ public function _getMock() { return call_user_func_array([$this, 'createMock'], $params); } } + + public function _setExpectedException() { + $num_params = func_num_args(); + $params = func_get_args(); + if ($this->_version() < 9) { + call_user_func_array([$this, 'setExpectedException'], $params); + } else { + call_user_func_array([$this, 'expectException'], $params); + } + } } diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index c110790b..fbca7d26 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -135,17 +135,17 @@ public function testDecoratorRecursionLevel2() { } public function testWarningGettingNothing() { - $this->setExpectedException('PHPUnit_Framework_Error'); + $this->_setExpectedException('PHPUnit_Framework_Error'); $var = $this->mock->nonExistant; } public function testWarningGettingNothingLevel1() { - $this->setExpectedException('PHPUnit_Framework_Error'); + $this->_setExpectedException('PHPUnit_Framework_Error'); $var = $this->l1->nonExistant; } public function testWarningGettingNothingLevel2() { - $this->setExpectedException('PHPUnit_Framework_Error'); + $this->_setExpectedException('PHPUnit_Framework_Error'); $var = $this->l2->nonExistant; } } diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index db27eecd..dcd36551 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -1,12 +1,12 @@ getMock('\Ratchet\ConnectionInterface'); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->parser->maxSize = 20; $this->assertNull($this->parser->onMessage($conn, "GET / HTTP/1.1\r\n")); - $this->setExpectedException('OverflowException'); + $this->_setExpectedException('OverflowException'); $this->parser->onMessage($conn, "Header-Is: Too Big"); } public function testReturnTypeIsRequest() { - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $return = $this->parser->onMessage($conn, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n"); $this->assertInstanceOf('\Psr\Http\Message\RequestInterface', $return); diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index 97c2fd84..78367647 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -12,7 +12,7 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { * @before */ public function before() { - $this->_reqStub = $this->getMock('Psr\Http\Message\RequestInterface'); + $this->_reqStub = $this->_getMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); parent::before(); diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 4ea0fcc2..c36bf40e 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -1,6 +1,6 @@ _conn = $this->getMock('\Ratchet\ConnectionInterface'); - $this->_uri = $this->getMock('Psr\Http\Message\UriInterface'); - $this->_req = $this->getMock('\Psr\Http\Message\RequestInterface'); + $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $this->_uri = $this->_getMock('Psr\Http\Message\UriInterface'); + $this->_req = $this->_getMock('\Psr\Http\Message\RequestInterface'); $this->_req ->expects($this->any()) ->method('getUri') ->will($this->returnValue($this->_uri)); - $this->_matcher = $this->getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $this->_matcher = $this->_getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $this->_matcher ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMock('Symfony\Component\Routing\RequestContext'))); + ->will($this->returnValue($this->_getMock('Symfony\Component\Routing\RequestContext'))); $this->_router = new Router($this->_matcher); $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); @@ -59,12 +59,12 @@ public function testFourOhFour() { } public function testNullRequest() { - $this->setExpectedException('\UnexpectedValueException'); + $this->_setExpectedException('\UnexpectedValueException'); $this->_router->onOpen($this->_conn); } public function testControllerIsMessageComponentInterface() { - $this->setExpectedException('\UnexpectedValueException'); + $this->_setExpectedException('\UnexpectedValueException'); $this->_matcher->expects($this->any())->method('match')->will($this->returnValue(array('_controller' => new \StdClass))); $this->_router->onOpen($this->_conn, $this->_req); } @@ -117,7 +117,7 @@ public function testRouterGeneratesRouteParameters() { $this->_matcher->expects($this->any())->method('match')->will( $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->getMock('Ratchet\Mock\Connection'); + $conn = $this->_getMock('Ratchet\Mock\Connection'); $router = new Router($this->_matcher); @@ -132,8 +132,8 @@ public function testQueryParams() { $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->getMock('Ratchet\Mock\Connection'); - $request = $this->getMock('Psr\Http\Message\RequestInterface'); + $conn = $this->_getMock('Ratchet\Mock\Connection'); + $request = $this->_getMock('Psr\Http\Message\RequestInterface'); $uri = new \GuzzleHttp\Psr7\Uri('ws://doesnt.matter/endpoint?hello=world&foo=nope'); $request->expects($this->any())->method('getUri')->will($this->returnCallback(function() use (&$uri) { diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 44384b14..42b118e7 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -1,12 +1,12 @@ _conn = $this->getMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 290a74f1..63088743 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -1,12 +1,12 @@ setExpectedException('UnexpectedValueException'); + $this->_setExpectedException('UnexpectedValueException'); $this->_policy->renderPolicy(); } public function testInvalidDomainPolicyReader() { - $this->setExpectedException('UnexpectedValueException'); + $this->_setExpectedException('UnexpectedValueException'); $this->_policy->setSiteControl('all'); $this->_policy->addAllowedAccess('dev.example.*', '*'); $this->_policy->renderPolicy(); @@ -115,19 +115,19 @@ public static function ports() { } public function testAddAllowedAccessOnlyAcceptsValidPorts() { - $this->setExpectedException('UnexpectedValueException'); + $this->_setExpectedException('UnexpectedValueException'); $this->_policy->addAllowedAccess('*', 'nope'); } public function testSetSiteControlThrowsException() { - $this->setExpectedException('UnexpectedValueException'); + $this->_setExpectedException('UnexpectedValueException'); $this->_policy->setSiteControl('nope'); } public function testErrorClosesConnection() { - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('close'); $this->_policy->onError($conn, new \Exception); @@ -136,7 +136,7 @@ public function testErrorClosesConnection() { public function testOnMessageSendsString() { $this->_policy->addAllowedAccess('*', '*'); - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('send')->with($this->isType('string')); $this->_policy->onMessage($conn, ' '); @@ -144,13 +144,13 @@ public function testOnMessageSendsString() { public function testOnOpenExists() { $this->assertTrue(method_exists($this->_policy, 'onOpen')); - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->_policy->onOpen($conn); } public function testOnCloseExists() { $this->assertTrue(method_exists($this->_policy, 'onClose')); - $conn = $this->getMock('\Ratchet\ConnectionInterface'); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->_policy->onClose($conn); } } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index c54ff40c..fc843367 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -1,12 +1,12 @@ sock = $this->getMock('\\React\\Socket\\ConnectionInterface'); + $this->sock = $this->_getMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 4480c09b..d07637a2 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -1,6 +1,6 @@ app = $this->getMock('\\Ratchet\\MessageComponentInterface'); + $this->app = $this->_getMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; $this->reactor = new Server(0, $loop); @@ -100,14 +100,14 @@ public function testFactory() { } public function testNoLoopProvidedError() { - $this->setExpectedException('RuntimeException'); + $this->_setExpectedException('RuntimeException'); $io = new IoServer($this->app, $this->reactor); $io->run(); } public function testOnErrorPassesException() { - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $err = new \Exception("Nope"); $this->app->expects($this->once())->method('onError')->with($conn, $err); @@ -118,7 +118,7 @@ public function testOnErrorPassesException() { public function onErrorCalledWhenExceptionThrown() { $this->markTestIncomplete("Need to learn how to throw an exception from a mock"); - $conn = $this->getMock('\\React\\Socket\\ConnectionInterface'); + $conn = $this->_getMock('\\React\\Socket\\ConnectionInterface'); $this->server->handleConnect($conn); $e = new \Exception; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index 2d86e6f1..482d9bcf 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -1,12 +1,12 @@ mock = $this->getMock('\\Ratchet\\MessageComponentInterface'); + $this->mock = $this->_getMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } @@ -121,7 +121,7 @@ public function testUnblockingSilentlyFails() { } protected function newConn() { - $conn = $this->getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn->remoteAddress = '127.0.0.1'; return $conn; diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index 3611c788..3c5bbd38 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -58,7 +58,7 @@ public function testToClassCase($in, $out) { $method = $ref->getMethod('toClassCase'); $method->setAccessible(true); - $component = new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface')); + $component = new SessionProvider($this->_getMock($this->getComponentClassString()), $this->_getMock('\SessionHandlerInterface')); $this->assertEquals($out, $method->invokeArgs($component, array($in))); } @@ -87,10 +87,10 @@ public function testConnectionValueFromPdo() { $pdoHandler = new PdoSessionHandler($pdo, $dbOptions); $pdoHandler->write($sessionId, '_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'); - $component = new SessionProvider($this->getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); - $connection = $this->getMock('Ratchet\\ConnectionInterface'); + $component = new SessionProvider($this->_getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); + $connection = $this->_getMock('Ratchet\\ConnectionInterface'); - $headers = $this->getMock('Psr\Http\Message\RequestInterface'); + $headers = $this->_getMock('Psr\Http\Message\RequestInterface'); $headers->expects($this->once())->method('getHeader')->will($this->returnValue([ini_get('session.name') . "={$sessionId};"])); $component->onOpen($connection, $headers); @@ -99,9 +99,9 @@ public function testConnectionValueFromPdo() { } protected function newConn() { - $conn = $this->getMock('Ratchet\ConnectionInterface'); + $conn = $this->_getMock('Ratchet\ConnectionInterface'); - $headers = $this->getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); + $headers = $this->_getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null)); return $conn; @@ -119,12 +119,12 @@ public function testRejectInvalidSeralizers() { } ini_set('session.serialize_handler', 'wddx'); - $this->setExpectedException('\RuntimeException'); - new SessionProvider($this->getMock($this->getComponentClassString()), $this->getMock('\SessionHandlerInterface')); + $this->_setExpectedException('\RuntimeException'); + new SessionProvider($this->_getMock($this->getComponentClassString()), $this->_getMock('\SessionHandlerInterface')); } protected function doOpen($conn) { - $request = $this->getMock('Psr\Http\Message\RequestInterface'); + $request = $this->_getMock('Psr\Http\Message\RequestInterface'); $request->expects($this->any())->method('getHeader')->will($this->returnValue([])); $this->_serv->onOpen($conn, $request); diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index 82b74fbf..cc89906e 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -1,6 +1,6 @@ setExpectedException('\Ratchet\Wamp\Exception'); + $this->_setExpectedException('\Ratchet\Wamp\Exception'); $conn = $this->newConn(); $this->_comp->onOpen($conn); @@ -226,7 +226,7 @@ public function testPrefix() { } public function testMessageMustBeJson() { - $this->setExpectedException('\\Ratchet\\Wamp\\JsonException'); + $this->_setExpectedException('\\Ratchet\\Wamp\\JsonException'); $conn = new Connection; @@ -245,7 +245,7 @@ public function testGetSubProtocolsGetFromApp() { } public function testWampOnMessageApp() { - $app = $this->getMock('\\Ratchet\\Wamp\\WampServerInterface'); + $app = $this->_getMock('\\Ratchet\\Wamp\\WampServerInterface'); $wamp = new ServerProtocol($app); $this->assertContains('wamp', $wamp->getSubProtocols()); @@ -263,7 +263,7 @@ public function badFormatProvider() { * @dataProvider badFormatProvider */ public function testValidJsonButInvalidProtocol($message) { - $this->setExpectedException('\Ratchet\Wamp\Exception'); + $this->_setExpectedException('\Ratchet\Wamp\Exception'); $conn = $this->newConn(); $this->_comp->onOpen($conn); @@ -271,7 +271,7 @@ public function testValidJsonButInvalidProtocol($message) { } public function testBadClientInputFromNonStringTopic() { - $this->setExpectedException('\Ratchet\Wamp\Exception'); + $this->_setExpectedException('\Ratchet\Wamp\Exception'); $conn = new WampConnection($this->newConn()); $this->_comp->onOpen($conn); @@ -280,7 +280,7 @@ public function testBadClientInputFromNonStringTopic() { } public function testBadPrefixWithNonStringTopic() { - $this->setExpectedException('\Ratchet\Wamp\Exception'); + $this->_setExpectedException('\Ratchet\Wamp\Exception'); $conn = new WampConnection($this->newConn()); $this->_comp->onOpen($conn); @@ -289,7 +289,7 @@ public function testBadPrefixWithNonStringTopic() { } public function testBadPublishWithNonStringTopic() { - $this->setExpectedException('\Ratchet\Wamp\Exception'); + $this->_setExpectedException('\Ratchet\Wamp\Exception'); $conn = new WampConnection($this->newConn()); $this->_comp->onOpen($conn); diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index 86f688fe..d86e1d83 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -1,12 +1,12 @@ conn = $this->getMock('\Ratchet\ConnectionInterface'); - $this->mock = $this->getMock('\Ratchet\Wamp\WampServerInterface'); + $this->conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->_getMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); $this->conn->WAMP = new \StdClass; @@ -222,7 +222,7 @@ public function testGetSubProtocolsReturnsArray() { public function testGetSubProtocolsBubbles() { $subs = array('hello', 'world'); - $app = $this->getMock('Ratchet\Wamp\Stub\WsWampServerInterface'); + $app = $this->_getMock('Ratchet\Wamp\Stub\WsWampServerInterface'); $app->expects($this->once())->method('getSubProtocols')->will($this->returnValue($subs)); $mngr = new TopicManager($app); diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index 6f77a01a..2314dc36 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -1,11 +1,10 @@ getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -64,9 +63,9 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -91,9 +90,9 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $first->expects($this->once()) ->method('send') @@ -160,6 +159,6 @@ public function testDoesNotHaveAfterRemove() { } protected function newConn() { - return new WampConnection($this->getMock('\\Ratchet\\ConnectionInterface')); + return new WampConnection($this->_getMock('\\Ratchet\\ConnectionInterface')); } } diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index aac57f3d..936fa6e1 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -1,11 +1,11 @@ mock = $this->getMock('\\Ratchet\\ConnectionInterface'); + $this->mock = $this->_getMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } @@ -71,7 +71,7 @@ public function testGetUriWhenNoCurieGiven() { } public function testClose() { - $mock = $this->getMock('\\Ratchet\\ConnectionInterface'); + $mock = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn = new WampConnection($mock); $mock->expects($this->once())->method('close'); From 2ae3ea8859f88fa0b9bdfe22d924759cf40b10b3 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 15:50:49 +1200 Subject: [PATCH 47/75] Test extended testcase to allow switching between getMock/createMock --- tests/helpers/Ratchet/RatchetTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/helpers/Ratchet/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php index 27ba700e..fd1bcd42 100644 --- a/tests/helpers/Ratchet/RatchetTestCase.php +++ b/tests/helpers/Ratchet/RatchetTestCase.php @@ -6,8 +6,8 @@ class RatchetTestCase extends TestCase { private function _version() { - if (class_exists('PHPUnit_Runner_Version')) { - return PHPUnit_Runner_Version::id(); + if (class_exists('\PHPUnit\Runner\PHPUnit_Runner_Version')) { + return \PHPUnit\Runner\PHPUnit_Runner_Version::id(); } else { return \PHPUnit\Runner\Version::id(); } From 3c0701ef02cb435fd230abfe4cfee19565d5e593 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 15:54:59 +1200 Subject: [PATCH 48/75] Test extended testcase to allow switching between getMock/createMock --- tests/helpers/Ratchet/RatchetTestCase.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/helpers/Ratchet/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php index fd1bcd42..2f036232 100644 --- a/tests/helpers/Ratchet/RatchetTestCase.php +++ b/tests/helpers/Ratchet/RatchetTestCase.php @@ -6,8 +6,8 @@ class RatchetTestCase extends TestCase { private function _version() { - if (class_exists('\PHPUnit\Runner\PHPUnit_Runner_Version')) { - return \PHPUnit\Runner\PHPUnit_Runner_Version::id(); + if (class_exists('\PHPUnit_Runner_Version')) { + return \PHPUnit_Runner_Version::id(); } else { return \PHPUnit\Runner\Version::id(); } From 2578564c1fc2ade3c082ea6e9d0f8d6e7c8409b2 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 16:34:57 +1200 Subject: [PATCH 49/75] Add switches to support PHPUnit < 6 and > 6 --- .../AbstractMessageComponentTestCase.php | 6 +++++- tests/helpers/Ratchet/RatchetTestCase.php | 17 +++++++++-------- tests/unit/AbstractConnectionDecoratorTest.php | 18 +++++++++++++++--- tests/unit/Http/RouterTest.php | 7 ++++++- tests/unit/Wamp/WampServerTest.php | 8 +++++++- 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 987262ed..9e6298b7 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -28,7 +28,11 @@ protected function doOpen($conn) { } public function isExpectedConnection() { - return new \PHPUnit_Framework_Constraint_IsInstanceOf($this->getConnectionClassString()); + if ($this->_version() < 6) { + return new \PHPUnit_Framework_Constraint_IsInstanceOf($this->getConnectionClassString()); + } else { + return new \PHPUnit\Framework\Constraint\IsInstanceOf($this->getConnectionClassString()); + } } public function testOpen() { diff --git a/tests/helpers/Ratchet/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php index 2f036232..27e54733 100644 --- a/tests/helpers/Ratchet/RatchetTestCase.php +++ b/tests/helpers/Ratchet/RatchetTestCase.php @@ -5,7 +5,7 @@ class RatchetTestCase extends TestCase { - private function _version() { + protected function _version() { if (class_exists('\PHPUnit_Runner_Version')) { return \PHPUnit_Runner_Version::id(); } else { @@ -15,20 +15,21 @@ private function _version() { public function _getMock() { $params = func_get_args(); - if ($this->_version() < 9) { + if ($this->_version() < 6) { return call_user_func_array([$this, 'getMock'], $params); } else { return call_user_func_array([$this, 'createMock'], $params); } } - public function _setExpectedException() { - $num_params = func_num_args(); - $params = func_get_args(); - if ($this->_version() < 9) { - call_user_func_array([$this, 'setExpectedException'], $params); + public function _setExpectedException($exception) { + if ($this->_version() < 6) { + call_user_func_array([$this, 'setExpectedException'], $exception); } else { - call_user_func_array([$this, 'expectException'], $params); + if (substr($exception, 0, 17) === 'PHPUnit_Framework') { + $exception = str_replace('_', '\\', $exception); + } + call_user_func_array([$this, 'expectException'], [$exception]); } } } diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index fbca7d26..f4e22693 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -135,17 +135,29 @@ public function testDecoratorRecursionLevel2() { } public function testWarningGettingNothing() { - $this->_setExpectedException('PHPUnit_Framework_Error'); + if ($this->_version() < 6) { + $this->_setExpectedException('PHPUnit_Framework_Error'); + } else { + $this->_setExpectedException('PHPUnit\Framework\Error\Warning'); + } $var = $this->mock->nonExistant; } public function testWarningGettingNothingLevel1() { - $this->_setExpectedException('PHPUnit_Framework_Error'); + if ($this->_version() < 6) { + $this->_setExpectedException('PHPUnit_Framework_Error'); + } else { + $this->_setExpectedException('PHPUnit\Framework\Error\Warning'); + } $var = $this->l1->nonExistant; } public function testWarningGettingNothingLevel2() { - $this->_setExpectedException('PHPUnit_Framework_Error'); + if ($this->_version() < 6) { + $this->_setExpectedException('PHPUnit_Framework_Error'); + } else { + $this->_setExpectedException('PHPUnit\Framework\Error\Warning'); + } $var = $this->l2->nonExistant; } } diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index c36bf40e..c758f3a0 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -74,7 +74,12 @@ public function testControllerOnOpen() { $this->_matcher->expects($this->any())->method('match')->will($this->returnValue(array('_controller' => $controller))); $this->_router->onOpen($this->_conn, $this->_req); - $expectedConn = new \PHPUnit_Framework_Constraint_IsInstanceOf('\Ratchet\ConnectionInterface'); + if ($this->_version() < 6) { + $expectedConn = new \PHPUnit_Framework_Constraint_IsInstanceOf('\Ratchet\ConnectionInterface'); + } else { + $expectedConn = new \PHPUnit\Framework\Constraint\IsInstanceOf('\Ratchet\ConnectionInterface'); + } + $controller->expects($this->once())->method('onOpen')->with($expectedConn, $this->_req); $this->_matcher->expects($this->any())->method('match')->will($this->returnValue(array('_controller' => $controller))); diff --git a/tests/unit/Wamp/WampServerTest.php b/tests/unit/Wamp/WampServerTest.php index 626b1cef..1e0b5aa2 100644 --- a/tests/unit/Wamp/WampServerTest.php +++ b/tests/unit/Wamp/WampServerTest.php @@ -21,9 +21,15 @@ public function getComponentClassString() { public function testOnMessageToEvent() { $published = 'Client published this message'; + if ($this->_version() < 6) { + $topic = new \PHPUnit_Framework_Constraint_IsInstanceOf('\Ratchet\Wamp\Topic'); + } else { + $topic = new \PHPUnit\Framework\Constraint\IsInstanceOf('\Ratchet\Wamp\Topic'); + } + $this->_app->expects($this->once())->method('onPublish')->with( $this->isExpectedConnection() - , new \PHPUnit_Framework_Constraint_IsInstanceOf('\Ratchet\Wamp\Topic') + , $topic , $published , array() , array() From b70073fbc5c8082a0da0b0f7d1cbb010e54adcf6 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 16:37:57 +1200 Subject: [PATCH 50/75] Add switches to support PHPUnit < 6 and > 6 --- tests/helpers/Ratchet/RatchetTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/helpers/Ratchet/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php index 27e54733..9b2155b6 100644 --- a/tests/helpers/Ratchet/RatchetTestCase.php +++ b/tests/helpers/Ratchet/RatchetTestCase.php @@ -24,7 +24,7 @@ public function _getMock() { public function _setExpectedException($exception) { if ($this->_version() < 6) { - call_user_func_array([$this, 'setExpectedException'], $exception); + call_user_func_array([$this, 'setExpectedException'], [$exception]); } else { if (substr($exception, 0, 17) === 'PHPUnit_Framework') { $exception = str_replace('_', '\\', $exception); From 12a1a1335a5ea6973fe261dabd867fb7520a087a Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 16:40:42 +1200 Subject: [PATCH 51/75] Add switches to support PHPUnit < 6 and > 6 --- tests/helpers/Ratchet/RatchetTestCase.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/helpers/Ratchet/RatchetTestCase.php b/tests/helpers/Ratchet/RatchetTestCase.php index 9b2155b6..fb928d95 100644 --- a/tests/helpers/Ratchet/RatchetTestCase.php +++ b/tests/helpers/Ratchet/RatchetTestCase.php @@ -26,9 +26,6 @@ public function _setExpectedException($exception) { if ($this->_version() < 6) { call_user_func_array([$this, 'setExpectedException'], [$exception]); } else { - if (substr($exception, 0, 17) === 'PHPUnit_Framework') { - $exception = str_replace('_', '\\', $exception); - } call_user_func_array([$this, 'expectException'], [$exception]); } } From 3e7f7f10fcc97209afafba9f33fa265d99ae5495 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 17:39:01 +1200 Subject: [PATCH 52/75] Update to getMockBuilder --- src/Ratchet/Wamp/WampConnection.php | 4 +++- .../AbstractMessageComponentTestCase.php | 6 +++--- tests/unit/AbstractConnectionDecoratorTest.php | 2 +- tests/unit/Http/HttpRequestParserTest.php | 4 ++-- tests/unit/Http/OriginCheckTest.php | 2 +- tests/unit/Http/RouterTest.php | 16 ++++++++-------- tests/unit/Server/EchoServerTest.php | 2 +- tests/unit/Server/FlashPolicyComponentTest.php | 8 ++++---- tests/unit/Server/IoConnectionTest.php | 2 +- tests/unit/Server/IoServerTest.php | 6 +++--- tests/unit/Server/IpBlackListComponentTest.php | 4 ++-- tests/unit/Session/SessionComponentTest.php | 16 ++++++++-------- tests/unit/Wamp/ServerProtocolTest.php | 2 +- tests/unit/Wamp/TopicManagerTest.php | 6 +++--- tests/unit/Wamp/TopicTest.php | 18 +++++++++--------- tests/unit/Wamp/WampConnectionTest.php | 4 ++-- 16 files changed, 52 insertions(+), 50 deletions(-) diff --git a/src/Ratchet/Wamp/WampConnection.php b/src/Ratchet/Wamp/WampConnection.php index dda1e4eb..e3e88e7a 100644 --- a/src/Ratchet/Wamp/WampConnection.php +++ b/src/Ratchet/Wamp/WampConnection.php @@ -10,6 +10,8 @@ * @property \stdClass $WAMP */ class WampConnection extends AbstractConnectionDecorator { + public $WAMP; + /** * {@inheritdoc} */ @@ -86,7 +88,7 @@ public function getUri($uri) { if (preg_match('/http(s*)\:\/\//', $uri) == false) { if (strpos($uri, $curieSeperator) !== false) { list($prefix, $action) = explode($curieSeperator, $uri); - + if(isset($this->WAMP->prefixes[$prefix]) === true){ return $this->WAMP->prefixes[$prefix] . '#' . $action; } diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index 9e6298b7..e1a1d54c 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -15,10 +15,10 @@ abstract public function getComponentClassString(); * @before */ public function before() { - $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); } @@ -37,7 +37,7 @@ public function isExpectedConnection() { 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() { diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index f4e22693..a58d832f 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -16,7 +16,7 @@ class AbstractConnectionDecoratorTest extends RatchetTestCase { * @before */ public function before() { - $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); } diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index dcd36551..160aabd2 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -35,7 +35,7 @@ public function testIsEom($expected, $message) { } public function testBufferOverflowResponse() { - $conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); $this->parser->maxSize = 20; @@ -47,7 +47,7 @@ public function testBufferOverflowResponse() { } 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); diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index 78367647..f3351a21 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -12,7 +12,7 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { * @before */ public function before() { - $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::before(); diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index c758f3a0..85606f57 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -23,18 +23,18 @@ class RouterTest extends RatchetTestCase { * @before */ public function before() { - $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); - $this->_uri = $this->_getMock('Psr\Http\Message\UriInterface'); - $this->_req = $this->_getMock('\Psr\Http\Message\RequestInterface'); + $this->_conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $this->_uri = $this->getMockBuilder('Psr\Http\Message\UriInterface')->getMock(); + $this->_req = $this->getMockBuilder('\Psr\Http\Message\RequestInterface')->getMock(); $this->_req ->expects($this->any()) ->method('getUri') ->will($this->returnValue($this->_uri)); - $this->_matcher = $this->_getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); + $this->_matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); $this->_matcher ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->_getMock('Symfony\Component\Routing\RequestContext'))); + ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())); $this->_router = new Router($this->_matcher); $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); @@ -122,7 +122,7 @@ public function testRouterGeneratesRouteParameters() { $this->_matcher->expects($this->any())->method('match')->will( $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->_getMock('Ratchet\Mock\Connection'); + $conn = $this->getMockBuilder('Ratchet\Mock\Connection')->getMock(); $router = new Router($this->_matcher); @@ -137,8 +137,8 @@ public function testQueryParams() { $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->_getMock('Ratchet\Mock\Connection'); - $request = $this->_getMock('Psr\Http\Message\RequestInterface'); + $conn = $this->getMockBuilder('Ratchet\Mock\Connection')->getMock(); + $request = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); $uri = new \GuzzleHttp\Psr7\Uri('ws://doesnt.matter/endpoint?hello=world&foo=nope'); $request->expects($this->any())->method('getUri')->will($this->returnCallback(function() use (&$uri) { diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 42b118e7..3917d7c3 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -14,7 +14,7 @@ class EchoServerTest extends RatchetTestCase { * @before */ public function before() { - $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $this->_conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index 63088743..e7a03b49 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -127,7 +127,7 @@ public function testSetSiteControlThrowsException() { } public function testErrorClosesConnection() { - $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); $conn->expects($this->once())->method('close'); $this->_policy->onError($conn, new \Exception); @@ -136,7 +136,7 @@ public function testErrorClosesConnection() { public function testOnMessageSendsString() { $this->_policy->addAllowedAccess('*', '*'); - $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); $conn->expects($this->once())->method('send')->with($this->isType('string')); $this->_policy->onMessage($conn, ' '); @@ -144,13 +144,13 @@ public function testOnMessageSendsString() { public function testOnOpenExists() { $this->assertTrue(method_exists($this->_policy, 'onOpen')); - $conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); $this->_policy->onOpen($conn); } public function testOnCloseExists() { $this->assertTrue(method_exists($this->_policy, 'onClose')); - $conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); $this->_policy->onClose($conn); } } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index fc843367..13b9d54b 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -14,7 +14,7 @@ class IoConnectionTest extends RatchetTestCase { * @before */ public function before() { - $this->sock = $this->_getMock('\\React\\Socket\\ConnectionInterface'); + $this->sock = $this->getMockBuilder('\\React\\Socket\\ConnectionInterface')->getMock(); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index d07637a2..83a88f33 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -30,7 +30,7 @@ protected function tickLoop(LoopInterface $loop) { * @before */ public function before() { - $this->app = $this->_getMock('\\Ratchet\\MessageComponentInterface'); + $this->app = $this->getMockBuilder('\\Ratchet\\MessageComponentInterface')->getMock(); $loop = new StreamSelectLoop; $this->reactor = new Server(0, $loop); @@ -107,7 +107,7 @@ public function testNoLoopProvidedError() { } public function testOnErrorPassesException() { - $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); $err = new \Exception("Nope"); $this->app->expects($this->once())->method('onError')->with($conn, $err); @@ -118,7 +118,7 @@ public function testOnErrorPassesException() { public function onErrorCalledWhenExceptionThrown() { $this->markTestIncomplete("Need to learn how to throw an exception from a mock"); - $conn = $this->_getMock('\\React\\Socket\\ConnectionInterface'); + $conn = $this->getMockBuilder('\\React\\Socket\\ConnectionInterface')->getMock(); $this->server->handleConnect($conn); $e = new \Exception; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index 482d9bcf..28c07a37 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -14,7 +14,7 @@ class IpBlackListTest extends RatchetTestCase { * @before */ public function before() { - $this->mock = $this->_getMock('\\Ratchet\\MessageComponentInterface'); + $this->mock = $this->getMockBuilder('\\Ratchet\\MessageComponentInterface')->getMock(); $this->blocker = new IpBlackList($this->mock); } @@ -121,7 +121,7 @@ public function testUnblockingSilentlyFails() { } protected function newConn() { - $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); + $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); $conn->remoteAddress = '127.0.0.1'; return $conn; diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index 3c5bbd38..efe629f3 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -58,7 +58,7 @@ public function testToClassCase($in, $out) { $method = $ref->getMethod('toClassCase'); $method->setAccessible(true); - $component = new SessionProvider($this->_getMock($this->getComponentClassString()), $this->_getMock('\SessionHandlerInterface')); + $component = new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $this->getMockBuilder('\SessionHandlerInterface')->getMock()); $this->assertEquals($out, $method->invokeArgs($component, array($in))); } @@ -87,10 +87,10 @@ public function testConnectionValueFromPdo() { $pdoHandler = new PdoSessionHandler($pdo, $dbOptions); $pdoHandler->write($sessionId, '_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'); - $component = new SessionProvider($this->_getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); - $connection = $this->_getMock('Ratchet\\ConnectionInterface'); + $component = new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $pdoHandler, array('auto_start' => 1)); + $connection = $this->getMockBuilder('Ratchet\\ConnectionInterface')->getMock(); - $headers = $this->_getMock('Psr\Http\Message\RequestInterface'); + $headers = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); $headers->expects($this->once())->method('getHeader')->will($this->returnValue([ini_get('session.name') . "={$sessionId};"])); $component->onOpen($connection, $headers); @@ -99,9 +99,9 @@ public function testConnectionValueFromPdo() { } protected function newConn() { - $conn = $this->_getMock('Ratchet\ConnectionInterface'); + $conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock(); - $headers = $this->_getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); + $headers = $this->getMockBuilder('Psr\Http\Message\Request')->onlyMethods(array('getCookie'))->setConstructorArgs(array('POST', '/', array()))->getMock(); $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null)); return $conn; @@ -120,11 +120,11 @@ public function testRejectInvalidSeralizers() { ini_set('session.serialize_handler', 'wddx'); $this->_setExpectedException('\RuntimeException'); - new SessionProvider($this->_getMock($this->getComponentClassString()), $this->_getMock('\SessionHandlerInterface')); + new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $this->getMockBuilder('\SessionHandlerInterface')->getMock()); } protected function doOpen($conn) { - $request = $this->_getMock('Psr\Http\Message\RequestInterface'); + $request = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); $request->expects($this->any())->method('getHeader')->will($this->returnValue([])); $this->_serv->onOpen($conn, $request); diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index cc89906e..12c56b19 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -245,7 +245,7 @@ public function testGetSubProtocolsGetFromApp() { } public function testWampOnMessageApp() { - $app = $this->_getMock('\\Ratchet\\Wamp\\WampServerInterface'); + $app = $this->getMockBuilder('\\Ratchet\\Wamp\\WampServerInterface')->getMock(); $wamp = new ServerProtocol($app); $this->assertContains('wamp', $wamp->getSubProtocols()); diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index d86e1d83..7459acad 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -23,8 +23,8 @@ class TopicManagerTest extends RatchetTestCase { * @before */ public function before() { - $this->conn = $this->_getMock('\Ratchet\ConnectionInterface'); - $this->mock = $this->_getMock('\Ratchet\Wamp\WampServerInterface'); + $this->conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $this->mock = $this->getMockBuilder('\Ratchet\Wamp\WampServerInterface')->getMock(); $this->mngr = new TopicManager($this->mock); $this->conn->WAMP = new \StdClass; @@ -222,7 +222,7 @@ public function testGetSubProtocolsReturnsArray() { public function testGetSubProtocolsBubbles() { $subs = array('hello', 'world'); - $app = $this->_getMock('Ratchet\Wamp\Stub\WsWampServerInterface'); + $app = $this->getMockBuilder('Ratchet\Wamp\Stub\WsWampServerInterface')->getMock(); $app->expects($this->once())->method('getSubProtocols')->will($this->returnValue($subs)); $mngr = new TopicManager($app); diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index 2314dc36..62517fbd 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -40,8 +40,8 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); $first->expects($this->once()) ->method('send') @@ -63,9 +63,9 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); $first->expects($this->once()) ->method('send') @@ -90,9 +90,9 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); $first->expects($this->once()) ->method('send') @@ -159,6 +159,6 @@ public function testDoesNotHaveAfterRemove() { } protected function newConn() { - return new WampConnection($this->_getMock('\\Ratchet\\ConnectionInterface')); + return new WampConnection($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()); } } diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index 936fa6e1..9e20dc5f 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -13,7 +13,7 @@ class WampConnectionTest extends RatchetTestCase { * @before */ public function before() { - $this->mock = $this->_getMock('\\Ratchet\\ConnectionInterface'); + $this->mock = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); $this->conn = new WampConnection($this->mock); } @@ -71,7 +71,7 @@ public function testGetUriWhenNoCurieGiven() { } public function testClose() { - $mock = $this->_getMock('\\Ratchet\\ConnectionInterface'); + $mock = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); $conn = new WampConnection($mock); $mock->expects($this->once())->method('close'); From 2904585566544b40d528f71cef98f6e08bdd7942 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 17:47:08 +1200 Subject: [PATCH 53/75] Revert some getMockBuilder --- .../AbstractMessageComponentTestCase.php | 6 +++--- tests/unit/AbstractConnectionDecoratorTest.php | 2 +- tests/unit/Http/HttpRequestParserTest.php | 4 ++-- tests/unit/Http/OriginCheckTest.php | 2 +- tests/unit/Http/RouterTest.php | 16 ++++++++-------- tests/unit/Server/EchoServerTest.php | 2 +- tests/unit/Server/FlashPolicyComponentTest.php | 8 ++++---- tests/unit/Server/IoConnectionTest.php | 2 +- tests/unit/Server/IoServerTest.php | 6 +++--- tests/unit/Server/IpBlackListComponentTest.php | 4 ++-- tests/unit/Session/SessionComponentTest.php | 16 ++++++++-------- tests/unit/Wamp/ServerProtocolTest.php | 2 +- tests/unit/Wamp/TopicManagerTest.php | 6 +++--- tests/unit/Wamp/TopicTest.php | 18 +++++++++--------- tests/unit/Wamp/WampConnectionTest.php | 4 ++-- 15 files changed, 49 insertions(+), 49 deletions(-) diff --git a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php index e1a1d54c..9e6298b7 100644 --- a/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php +++ b/tests/helpers/Ratchet/AbstractMessageComponentTestCase.php @@ -15,10 +15,10 @@ abstract public function getComponentClassString(); * @before */ public function before() { - $this->_app = $this->getMockBuilder($this->getComponentClassString())->getMock(); + $this->_app = $this->_getMock($this->getComponentClassString()); $decorator = $this->getDecoratorClassString(); $this->_serv = new $decorator($this->_app); - $this->_conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->doOpen($this->_conn); } @@ -37,7 +37,7 @@ public function isExpectedConnection() { public function testOpen() { $this->_app->expects($this->once())->method('onOpen')->with($this->isExpectedConnection()); - $this->doOpen($this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock()); + $this->doOpen($this->_getMock('\Ratchet\ConnectionInterface')); } public function testOnClose() { diff --git a/tests/unit/AbstractConnectionDecoratorTest.php b/tests/unit/AbstractConnectionDecoratorTest.php index a58d832f..f4e22693 100644 --- a/tests/unit/AbstractConnectionDecoratorTest.php +++ b/tests/unit/AbstractConnectionDecoratorTest.php @@ -16,7 +16,7 @@ class AbstractConnectionDecoratorTest extends RatchetTestCase { * @before */ public function before() { - $this->mock = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $this->mock = $this->_getMock('\Ratchet\ConnectionInterface'); $this->l1 = new ConnectionDecorator($this->mock); $this->l2 = new ConnectionDecorator($this->l1); } diff --git a/tests/unit/Http/HttpRequestParserTest.php b/tests/unit/Http/HttpRequestParserTest.php index 160aabd2..dcd36551 100644 --- a/tests/unit/Http/HttpRequestParserTest.php +++ b/tests/unit/Http/HttpRequestParserTest.php @@ -35,7 +35,7 @@ public function testIsEom($expected, $message) { } public function testBufferOverflowResponse() { - $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->parser->maxSize = 20; @@ -47,7 +47,7 @@ public function testBufferOverflowResponse() { } public function testReturnTypeIsRequest() { - $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $return = $this->parser->onMessage($conn, "GET / HTTP/1.1\r\nHost: socketo.me\r\n\r\n"); $this->assertInstanceOf('\Psr\Http\Message\RequestInterface', $return); diff --git a/tests/unit/Http/OriginCheckTest.php b/tests/unit/Http/OriginCheckTest.php index f3351a21..78367647 100644 --- a/tests/unit/Http/OriginCheckTest.php +++ b/tests/unit/Http/OriginCheckTest.php @@ -12,7 +12,7 @@ class OriginCheckTest extends AbstractMessageComponentTestCase { * @before */ public function before() { - $this->_reqStub = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); + $this->_reqStub = $this->_getMock('Psr\Http\Message\RequestInterface'); $this->_reqStub->expects($this->any())->method('getHeader')->will($this->returnValue(['localhost'])); parent::before(); diff --git a/tests/unit/Http/RouterTest.php b/tests/unit/Http/RouterTest.php index 85606f57..c758f3a0 100644 --- a/tests/unit/Http/RouterTest.php +++ b/tests/unit/Http/RouterTest.php @@ -23,18 +23,18 @@ class RouterTest extends RatchetTestCase { * @before */ public function before() { - $this->_conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); - $this->_uri = $this->getMockBuilder('Psr\Http\Message\UriInterface')->getMock(); - $this->_req = $this->getMockBuilder('\Psr\Http\Message\RequestInterface')->getMock(); + $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $this->_uri = $this->_getMock('Psr\Http\Message\UriInterface'); + $this->_req = $this->_getMock('\Psr\Http\Message\RequestInterface'); $this->_req ->expects($this->any()) ->method('getUri') ->will($this->returnValue($this->_uri)); - $this->_matcher = $this->getMockBuilder('Symfony\Component\Routing\Matcher\UrlMatcherInterface')->getMock(); + $this->_matcher = $this->_getMock('Symfony\Component\Routing\Matcher\UrlMatcherInterface'); $this->_matcher ->expects($this->any()) ->method('getContext') - ->will($this->returnValue($this->getMockBuilder('Symfony\Component\Routing\RequestContext')->getMock())); + ->will($this->returnValue($this->_getMock('Symfony\Component\Routing\RequestContext'))); $this->_router = new Router($this->_matcher); $this->_uri->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/')); @@ -122,7 +122,7 @@ public function testRouterGeneratesRouteParameters() { $this->_matcher->expects($this->any())->method('match')->will( $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->getMockBuilder('Ratchet\Mock\Connection')->getMock(); + $conn = $this->_getMock('Ratchet\Mock\Connection'); $router = new Router($this->_matcher); @@ -137,8 +137,8 @@ public function testQueryParams() { $this->returnValue(['_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux']) ); - $conn = $this->getMockBuilder('Ratchet\Mock\Connection')->getMock(); - $request = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); + $conn = $this->_getMock('Ratchet\Mock\Connection'); + $request = $this->_getMock('Psr\Http\Message\RequestInterface'); $uri = new \GuzzleHttp\Psr7\Uri('ws://doesnt.matter/endpoint?hello=world&foo=nope'); $request->expects($this->any())->method('getUri')->will($this->returnCallback(function() use (&$uri) { diff --git a/tests/unit/Server/EchoServerTest.php b/tests/unit/Server/EchoServerTest.php index 3917d7c3..42b118e7 100644 --- a/tests/unit/Server/EchoServerTest.php +++ b/tests/unit/Server/EchoServerTest.php @@ -14,7 +14,7 @@ class EchoServerTest extends RatchetTestCase { * @before */ public function before() { - $this->_conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $this->_conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->_comp = new EchoServer; } diff --git a/tests/unit/Server/FlashPolicyComponentTest.php b/tests/unit/Server/FlashPolicyComponentTest.php index e7a03b49..63088743 100644 --- a/tests/unit/Server/FlashPolicyComponentTest.php +++ b/tests/unit/Server/FlashPolicyComponentTest.php @@ -127,7 +127,7 @@ public function testSetSiteControlThrowsException() { } public function testErrorClosesConnection() { - $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('close'); $this->_policy->onError($conn, new \Exception); @@ -136,7 +136,7 @@ public function testErrorClosesConnection() { public function testOnMessageSendsString() { $this->_policy->addAllowedAccess('*', '*'); - $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn->expects($this->once())->method('send')->with($this->isType('string')); $this->_policy->onMessage($conn, ' '); @@ -144,13 +144,13 @@ public function testOnMessageSendsString() { public function testOnOpenExists() { $this->assertTrue(method_exists($this->_policy, 'onOpen')); - $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->_policy->onOpen($conn); } public function testOnCloseExists() { $this->assertTrue(method_exists($this->_policy, 'onClose')); - $conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\Ratchet\ConnectionInterface'); $this->_policy->onClose($conn); } } diff --git a/tests/unit/Server/IoConnectionTest.php b/tests/unit/Server/IoConnectionTest.php index 13b9d54b..fc843367 100644 --- a/tests/unit/Server/IoConnectionTest.php +++ b/tests/unit/Server/IoConnectionTest.php @@ -14,7 +14,7 @@ class IoConnectionTest extends RatchetTestCase { * @before */ public function before() { - $this->sock = $this->getMockBuilder('\\React\\Socket\\ConnectionInterface')->getMock(); + $this->sock = $this->_getMock('\\React\\Socket\\ConnectionInterface'); $this->conn = new IoConnection($this->sock); } diff --git a/tests/unit/Server/IoServerTest.php b/tests/unit/Server/IoServerTest.php index 83a88f33..d07637a2 100644 --- a/tests/unit/Server/IoServerTest.php +++ b/tests/unit/Server/IoServerTest.php @@ -30,7 +30,7 @@ protected function tickLoop(LoopInterface $loop) { * @before */ public function before() { - $this->app = $this->getMockBuilder('\\Ratchet\\MessageComponentInterface')->getMock(); + $this->app = $this->_getMock('\\Ratchet\\MessageComponentInterface'); $loop = new StreamSelectLoop; $this->reactor = new Server(0, $loop); @@ -107,7 +107,7 @@ public function testNoLoopProvidedError() { } public function testOnErrorPassesException() { - $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $err = new \Exception("Nope"); $this->app->expects($this->once())->method('onError')->with($conn, $err); @@ -118,7 +118,7 @@ public function testOnErrorPassesException() { public function onErrorCalledWhenExceptionThrown() { $this->markTestIncomplete("Need to learn how to throw an exception from a mock"); - $conn = $this->getMockBuilder('\\React\\Socket\\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\\React\\Socket\\ConnectionInterface'); $this->server->handleConnect($conn); $e = new \Exception; diff --git a/tests/unit/Server/IpBlackListComponentTest.php b/tests/unit/Server/IpBlackListComponentTest.php index 28c07a37..482d9bcf 100644 --- a/tests/unit/Server/IpBlackListComponentTest.php +++ b/tests/unit/Server/IpBlackListComponentTest.php @@ -14,7 +14,7 @@ class IpBlackListTest extends RatchetTestCase { * @before */ public function before() { - $this->mock = $this->getMockBuilder('\\Ratchet\\MessageComponentInterface')->getMock(); + $this->mock = $this->_getMock('\\Ratchet\\MessageComponentInterface'); $this->blocker = new IpBlackList($this->mock); } @@ -121,7 +121,7 @@ public function testUnblockingSilentlyFails() { } protected function newConn() { - $conn = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); + $conn = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn->remoteAddress = '127.0.0.1'; return $conn; diff --git a/tests/unit/Session/SessionComponentTest.php b/tests/unit/Session/SessionComponentTest.php index efe629f3..3c5bbd38 100644 --- a/tests/unit/Session/SessionComponentTest.php +++ b/tests/unit/Session/SessionComponentTest.php @@ -58,7 +58,7 @@ public function testToClassCase($in, $out) { $method = $ref->getMethod('toClassCase'); $method->setAccessible(true); - $component = new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $this->getMockBuilder('\SessionHandlerInterface')->getMock()); + $component = new SessionProvider($this->_getMock($this->getComponentClassString()), $this->_getMock('\SessionHandlerInterface')); $this->assertEquals($out, $method->invokeArgs($component, array($in))); } @@ -87,10 +87,10 @@ public function testConnectionValueFromPdo() { $pdoHandler = new PdoSessionHandler($pdo, $dbOptions); $pdoHandler->write($sessionId, '_sf2_attributes|a:2:{s:5:"hello";s:5:"world";s:4:"last";i:1332872102;}_sf2_flashes|a:0:{}'); - $component = new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $pdoHandler, array('auto_start' => 1)); - $connection = $this->getMockBuilder('Ratchet\\ConnectionInterface')->getMock(); + $component = new SessionProvider($this->_getMock($this->getComponentClassString()), $pdoHandler, array('auto_start' => 1)); + $connection = $this->_getMock('Ratchet\\ConnectionInterface'); - $headers = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); + $headers = $this->_getMock('Psr\Http\Message\RequestInterface'); $headers->expects($this->once())->method('getHeader')->will($this->returnValue([ini_get('session.name') . "={$sessionId};"])); $component->onOpen($connection, $headers); @@ -99,9 +99,9 @@ public function testConnectionValueFromPdo() { } protected function newConn() { - $conn = $this->getMockBuilder('Ratchet\ConnectionInterface')->getMock(); + $conn = $this->_getMock('Ratchet\ConnectionInterface'); - $headers = $this->getMockBuilder('Psr\Http\Message\Request')->onlyMethods(array('getCookie'))->setConstructorArgs(array('POST', '/', array()))->getMock(); + $headers = $this->_getMock('Psr\Http\Message\Request', array('getCookie'), array('POST', '/', array())); $headers->expects($this->once())->method('getCookie', array(ini_get('session.name')))->will($this->returnValue(null)); return $conn; @@ -120,11 +120,11 @@ public function testRejectInvalidSeralizers() { ini_set('session.serialize_handler', 'wddx'); $this->_setExpectedException('\RuntimeException'); - new SessionProvider($this->getMockBuilder($this->getComponentClassString())->getMock(), $this->getMockBuilder('\SessionHandlerInterface')->getMock()); + new SessionProvider($this->_getMock($this->getComponentClassString()), $this->_getMock('\SessionHandlerInterface')); } protected function doOpen($conn) { - $request = $this->getMockBuilder('Psr\Http\Message\RequestInterface')->getMock(); + $request = $this->_getMock('Psr\Http\Message\RequestInterface'); $request->expects($this->any())->method('getHeader')->will($this->returnValue([])); $this->_serv->onOpen($conn, $request); diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index 12c56b19..cc89906e 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -245,7 +245,7 @@ public function testGetSubProtocolsGetFromApp() { } public function testWampOnMessageApp() { - $app = $this->getMockBuilder('\\Ratchet\\Wamp\\WampServerInterface')->getMock(); + $app = $this->_getMock('\\Ratchet\\Wamp\\WampServerInterface'); $wamp = new ServerProtocol($app); $this->assertContains('wamp', $wamp->getSubProtocols()); diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index 7459acad..d86e1d83 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -23,8 +23,8 @@ class TopicManagerTest extends RatchetTestCase { * @before */ public function before() { - $this->conn = $this->getMockBuilder('\Ratchet\ConnectionInterface')->getMock(); - $this->mock = $this->getMockBuilder('\Ratchet\Wamp\WampServerInterface')->getMock(); + $this->conn = $this->_getMock('\Ratchet\ConnectionInterface'); + $this->mock = $this->_getMock('\Ratchet\Wamp\WampServerInterface'); $this->mngr = new TopicManager($this->mock); $this->conn->WAMP = new \StdClass; @@ -222,7 +222,7 @@ public function testGetSubProtocolsReturnsArray() { public function testGetSubProtocolsBubbles() { $subs = array('hello', 'world'); - $app = $this->getMockBuilder('Ratchet\Wamp\Stub\WsWampServerInterface')->getMock(); + $app = $this->_getMock('Ratchet\Wamp\Stub\WsWampServerInterface'); $app->expects($this->once())->method('getSubProtocols')->will($this->returnValue($subs)); $mngr = new TopicManager($app); diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index 62517fbd..d0e3b641 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -40,8 +40,8 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); - $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $first->expects($this->once()) ->method('send') @@ -63,9 +63,9 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); - $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); - $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $first->expects($this->once()) ->method('send') @@ -90,9 +90,9 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); - $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); - $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()))->getMock(); + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $first->expects($this->once()) ->method('send') @@ -159,6 +159,6 @@ public function testDoesNotHaveAfterRemove() { } protected function newConn() { - return new WampConnection($this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock()); + return new WampConnection($this->_getMock('\\Ratchet\\ConnectionInterface')); } } diff --git a/tests/unit/Wamp/WampConnectionTest.php b/tests/unit/Wamp/WampConnectionTest.php index 9e20dc5f..936fa6e1 100644 --- a/tests/unit/Wamp/WampConnectionTest.php +++ b/tests/unit/Wamp/WampConnectionTest.php @@ -13,7 +13,7 @@ class WampConnectionTest extends RatchetTestCase { * @before */ public function before() { - $this->mock = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); + $this->mock = $this->_getMock('\\Ratchet\\ConnectionInterface'); $this->conn = new WampConnection($this->mock); } @@ -71,7 +71,7 @@ public function testGetUriWhenNoCurieGiven() { } public function testClose() { - $mock = $this->getMockBuilder('\\Ratchet\\ConnectionInterface')->getMock(); + $mock = $this->_getMock('\\Ratchet\\ConnectionInterface'); $conn = new WampConnection($mock); $mock->expects($this->once())->method('close'); From c62998b7a67b838cb97ed015f9eea8e1f1ac97fa Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 18:03:25 +1200 Subject: [PATCH 54/75] Update TopicTest --- tests/unit/Wamp/TopicTest.php | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index d0e3b641..bc2acfd1 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -40,8 +40,13 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + if ($this->_version() < 6) { + $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + } else { + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(['send'])->setConstructorArgs([$this->_getMock('\\Ratchet\\ConnectionInterface')])->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(['send'])->setConstructorArgs([$this->_getMock('\\Ratchet\\ConnectionInterface')])->getMock(); + } $first->expects($this->once()) ->method('send') @@ -63,9 +68,15 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + if ($this->_version() < 6) { + $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + } else { + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + } $first->expects($this->once()) ->method('send') @@ -90,10 +101,16 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - + if ($this->_version() < 6) { + $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); + } else { + $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); + } + $first->expects($this->once()) ->method('send') ->with($this->equalTo($protocol)); From f3559e92fcabb697d774a20b4b601e7d64da4410 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 18:08:06 +1200 Subject: [PATCH 55/75] Update TopicTest --- tests/helpers/Ratchet/Mock/Connection.php | 8 ++++++++ tests/unit/Wamp/TopicTest.php | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/helpers/Ratchet/Mock/Connection.php b/tests/helpers/Ratchet/Mock/Connection.php index 59182965..23e645f7 100644 --- a/tests/helpers/Ratchet/Mock/Connection.php +++ b/tests/helpers/Ratchet/Mock/Connection.php @@ -8,6 +8,8 @@ class Connection implements ConnectionInterface { , 'close' => false ); + public $WAMP; + public $remoteAddress = '127.0.0.1'; public function send($data) { @@ -17,4 +19,10 @@ public function send($data) { public function close() { $this->last[__FUNCTION__] = true; } + + public function __construct() { + $this->WAMP = new \StdClass; + $this->WAMP->sessionId = str_replace('.', '', uniqid(mt_rand(), true)); + $this->WAMP->prefixes = array(); + } } diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index bc2acfd1..d2126dc9 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -110,7 +110,7 @@ public function testBroadcastWithEligible() { $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); } - + $first->expects($this->once()) ->method('send') ->with($this->equalTo($protocol)); From cd493aa8025b9aa1870e24112e550de8863e2e4b Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 18:31:36 +1200 Subject: [PATCH 56/75] Update Connection --- tests/helpers/Ratchet/Mock/Connection.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/helpers/Ratchet/Mock/Connection.php b/tests/helpers/Ratchet/Mock/Connection.php index 23e645f7..59182965 100644 --- a/tests/helpers/Ratchet/Mock/Connection.php +++ b/tests/helpers/Ratchet/Mock/Connection.php @@ -8,8 +8,6 @@ class Connection implements ConnectionInterface { , 'close' => false ); - public $WAMP; - public $remoteAddress = '127.0.0.1'; public function send($data) { @@ -19,10 +17,4 @@ public function send($data) { public function close() { $this->last[__FUNCTION__] = true; } - - public function __construct() { - $this->WAMP = new \StdClass; - $this->WAMP->sessionId = str_replace('.', '', uniqid(mt_rand(), true)); - $this->WAMP->prefixes = array(); - } } From 8f4a6dd507ebf05e338a16b4e69e5c2c81124a15 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 19:55:39 +1200 Subject: [PATCH 57/75] Revert changes --- tests/unit/Wamp/TopicTest.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index d2126dc9..f7c51657 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -40,13 +40,13 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - if ($this->_version() < 6) { + //if ($this->_version() < 6) { $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - } else { + /*} else { $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(['send'])->setConstructorArgs([$this->_getMock('\\Ratchet\\ConnectionInterface')])->getMock(); $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(['send'])->setConstructorArgs([$this->_getMock('\\Ratchet\\ConnectionInterface')])->getMock(); - } + }*/ $first->expects($this->once()) ->method('send') @@ -68,15 +68,15 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - if ($this->_version() < 6) { + //if ($this->_version() < 6) { $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - } else { + /*} else { $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - } + }*/ $first->expects($this->once()) ->method('send') @@ -101,15 +101,15 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - if ($this->_version() < 6) { + //if ($this->_version() < 6) { $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - } else { + /*} else { $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - } + }*/ $first->expects($this->once()) ->method('send') From 659080314d512325bfc9a936f9c5ba2995fc07b6 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 20:07:49 +1200 Subject: [PATCH 58/75] Revert changes --- src/Ratchet/Wamp/WampConnection.php | 1 - tests/unit/Wamp/ServerProtocolTest.php | 1 - tests/unit/Wamp/TopicTest.php | 18 +++++++++--------- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Ratchet/Wamp/WampConnection.php b/src/Ratchet/Wamp/WampConnection.php index e3e88e7a..20fdad16 100644 --- a/src/Ratchet/Wamp/WampConnection.php +++ b/src/Ratchet/Wamp/WampConnection.php @@ -10,7 +10,6 @@ * @property \stdClass $WAMP */ class WampConnection extends AbstractConnectionDecorator { - public $WAMP; /** * {@inheritdoc} diff --git a/tests/unit/Wamp/ServerProtocolTest.php b/tests/unit/Wamp/ServerProtocolTest.php index cc89906e..86708f64 100644 --- a/tests/unit/Wamp/ServerProtocolTest.php +++ b/tests/unit/Wamp/ServerProtocolTest.php @@ -142,7 +142,6 @@ public function testPublishAndExcludeMe() { $this->_comp->onOpen($conn); $this->_comp->onMessage($conn, json_encode(array(7, 'topic', 'event', true))); - $this->assertEquals($conn->WAMP->sessionId, $this->_app->last['onPublish'][3][0]); } diff --git a/tests/unit/Wamp/TopicTest.php b/tests/unit/Wamp/TopicTest.php index f7c51657..d2126dc9 100644 --- a/tests/unit/Wamp/TopicTest.php +++ b/tests/unit/Wamp/TopicTest.php @@ -40,13 +40,13 @@ public function testBroadcast() { $name = 'Batman'; $protocol = json_encode(array(8, $name, $msg)); - //if ($this->_version() < 6) { + if ($this->_version() < 6) { $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - /*} else { + } else { $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(['send'])->setConstructorArgs([$this->_getMock('\\Ratchet\\ConnectionInterface')])->getMock(); $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(['send'])->setConstructorArgs([$this->_getMock('\\Ratchet\\ConnectionInterface')])->getMock(); - }*/ + } $first->expects($this->once()) ->method('send') @@ -68,15 +68,15 @@ public function testBroadcastWithExclude() { $name = 'Excluding'; $protocol = json_encode(array(8, $name, $msg)); - //if ($this->_version() < 6) { + if ($this->_version() < 6) { $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - /*} else { + } else { $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - }*/ + } $first->expects($this->once()) ->method('send') @@ -101,15 +101,15 @@ public function testBroadcastWithEligible() { $name = 'Eligible'; $protocol = json_encode(array(8, $name, $msg)); - //if ($this->_version() < 6) { + if ($this->_version() < 6) { $first = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $second = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); $third = $this->_getMock('Ratchet\\Wamp\\WampConnection', array('send'), array($this->_getMock('\\Ratchet\\ConnectionInterface'))); - /*} else { + } else { $first = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $second = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); $third = $this->getMockBuilder('Ratchet\\Wamp\\WampConnection')->onlyMethods(array('send'))->setConstructorArgs(array($this->_getMock('\\Ratchet\\ConnectionInterface')))->getMock(); - }*/ + } $first->expects($this->once()) ->method('send') From 836a02c6c402ddf9cd4ed1f4c39c53dfb0c03c6b Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 20:19:03 +1200 Subject: [PATCH 59/75] Update asserts --- tests/unit/Wamp/TopicManagerTest.php | 10 +++++++--- tests/unit/Wamp/WampServerTest.php | 6 +++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index d86e1d83..fe89352a 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -179,7 +179,7 @@ protected function topicProvider($name) { public function testConnIsRemovedFromTopicOnClose() { $name = 'State Testing'; - list($topic, $attribute) = $this->topicProvider($name); + [$topic, $attribute] = $this->topicProvider($name); $this->assertCount(1, $attribute->getValue($this->mngr)); @@ -201,7 +201,7 @@ public static function topicConnExpectationProvider() { */ public function testTopicRetentionFromLeavingConnections($methodCall, $expectation) { $topicName = 'checkTopic'; - list($topic, $attribute) = $this->topicProvider($topicName); + [$topic, $attribute] = $this->topicProvider($topicName); $this->mngr->onSubscribe($this->conn, $topicName); call_user_func_array(array($this->mngr, $methodCall), array($this->conn, $topicName)); @@ -217,7 +217,11 @@ public function testOnErrorBubbles() { } public function testGetSubProtocolsReturnsArray() { - $this->assertInternalType('array', $this->mngr->getSubProtocols()); + if ($this->_version() < 7.5) { + $this->assertInternalType('array', $this->mngr->getSubProtocols()); + } else { + $this->assertIsArray($this->mngr->getSubProtocols()); + } } public function testGetSubProtocolsBubbles() { diff --git a/tests/unit/Wamp/WampServerTest.php b/tests/unit/Wamp/WampServerTest.php index 1e0b5aa2..4d25d3c7 100644 --- a/tests/unit/Wamp/WampServerTest.php +++ b/tests/unit/Wamp/WampServerTest.php @@ -40,7 +40,11 @@ public function testOnMessageToEvent() { public function testGetSubProtocols() { // todo: could expand on this - $this->assertInternalType('array', $this->_serv->getSubProtocols()); + if ($this->_version() < 7.5) { + $this->assertInternalType('array', $this->_serv->getSubProtocols()); + } else { + $this->assertIsArray($this->_serv->getSubProtocols()); + } } public function testConnectionClosesOnInvalidJson() { From ccfaf848b6f0f960fc0f664605da7839d64e459a Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 20:25:06 +1200 Subject: [PATCH 60/75] Try list() for array destructuring in testConnIsRemovedFromTopicOnClose --- tests/unit/Wamp/TopicManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index fe89352a..db680a91 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -179,7 +179,7 @@ protected function topicProvider($name) { public function testConnIsRemovedFromTopicOnClose() { $name = 'State Testing'; - [$topic, $attribute] = $this->topicProvider($name); + list($topic, $attribute) = $this->topicProvider($name); $this->assertCount(1, $attribute->getValue($this->mngr)); From 533b27316f703b8a7811fb162ec9ada0edc133cf Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 20:27:13 +1200 Subject: [PATCH 61/75] list() for array destructuring --- tests/unit/Wamp/TopicManagerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Wamp/TopicManagerTest.php b/tests/unit/Wamp/TopicManagerTest.php index db680a91..340c9fb3 100644 --- a/tests/unit/Wamp/TopicManagerTest.php +++ b/tests/unit/Wamp/TopicManagerTest.php @@ -201,7 +201,7 @@ public static function topicConnExpectationProvider() { */ public function testTopicRetentionFromLeavingConnections($methodCall, $expectation) { $topicName = 'checkTopic'; - [$topic, $attribute] = $this->topicProvider($topicName); + list($topic, $attribute) = $this->topicProvider($topicName); $this->mngr->onSubscribe($this->conn, $topicName); call_user_func_array(array($this->mngr, $methodCall), array($this->conn, $topicName)); From 755977d8b41bbed541b333ab27991e717de19025 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 21:54:04 +1200 Subject: [PATCH 62/75] Remove workflow_dispatch --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9a0434a..718a1fb9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: - "master" schedule: - cron: "42 3 * * *" - workflow_dispatch: jobs: phpunit: From 634792ae8a1b5925ef505c4f7b8a8dd22905c0cf Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 22:03:23 +1200 Subject: [PATCH 63/75] Remove unnecessary include from HttpServer --- src/Ratchet/Http/HttpServer.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Ratchet/Http/HttpServer.php b/src/Ratchet/Http/HttpServer.php index 188ab3f8..4ba5ebe0 100644 --- a/src/Ratchet/Http/HttpServer.php +++ b/src/Ratchet/Http/HttpServer.php @@ -1,6 +1,5 @@ Date: Sun, 14 May 2023 22:06:28 +1200 Subject: [PATCH 64/75] Add http-foundation 6.0 back --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index f695bbed..a2d51d0b 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ , "react/socket": "^1.0 || ^0.8 || ^0.7 || ^0.6 || ^0.5" , "react/event-loop": ">=0.4" , "guzzlehttp/psr7": "^1.7|^2.0" - , "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0" + , "symfony/http-foundation": "^2.6|^3.0|^4.0|^5.0|^6.0" , "symfony/routing": "^2.6|^3.0|^4.0|^5.0|^6.0" } , "require-dev": { From 7c28424fc67c94ef1975a5ebd11f629694982551 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 22:32:54 +1200 Subject: [PATCH 65/75] Test return types --- src/Ratchet/Session/Storage/VirtualSessionStorage.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage.php b/src/Ratchet/Session/Storage/VirtualSessionStorage.php index daa10bba..5e3cee84 100644 --- a/src/Ratchet/Session/Storage/VirtualSessionStorage.php +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage.php @@ -25,7 +25,7 @@ public function __construct(\SessionHandlerInterface $handler, $sessionId, Handl /** * {@inheritdoc} */ - public function start() { + public function start(): bool { if ($this->started && !$this->closed) { return true; } From 54c0aefca915c24040bac65ae8bb6f2c7fdc9a76 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 22:33:20 +1200 Subject: [PATCH 66/75] Allow manual work flow runs --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 718a1fb9..c9a0434a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: - "master" schedule: - cron: "42 3 * * *" + workflow_dispatch: jobs: phpunit: From e7e7e32e69cd1e538f1c05cb36e9e6d17ef2d703 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 14 May 2023 23:37:59 +1200 Subject: [PATCH 67/75] Horrible hack to allow symfony/http-foundation >= 6.0 (definitely need a better solution) --- .../Session/Storage/Proxy/VirtualProxy.php | 55 +----------- .../Session/Storage/Proxy/VirtualProxy8+.php | 54 +++++++++++ .../Session/Storage/Proxy/VirtualProxy<8.php | 54 +++++++++++ .../Session/Storage/VirtualSessionStorage.php | 89 +------------------ .../Storage/VirtualSessionStorage8+.php | 81 +++++++++++++++++ .../Storage/VirtualSessionStorage<8.php | 81 +++++++++++++++++ 6 files changed, 278 insertions(+), 136 deletions(-) create mode 100644 src/Ratchet/Session/Storage/Proxy/VirtualProxy8+.php create mode 100644 src/Ratchet/Session/Storage/Proxy/VirtualProxy<8.php create mode 100644 src/Ratchet/Session/Storage/VirtualSessionStorage8+.php create mode 100644 src/Ratchet/Session/Storage/VirtualSessionStorage<8.php diff --git a/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php b/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php index b478d039..c42d3b04 100644 --- a/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php +++ b/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php @@ -1,54 +1,7 @@ saveHandlerName = 'user'; - $this->_sessionName = ini_get('session.name'); - } - - /** - * {@inheritdoc} - */ - public function getId() { - return $this->_sessionId; - } - - /** - * {@inheritdoc} - */ - public function setId($id) { - $this->_sessionId = $id; - } - - /** - * {@inheritdoc} - */ - public function getName() { - return $this->_sessionName; - } - - /** - * DO NOT CALL THIS METHOD - * @internal - */ - public function setName($name) { - throw new \RuntimeException("Can not change session name in VirtualProxy"); - } +if (version_compare(\Composer\InstalledVersions::getVersion('symfony/http-foundation'), '6.0.0') === -1) { + include 'VirtualProxy<8.php'; +} else { + include 'VirtualProxy8+.php'; } diff --git a/src/Ratchet/Session/Storage/Proxy/VirtualProxy8+.php b/src/Ratchet/Session/Storage/Proxy/VirtualProxy8+.php new file mode 100644 index 00000000..a1f72d8a --- /dev/null +++ b/src/Ratchet/Session/Storage/Proxy/VirtualProxy8+.php @@ -0,0 +1,54 @@ +saveHandlerName = 'user'; + $this->_sessionName = ini_get('session.name'); + } + + /** + * {@inheritdoc} + */ + public function getId(): string { + return $this->_sessionId; + } + + /** + * {@inheritdoc} + */ + public function setId($id) { + $this->_sessionId = $id; + } + + /** + * {@inheritdoc} + */ + public function getName(): string { + return $this->_sessionName; + } + + /** + * DO NOT CALL THIS METHOD + * @internal + */ + public function setName($name) { + throw new \RuntimeException("Can not change session name in VirtualProxy"); + } +} diff --git a/src/Ratchet/Session/Storage/Proxy/VirtualProxy<8.php b/src/Ratchet/Session/Storage/Proxy/VirtualProxy<8.php new file mode 100644 index 00000000..b478d039 --- /dev/null +++ b/src/Ratchet/Session/Storage/Proxy/VirtualProxy<8.php @@ -0,0 +1,54 @@ +saveHandlerName = 'user'; + $this->_sessionName = ini_get('session.name'); + } + + /** + * {@inheritdoc} + */ + public function getId() { + return $this->_sessionId; + } + + /** + * {@inheritdoc} + */ + public function setId($id) { + $this->_sessionId = $id; + } + + /** + * {@inheritdoc} + */ + public function getName() { + return $this->_sessionName; + } + + /** + * DO NOT CALL THIS METHOD + * @internal + */ + public function setName($name) { + throw new \RuntimeException("Can not change session name in VirtualProxy"); + } +} diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage.php b/src/Ratchet/Session/Storage/VirtualSessionStorage.php index 5e3cee84..4859bd0a 100644 --- a/src/Ratchet/Session/Storage/VirtualSessionStorage.php +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage.php @@ -1,88 +1,7 @@ setSaveHandler($handler); - $this->saveHandler->setId($sessionId); - $this->_serializer = $serializer; - $this->setMetadataBag(null); - } - - /** - * {@inheritdoc} - */ - public function start(): bool { - if ($this->started && !$this->closed) { - return true; - } - - // You have to call Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::open() to use - // pdo_sqlite (and possible pdo_*) as session storage, if you are using a DSN string instead of a \PDO object - // in the constructor. The method arguments are filled with the values, which are also used by the symfony - // framework in this case. This must not be the best choice, but it works. - $this->saveHandler->open(session_save_path(), session_name()); - - $rawData = $this->saveHandler->read($this->saveHandler->getId()); - $sessionData = $this->_serializer->unserialize($rawData); - - $this->loadSession($sessionData); - - if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { - $this->saveHandler->setActive(false); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function regenerate($destroy = false, $lifetime = null) { - // .. ? - } - - /** - * {@inheritdoc} - */ - public function save() { - // get the data from the bags? - // serialize the data - // save the data using the saveHandler -// $this->saveHandler->write($this->saveHandler->getId(), - - if (!$this->saveHandler->isWrapper() && !$this->getSaveHandler()->isSessionHandlerInterface()) { - $this->saveHandler->setActive(false); - } - - $this->closed = true; - } - - /** - * {@inheritdoc} - */ - public function setSaveHandler($saveHandler = null) { - if (!($saveHandler instanceof \SessionHandlerInterface)) { - throw new \InvalidArgumentException('Handler must be instance of SessionHandlerInterface'); - } - - if (!($saveHandler instanceof VirtualProxy)) { - $saveHandler = new VirtualProxy($saveHandler); - } - - $this->saveHandler = $saveHandler; - } +if (version_compare(\Composer\InstalledVersions::getVersion('symfony/http-foundation'), '6.0.0') === -1) { + include 'VirtualSessionStorage<8.php'; +} else { + include 'VirtualSessionStorage8+.php'; } diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage8+.php b/src/Ratchet/Session/Storage/VirtualSessionStorage8+.php new file mode 100644 index 00000000..cf7f3e5f --- /dev/null +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage8+.php @@ -0,0 +1,81 @@ +setSaveHandler($handler); + $this->saveHandler->setId($sessionId); + $this->_serializer = $serializer; + $this->setMetadataBag(null); + } + + /** + * {@inheritdoc} + */ + public function start(): bool { + if ($this->started && !$this->closed) { + return true; + } + + // You have to call Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::open() to use + // pdo_sqlite (and possible pdo_*) as session storage, if you are using a DSN string instead of a \PDO object + // in the constructor. The method arguments are filled with the values, which are also used by the symfony + // framework in this case. This must not be the best choice, but it works. + $this->saveHandler->open(session_save_path(), session_name()); + + $rawData = $this->saveHandler->read($this->saveHandler->getId()); + $sessionData = $this->_serializer->unserialize($rawData); + + $this->loadSession($sessionData); + + if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { + $this->saveHandler->setActive(false); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function save() { + // get the data from the bags? + // serialize the data + // save the data using the saveHandler +// $this->saveHandler->write($this->saveHandler->getId(), + + if (!$this->saveHandler->isWrapper() && !$this->getSaveHandler()->isSessionHandlerInterface()) { + $this->saveHandler->setActive(false); + } + + $this->closed = true; + } + + /** + * {@inheritdoc} + */ + public function setSaveHandler($saveHandler = null) { + if (!($saveHandler instanceof \SessionHandlerInterface)) { + throw new \InvalidArgumentException('Handler must be instance of SessionHandlerInterface'); + } + + if (!($saveHandler instanceof VirtualProxy)) { + $saveHandler = new VirtualProxy($saveHandler); + } + + $this->saveHandler = $saveHandler; + } +} diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage<8.php b/src/Ratchet/Session/Storage/VirtualSessionStorage<8.php new file mode 100644 index 00000000..73140a61 --- /dev/null +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage<8.php @@ -0,0 +1,81 @@ +setSaveHandler($handler); + $this->saveHandler->setId($sessionId); + $this->_serializer = $serializer; + $this->setMetadataBag(null); + } + + /** + * {@inheritdoc} + */ + public function start() { + if ($this->started && !$this->closed) { + return true; + } + + // You have to call Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::open() to use + // pdo_sqlite (and possible pdo_*) as session storage, if you are using a DSN string instead of a \PDO object + // in the constructor. The method arguments are filled with the values, which are also used by the symfony + // framework in this case. This must not be the best choice, but it works. + $this->saveHandler->open(session_save_path(), session_name()); + + $rawData = $this->saveHandler->read($this->saveHandler->getId()); + $sessionData = $this->_serializer->unserialize($rawData); + + $this->loadSession($sessionData); + + if (!$this->saveHandler->isWrapper() && !$this->saveHandler->isSessionHandlerInterface()) { + $this->saveHandler->setActive(false); + } + + return true; + } + + /** + * {@inheritdoc} + */ + public function save() { + // get the data from the bags? + // serialize the data + // save the data using the saveHandler +// $this->saveHandler->write($this->saveHandler->getId(), + + if (!$this->saveHandler->isWrapper() && !$this->getSaveHandler()->isSessionHandlerInterface()) { + $this->saveHandler->setActive(false); + } + + $this->closed = true; + } + + /** + * {@inheritdoc} + */ + public function setSaveHandler($saveHandler = null) { + if (!($saveHandler instanceof \SessionHandlerInterface)) { + throw new \InvalidArgumentException('Handler must be instance of SessionHandlerInterface'); + } + + if (!($saveHandler instanceof VirtualProxy)) { + $saveHandler = new VirtualProxy($saveHandler); + } + + $this->saveHandler = $saveHandler; + } +} From dc69b2894a14d5d5d6b8061d2989779ee9144323 Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 15 May 2023 00:07:03 +1200 Subject: [PATCH 68/75] Update to horrible hack to allow symfony/http-foundation >= 6.0 while maintaining PHP < 7.0 support. --- src/Ratchet/Session/SessionProvider.php | 2 +- ...roxy8+.php => VirtualProxy-HttpFoundation6+.php} | 0 ...roxy<8.php => VirtualProxy-HttpFoundation<6.php} | 0 src/Ratchet/Session/Storage/Proxy/VirtualProxy.php | 13 +++++++++++-- ...p => VirtualSessionStorage-HttpFoundation6+.php} | 8 ++++++++ ...p => VirtualSessionStorage-HttpFoundation<6.php} | 7 +++++++ .../Session/Storage/VirtualSessionStorage.php | 13 +++++++++++-- 7 files changed, 38 insertions(+), 5 deletions(-) rename src/Ratchet/Session/Storage/Proxy/{VirtualProxy8+.php => VirtualProxy-HttpFoundation6+.php} (100%) rename src/Ratchet/Session/Storage/Proxy/{VirtualProxy<8.php => VirtualProxy-HttpFoundation<6.php} (100%) rename src/Ratchet/Session/Storage/{VirtualSessionStorage8+.php => VirtualSessionStorage-HttpFoundation6+.php} (94%) rename src/Ratchet/Session/Storage/{VirtualSessionStorage<8.php => VirtualSessionStorage-HttpFoundation<6.php} (95%) diff --git a/src/Ratchet/Session/SessionProvider.php b/src/Ratchet/Session/SessionProvider.php index 44276c54..30529949 100644 --- a/src/Ratchet/Session/SessionProvider.php +++ b/src/Ratchet/Session/SessionProvider.php @@ -12,7 +12,7 @@ * This component will allow access to session data from your website for each user connected * Symfony HttpFoundation is required for this component to work * Your website must also use Symfony HttpFoundation Sessions to read your sites session data - * If your are not using at least PHP 5.4 you must include a SessionHandlerInterface stub (is included in Symfony HttpFoundation, loaded w/ composer) + * If you're not using at least PHP 5.4 you must include a SessionHandlerInterface stub (is included in Symfony HttpFoundation, loaded w/ composer) */ class SessionProvider implements HttpServerInterface { /** diff --git a/src/Ratchet/Session/Storage/Proxy/VirtualProxy8+.php b/src/Ratchet/Session/Storage/Proxy/VirtualProxy-HttpFoundation6+.php similarity index 100% rename from src/Ratchet/Session/Storage/Proxy/VirtualProxy8+.php rename to src/Ratchet/Session/Storage/Proxy/VirtualProxy-HttpFoundation6+.php diff --git a/src/Ratchet/Session/Storage/Proxy/VirtualProxy<8.php b/src/Ratchet/Session/Storage/Proxy/VirtualProxy-HttpFoundation<6.php similarity index 100% rename from src/Ratchet/Session/Storage/Proxy/VirtualProxy<8.php rename to src/Ratchet/Session/Storage/Proxy/VirtualProxy-HttpFoundation<6.php diff --git a/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php b/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php index c42d3b04..167c654e 100644 --- a/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php +++ b/src/Ratchet/Session/Storage/Proxy/VirtualProxy.php @@ -1,7 +1,16 @@ = 6, include a class with return types + include 'VirtualProxy-HttpFoundation6+.php'; } diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage8+.php b/src/Ratchet/Session/Storage/VirtualSessionStorage-HttpFoundation6+.php similarity index 94% rename from src/Ratchet/Session/Storage/VirtualSessionStorage8+.php rename to src/Ratchet/Session/Storage/VirtualSessionStorage-HttpFoundation6+.php index cf7f3e5f..89b5f685 100644 --- a/src/Ratchet/Session/Storage/VirtualSessionStorage8+.php +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage-HttpFoundation6+.php @@ -48,6 +48,14 @@ public function start(): bool { return true; } + /** + * {@inheritdoc} + */ + public function regenerate($destroy = false, $lifetime = null): bool { + // .. ? + return false; + } + /** * {@inheritdoc} */ diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage<8.php b/src/Ratchet/Session/Storage/VirtualSessionStorage-HttpFoundation<6.php similarity index 95% rename from src/Ratchet/Session/Storage/VirtualSessionStorage<8.php rename to src/Ratchet/Session/Storage/VirtualSessionStorage-HttpFoundation<6.php index 73140a61..daa10bba 100644 --- a/src/Ratchet/Session/Storage/VirtualSessionStorage<8.php +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage-HttpFoundation<6.php @@ -48,6 +48,13 @@ public function start() { return true; } + /** + * {@inheritdoc} + */ + public function regenerate($destroy = false, $lifetime = null) { + // .. ? + } + /** * {@inheritdoc} */ diff --git a/src/Ratchet/Session/Storage/VirtualSessionStorage.php b/src/Ratchet/Session/Storage/VirtualSessionStorage.php index 4859bd0a..5a05327a 100644 --- a/src/Ratchet/Session/Storage/VirtualSessionStorage.php +++ b/src/Ratchet/Session/Storage/VirtualSessionStorage.php @@ -1,7 +1,16 @@ = 6, include a class with return types + include 'VirtualSessionStorage-HttpFoundation6+.php'; } From bc519b9dc48d2b3d2efed139dd313245056c93a0 Mon Sep 17 00:00:00 2001 From: Josh Date: Tue, 23 May 2023 19:53:45 +1200 Subject: [PATCH 69/75] Allow the WsConnection close function to include the optional reason. --- src/Ratchet/WebSocket/WsConnection.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Ratchet/WebSocket/WsConnection.php b/src/Ratchet/WebSocket/WsConnection.php index d2d04efa..265a7f29 100644 --- a/src/Ratchet/WebSocket/WsConnection.php +++ b/src/Ratchet/WebSocket/WsConnection.php @@ -25,9 +25,10 @@ public function send($msg) { } /** - * @param int|\Ratchet\RFC6455\Messaging\DataInterface + * @param int|\Ratchet\RFC6455\Messaging\DataInterface $code + * @param null|string $reason */ - public function close($code = 1000) { + public function close($code = 1000, $reason = null) { if ($this->WebSocket->closing) { return; } @@ -35,7 +36,17 @@ public function close($code = 1000) { if ($code instanceof DataInterface) { $this->send($code); } else { - $this->send(new Frame(pack('n', $code), true, Frame::OP_CLOSE)); + if (!is_string($reason)) { + $frame = new Frame(pack('n', $code), true, Frame::OP_CLOSE); + } else { + // Limit reason to 123 bytes to fit into the remainder of the 125 byte payload limit + while (strlen($reason) > 123) { + $reason = substr($reason, 0, -1); + } + $frame = new Frame(pack('nA*', $code, $reason), true, Frame::OP_CLOSE); + } + + $this->send($frame); } $this->getConnection()->close(); From 56a7c2ba1bbd72d5395123478d303223d4b3cb65 Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 16 Jul 2023 15:49:14 +1200 Subject: [PATCH 70/75] Update ci.yml Disable scheduled action run --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9a0434a..a6f86a3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,8 @@ on: push: branches: - "master" - schedule: - - cron: "42 3 * * *" + # schedule: + # - cron: "42 3 * * *" workflow_dispatch: jobs: From 4311014d8ad6c8827ed60d895df5f3917d519f7e Mon Sep 17 00:00:00 2001 From: Josh Date: Sun, 16 Jul 2023 15:49:52 +1200 Subject: [PATCH 71/75] Update ci.yml Disable scheduled action run --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c9a0434a..a6f86a3b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,8 @@ on: push: branches: - "master" - schedule: - - cron: "42 3 * * *" + # schedule: + # - cron: "42 3 * * *" workflow_dispatch: jobs: From be5e0726873b37f8f26b3fa9034568b45cfc06ae Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 10 Jan 2024 09:39:00 +1300 Subject: [PATCH 72/75] Add missing __isset function to the IoConnection class. --- src/Ratchet/Server/IoConnection.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Ratchet/Server/IoConnection.php b/src/Ratchet/Server/IoConnection.php index eb510778..a08036d3 100644 --- a/src/Ratchet/Server/IoConnection.php +++ b/src/Ratchet/Server/IoConnection.php @@ -25,7 +25,11 @@ public function __get($key) { return $this->properties[$key]; } } - + + public function __isset($key) { + return isset($this->properties[$key]); + } + /** * @param \React\Socket\ConnectionInterface $conn */ From 688b810eaea4d306de21319c9a27eea66034bff6 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 9 Aug 2024 16:58:11 +1200 Subject: [PATCH 73/75] refactor: switch to using a dynamic properties trait --- src/Ratchet/Http/HttpRequestParser.php | 37 +----------- src/Ratchet/Http/HttpServer.php | 38 +------------ src/Ratchet/Http/OriginCheck.php | 2 +- src/Ratchet/Http/Router.php | 6 +- src/Ratchet/Server/IoServer.php | 37 +----------- src/Ratchet/Traits/DynamicPropertiesTrait.php | 49 ++++++++++++++++ src/Ratchet/WebSocket/WsServer.php | 56 ++++--------------- 7 files changed, 73 insertions(+), 152 deletions(-) create mode 100644 src/Ratchet/Traits/DynamicPropertiesTrait.php diff --git a/src/Ratchet/Http/HttpRequestParser.php b/src/Ratchet/Http/HttpRequestParser.php index 6b8dea87..d0f51f27 100644 --- a/src/Ratchet/Http/HttpRequestParser.php +++ b/src/Ratchet/Http/HttpRequestParser.php @@ -3,6 +3,7 @@ use Ratchet\MessageInterface; use Ratchet\ConnectionInterface; use GuzzleHttp\Psr7\Message; +use Ratchet\Traits\DynamicPropertiesTrait; /** * This class receives streaming data from a client request @@ -10,6 +11,8 @@ * once it's been buffered */ class HttpRequestParser implements MessageInterface { + use DynamicPropertiesTrait; + const EOM = "\r\n\r\n"; /** @@ -19,40 +22,6 @@ class HttpRequestParser implements MessageInterface { */ public $maxSize = 4096; - /** - * Storage for dynamic properties. - * - * @var array - */ - protected $_properties = []; - - /** - * Allow setting dynamic properties. - * - * @param string $key - * @param mixed $value - * - * @return void - */ - public function __set($key, $value) { - if (property_exists($this, $key)) { - $this->_properties[$key] = $value; - } - } - - /** - * Get a property that has been declared dynamically - * - * @param string $key - * - * @return mixed|void - */ - public function __get($key) { - if (isset($this->_properties[$key])) { - return $this->_properties[$key]; - } - } - /** * @param \Ratchet\ConnectionInterface $context * @param string $data Data stream to buffer diff --git a/src/Ratchet/Http/HttpServer.php b/src/Ratchet/Http/HttpServer.php index 4ba5ebe0..3c50d463 100644 --- a/src/Ratchet/Http/HttpServer.php +++ b/src/Ratchet/Http/HttpServer.php @@ -1,10 +1,11 @@ _reqParser = new HttpRequestParser; } - /** - * Allow setting dynamic properties. - * - * @param string $key - * @param mixed $value - * - * @return void - */ - public function __set($key, $value) { - if (property_exists($this, $key)) { - $this->_properties[$key] = $value; - } - } - - /** - * Get a property that has been declared dynamically - * - * @param string $key - * - * @return mixed|void - */ - public function __get($key) { - if (isset($this->_properties[$key])) { - return $this->_properties[$key]; - } - } /** * {@inheritdoc} diff --git a/src/Ratchet/Http/OriginCheck.php b/src/Ratchet/Http/OriginCheck.php index 2bdc0f7c..9315456f 100644 --- a/src/Ratchet/Http/OriginCheck.php +++ b/src/Ratchet/Http/OriginCheck.php @@ -62,4 +62,4 @@ function onClose(ConnectionInterface $conn) { function onError(ConnectionInterface $conn, \Exception $e) { return $this->_component->onError($conn, $e); } -} \ No newline at end of file +} diff --git a/src/Ratchet/Http/Router.php b/src/Ratchet/Http/Router.php index 2bd5942f..2ee7cde2 100644 --- a/src/Ratchet/Http/Router.php +++ b/src/Ratchet/Http/Router.php @@ -1,11 +1,11 @@ on('connection', array($this, 'handleConnect')); } - /** - * Allow setting dynamic properties. - * - * @param string $key - * @param mixed $value - * - * @return void - */ - public function __set($key, $value) { - if (property_exists($this, $key)) { - $this->_properties[$key] = $value; - } - } - - /** - * Get a property that has been declared dynamically - * - * @param string $key - * - * @return mixed|void - */ - public function __get($key) { - if (isset($this->_properties[$key])) { - return $this->_properties[$key]; - } - } - /** * @param \Ratchet\MessageComponentInterface $component The application that I/O will call when events are received * @param int $port The port to server sockets on diff --git a/src/Ratchet/Traits/DynamicPropertiesTrait.php b/src/Ratchet/Traits/DynamicPropertiesTrait.php new file mode 100644 index 00000000..5ebeac47 --- /dev/null +++ b/src/Ratchet/Traits/DynamicPropertiesTrait.php @@ -0,0 +1,49 @@ +_dynamic_properties[$key] = $value; + } + } + + /** + * Get a property that has been declared dynamically + * + * @param string $key + * + * @return mixed|void + */ + public function __get($key) { + if (isset($this->_dynamic_properties[$key])) { + return $this->_dynamic_properties[$key]; + } + } + + /** + * @param $key + * + * @return bool + */ + public function __isset($key) { + return isset($this->_dynamic_properties[$key]); + } +} diff --git a/src/Ratchet/WebSocket/WsServer.php b/src/Ratchet/WebSocket/WsServer.php index 118c9c3b..477a099c 100644 --- a/src/Ratchet/WebSocket/WsServer.php +++ b/src/Ratchet/WebSocket/WsServer.php @@ -1,20 +1,21 @@ _properties[$key] = $value; - } - } - - /** - * Get a property that has been declared dynamically - * - * @param string $key - * - * @return mixed|void - */ - public function __get($key) { - if (isset($this->_properties[$key])) { - return $this->_properties[$key]; - } - } - /** * {@inheritdoc} */ From dc5edca9ef280dad341fe26e5c6c028fb8960e4d Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 9 Aug 2024 17:01:06 +1200 Subject: [PATCH 74/75] refactor: switch IoConnection to use the new dynamic properties trait --- src/Ratchet/Server/IoConnection.php | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/src/Ratchet/Server/IoConnection.php b/src/Ratchet/Server/IoConnection.php index a08036d3..4da176e6 100644 --- a/src/Ratchet/Server/IoConnection.php +++ b/src/Ratchet/Server/IoConnection.php @@ -1,35 +1,19 @@ properties[$key] = $value; - } - } - - public function __get($key) { - if (isset($this->properties[$key])) { - return $this->properties[$key]; - } - } - - public function __isset($key) { - return isset($this->properties[$key]); - } - /** * @param \React\Socket\ConnectionInterface $conn */ From 30959f5fb35830e3f67ffe2b5dcc76beefeec808 Mon Sep 17 00:00:00 2001 From: Josh Date: Fri, 9 Aug 2024 17:03:36 +1200 Subject: [PATCH 75/75] ci: re-enable running ci on a schedule --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6f86a3b..d880394c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,8 +5,8 @@ on: push: branches: - "master" - # schedule: - # - cron: "42 3 * * *" + schedule: + - cron: "42 3 * * *" workflow_dispatch: jobs: