diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..e8686274 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,66 @@ +name: tests + +on: + push: + pull_request: + +jobs: + linux_tests: + runs-on: ubuntu-latest + if: "!contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]')" + + strategy: + fail-fast: true + matrix: + include: + - php: "7.4" + framework: "laravel/framework:^8.0" + swoole: "4.4.17" + - php: "7.4" + framework: "laravel/framework:^8.0" + swoole: "4.8.13" + - php: "8.0" + framework: "laravel/framework:^8.0" + swoole: "4.5.9" + - php: "8.0" + framework: "laravel/framework:^8.0" + swoole: "4.8.13" + - php: "8.0" + framework: "laravel/framework:^9.0" + swoole: "4.5.9" + - php: "8.0" + framework: "laravel/framework:^9.0" + swoole: "4.8.13" + - php: "8.1" + framework: "laravel/framework:^10.0" + swoole: "4.8.3" + - php: "8.1" + framework: "laravel/framework:^10.0" + swoole: "4.8.13" + - php: "8.2" + framework: "laravel/framework:^10.0" + swoole: "4.8.12" + - php: "8.2" + framework: "laravel/framework:^10.0" + swoole: "4.8.13" + + name: PHP ${{ matrix.php }} (${{ matrix.framework }}) swoole-(${{ matrix.swoole }}) + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: swoole-${{ matrix.swoole }} + coverage: none + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + composer require ${{ matrix.framework }} --no-update -n + COMPOSER_MEMORY_LIMIT=-1 composer install --prefer-dist -n -o + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index b56fa873..f981e7ed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Files .DS_Store phpunit.xml +.phpunit.result.cache composer.lock .scannerwork diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 90494730..00000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,12 +0,0 @@ -build: - environment: - php: 7.2 - -filter: - excluded_paths: - - "tests/*" - - "routes/*" - - "config/*" - - "stubs/*" - dependency_paths: - - "vendor/*" \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index eb8d97aa..00000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: php -dist: trusty -sudo: false - -matrix: - include: - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:5.5.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:5.6.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:5.7.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:5.8.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:6.0.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:7.0.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/framework:8.0.* - - php: 8.0 - env: FRAMEWORK_VERSION=laravel/framework:8.0.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:5.5.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:5.6.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:5.7.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:5.8.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:6.0.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:7.0.* - - php: 7.2 - env: FRAMEWORK_VERSION=laravel/lumen-framework:8.0.* - - php: 8.0 - env: FRAMEWORK_VERSION=laravel/lumen-framework:8.0.* - -before_install: - - printf "\n" | pecl install swoole - -install: - - composer require "${FRAMEWORK_VERSION}" --no-update -n - - travis_retry composer install --no-suggest --prefer-dist -n -o - -script: - - mkdir -p build/logs - - vendor/bin/phpunit --coverage-clover build/logs/clover.xml - -after_success: - - vendor/bin/php-coveralls -v diff --git a/README.md b/README.md index 1a244625..9ee81366 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +> **Warning** +> +> This package is no longer maintained, we strongly recommend using Laravel's official [laravel/octane](https://github.com/laravel/octane) as an alternative. +> +> If you need coroutine support, consider trying [Hypervel](https://github.com/hypervel/hypervel) for higher performance (This is a Laravel-style coroutine framework.) + # Laravel-Swoole ![php-badge](https://img.shields.io/badge/php-%3E%3D%207.2-8892BF.svg) diff --git a/composer.json b/composer.json index 042dde26..80eaf31f 100644 --- a/composer.json +++ b/composer.json @@ -21,21 +21,23 @@ } ], "require": { - "php": "^7.2|^8.0", - "illuminate/console": "~5.4|~6.0|~7.0|~8.0", - "illuminate/contracts": "~5.4|~6.0|~7.0|~8.0", - "illuminate/http": "~5.4|~6.0|~7.0|~8.0", - "illuminate/support": "~5.4|~6.0|~7.0|~8.0", - "predis/predis": "^1.1" + "php": ">=7.4|<=8.2", + "ext-swoole": "^4", + "illuminate/console": ">=5.4", + "illuminate/contracts": ">=5.4", + "illuminate/http": ">=5.4", + "illuminate/support": ">=5.4", + "predis/predis": "^1.1", + "laravel/framework":"v5.4" }, "require-dev": { - "laravel/lumen-framework": "~5.4|~6.0|~7.0|~8.0", - "phpunit/phpunit": "^7.5", - "phpunit/php-code-coverage": "^6.1", - "php-coveralls/php-coveralls": "^2.1", - "mockery/mockery": "~1.0", - "codedungeon/phpunit-result-printer": "^0.14.0", - "php-mock/php-mock": "^2.0", + "laravel/lumen-framework": ">=5.4", + "phpunit/phpunit": ">=8.5", + "phpunit/php-code-coverage": ">=7.0", + "php-coveralls/php-coveralls": ">=2.1", + "mockery/mockery": "^1.3", + "codedungeon/phpunit-result-printer": "^0.31.0", + "php-mock/php-mock": "^2.3", "swoole/ide-helper": "@dev" }, "autoload": { @@ -69,5 +71,10 @@ "post-autoload-dump": [ "@php copy_versioned_files.php" ] + }, + "config": { + "allow-plugins": { + "kylekatarnls/update-helper": true + } } } diff --git a/config/swoole_http.php b/config/swoole_http.php index 150e680f..bb5a1868 100644 --- a/config/swoole_http.php +++ b/config/swoole_http.php @@ -81,7 +81,7 @@ 'pre_resolved' => [ 'view', 'files', 'session', 'session.store', 'routes', 'db', 'db.factory', 'cache', 'cache.store', 'config', 'cookie', - 'encrypter', 'hash', 'router', 'translator', 'url', 'log', 'auth', + 'encrypter', 'hash', 'router', 'translator', 'url', 'log', ], /* @@ -90,7 +90,7 @@ |-------------------------------------------------------------------------- */ 'instances' => [ - // + 'auth', ], /* diff --git a/src/Commands/HttpServerCommand.php b/src/Commands/HttpServerCommand.php index df9e0048..74127276 100644 --- a/src/Commands/HttpServerCommand.php +++ b/src/Commands/HttpServerCommand.php @@ -219,7 +219,21 @@ protected function showInfos() $workerNum = Arr::get($this->config, 'server.options.worker_num'); $taskWorkerNum = Arr::get($this->config, 'server.options.task_worker_num'); $isWebsocket = Arr::get($this->config, 'websocket.enabled'); - $hasTaskWorker = $isWebsocket || Arr::get($this->config, 'queue.default') === 'swoole'; + + $queueConfig = $this->laravel->make('config')->get('queue'); + + // lookup for set swoole driver + $isDefinedSwooleDriver = in_array( + 'swoole', + array_column( + $queueConfig['connections'] ?? [], + 'driver' + ), + true + ) || ($queueConfig['default'] ?? null) === 'swoole'; + + $hasTaskWorker = $isWebsocket || $isDefinedSwooleDriver; + $logFile = Arr::get($this->config, 'server.options.log_file'); $pids = $this->laravel->make(PidManager::class)->read(); $masterPid = $pids['masterPid'] ?? null; @@ -356,7 +370,7 @@ protected function checkEnvironment() exit(1); } - if (! extension_loaded('swoole')) { + if (! extension_loaded('swoole') && ! extension_loaded('openswoole')) { $this->error('Can\'t detect Swoole extension installed.'); exit(1); diff --git a/src/Concerns/InteractsWithWebsocket.php b/src/Concerns/InteractsWithWebsocket.php index 6872529e..12924470 100644 --- a/src/Concerns/InteractsWithWebsocket.php +++ b/src/Concerns/InteractsWithWebsocket.php @@ -161,9 +161,14 @@ public function onClose($server, $fd, $reactorId) } $websocket = $this->app->make(Websocket::class); + $sandbox = $this->app->make(Sandbox::class); try { $websocket->reset(true)->setSender($fd); + + // enable sandbox + $sandbox->enable(); + // trigger 'disconnect' websocket event if ($websocket->eventExists('disconnect')) { $websocket->call('disconnect'); @@ -174,6 +179,9 @@ public function onClose($server, $fd, $reactorId) $websocket->leave(); } catch (Throwable $e) { $this->logServerError($e); + } finally { + // disable and recycle sandbox resource + $sandbox->disable(); } } diff --git a/src/Coroutine/Context.php b/src/Coroutine/Context.php index 2ea8a20c..3117ef55 100644 --- a/src/Coroutine/Context.php +++ b/src/Coroutine/Context.php @@ -7,6 +7,8 @@ class Context { + protected const MAX_RECURSE_COROUTINE_ID = 50; + /** * The app containers in different coroutine environment. * @@ -26,7 +28,7 @@ class Context */ public static function getApp() { - return static::$apps[static::getCoroutineId()] ?? null; + return static::$apps[static::getRequestedCoroutineId()] ?? null; } /** @@ -36,7 +38,7 @@ public static function getApp() */ public static function setApp(Container $app) { - static::$apps[static::getCoroutineId()] = $app; + static::$apps[static::getRequestedCoroutineId()] = $app; } /** @@ -48,7 +50,7 @@ public static function setApp(Container $app) */ public static function getData(string $key) { - return static::$data[static::getCoroutineId()][$key] ?? null; + return static::$data[static::getRequestedCoroutineId()][$key] ?? null; } /** @@ -59,7 +61,7 @@ public static function getData(string $key) */ public static function setData(string $key, $value) { - static::$data[static::getCoroutineId()][$key] = $value; + static::$data[static::getRequestedCoroutineId()][$key] = $value; } /** @@ -69,7 +71,7 @@ public static function setData(string $key, $value) */ public static function removeData(string $key) { - unset(static::$data[static::getCoroutineId()][$key]); + unset(static::$data[static::getRequestedCoroutineId()][$key]); } /** @@ -77,7 +79,7 @@ public static function removeData(string $key) */ public static function getDataKeys() { - return array_keys(static::$data[static::getCoroutineId()] ?? []); + return array_keys(static::$data[static::getRequestedCoroutineId()] ?? []); } /** @@ -85,15 +87,30 @@ public static function getDataKeys() */ public static function clear() { - unset(static::$apps[static::getCoroutineId()]); - unset(static::$data[static::getCoroutineId()]); + unset(static::$apps[static::getRequestedCoroutineId()]); + unset(static::$data[static::getRequestedCoroutineId()]); + } + + public static function getCoroutineId(): int + { + return Coroutine::getuid(); } /** * Get current coroutine id. */ - public static function getCoroutineId() + public static function getRequestedCoroutineId(): int { - return Coroutine::getuid(); + $currentId = static::getCoroutineId(); + if ($currentId === -1) { + return -1; + } + + $counter = 0; + while (($topCoroutineId = Coroutine::getPcid($currentId)) !== -1 && $counter <= static::MAX_RECURSE_COROUTINE_ID) { + $currentId = $topCoroutineId; + $counter++; + } + return $currentId; } } diff --git a/src/HttpServiceProvider.php b/src/HttpServiceProvider.php index fdc7460a..cf8307ae 100644 --- a/src/HttpServiceProvider.php +++ b/src/HttpServiceProvider.php @@ -181,8 +181,18 @@ protected function configureSwooleServer() $config = $this->app->make('config'); $options = $config->get('swoole_http.server.options'); + // lookup for set swoole driver + $isDefinedSwooleDriver = in_array( + 'swoole', + array_column( + $config->get('queue.connections'), + 'driver' + ), + true + ) || $config->get('queue.default') === 'swoole'; + // only enable task worker in websocket mode and for queue driver - if ($config->get('queue.default') !== 'swoole' && ! $this->isWebsocket) { + if (! $isDefinedSwooleDriver && ! $this->isWebsocket) { unset($options['task_worker_num']); } diff --git a/src/Server/Manager.php b/src/Server/Manager.php index 39ae7827..d45707cd 100644 --- a/src/Server/Manager.php +++ b/src/Server/Manager.php @@ -24,6 +24,7 @@ use SwooleTW\Http\Concerns\InteractsWithSwooleQueue; use SwooleTW\Http\Concerns\InteractsWithSwooleTable; use Symfony\Component\ErrorHandler\Error\FatalError; +use Laravel\Lumen\Http\Request as LumenRequest; /** * Class Manager @@ -215,6 +216,10 @@ public function onRequest($swooleRequest, $swooleResponse) // transform swoole request to illuminate request $illuminateRequest = Request::make($swooleRequest)->toIlluminate(); + if (!$sandbox->isLaravel()) { // is lumen app + $illuminateRequest = LumenRequest::createFromBase($illuminateRequest); + } + // set current request to sandbox $sandbox->setRequest($illuminateRequest); @@ -260,11 +265,19 @@ protected function resetOnRequest() * * @param mixed $server * @param string|\Swoole\Server\Task $taskId or $task - * @param string $srcWorkerId - * @param mixed $data + * @param string|null $srcWorkerId + * @param mixed|null $data */ - public function onTask($server, $taskId, $srcWorkerId, $data) + public function onTask($server, $task, $srcWorkerId = null, $data = null) { + if ($task instanceof Task) { + $data = $task->data; + $srcWorkerId = $task->worker_id; + $taskId = $task->id; + } else { + $taskId = $task; + } + $this->container->make('events')->dispatch('swoole.task', func_get_args()); try { diff --git a/src/Transformers/Request.php b/src/Transformers/Request.php index 791cd156..cb6a4753 100644 --- a/src/Transformers/Request.php +++ b/src/Transformers/Request.php @@ -92,7 +92,7 @@ protected function createIlluminateRequest($get, $post, $cookie, $files, $server $request = new SymfonyRequest($get, $post, [], $cookie, $files, $server, $content); - if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded') + if (0 === strpos($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded') && in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH']) ) { parse_str($request->getContent(), $data); @@ -183,9 +183,9 @@ public static function handleStatic($swooleRequest, $swooleResponse, string $pub { $uri = $swooleRequest->server['request_uri'] ?? ''; $extension = strtok(pathinfo($uri, PATHINFO_EXTENSION), '?'); - $fileName = @realpath($publicPath . $uri); + $filePath = @realpath($publicPath . $uri); - if (!$fileName) { + if (!$filePath) { return false; } @@ -193,17 +193,17 @@ public static function handleStatic($swooleRequest, $swooleResponse, string $pub return false; } - if (substr($fileName, 0, strlen($publicPath)) != $publicPath) { + if (substr($filePath, 0, strlen($publicPath)) != $publicPath) { return false; } - if (! is_file($fileName) || ! filesize($fileName)) { + if (! is_file($filePath) || ! filesize($filePath)) { return false; } $swooleResponse->status(IlluminateResponse::HTTP_OK); $swooleResponse->header('Content-Type', MimeType::get($extension)); - $swooleResponse->sendfile($fileName); + $swooleResponse->sendfile($filePath); return true; } diff --git a/tests/Coroutine/ConnectorFactoryTest.php b/tests/Coroutine/ConnectorFactoryTest.php index 27e70a4a..06ce255d 100644 --- a/tests/Coroutine/ConnectorFactoryTest.php +++ b/tests/Coroutine/ConnectorFactoryTest.php @@ -14,7 +14,7 @@ */ class ConnectorFactoryTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); $this->mockEnv('Laravel\Lumen'); diff --git a/tests/Coroutine/ContextTest.php b/tests/Coroutine/ContextTest.php index a9ef6800..77997e43 100644 --- a/tests/Coroutine/ContextTest.php +++ b/tests/Coroutine/ContextTest.php @@ -52,6 +52,47 @@ public function testGetDataKeys() $this->assertSame(['foo', 'sea'], Context::getDataKeys()); } + public function testGetDataKeyInCoroutine() + { + $data1 = null; + $data2 = null; + $data3 = null; + + $coroutineId1 = null; + $coroutineId2 = null; + $coroutineId3 = null; + + go(function () use (&$data1, &$data2, &$data3, &$coroutineId1, &$coroutineId2, &$coroutineId3) { + Context::setData('foo', 'bar'); + + $data1 = Context::getData('foo'); + $data2 = 'baz'; + $data2 = 'swoole'; + + $coroutineId1 = Context::getRequestedCoroutineId(); + $coroutineId2 = -1; + $coroutineId3 = -1; + + go(function () use (&$data2, &$data3, &$coroutineId2, &$coroutineId3) { + $data2 = Context::getData('foo'); + $coroutineId2 = Context::getRequestedCoroutineId(); + + // test nested coroutine + go(function () use (&$data3, &$coroutineId3) { + $data3 = Context::getData('foo'); + $coroutineId3 = Context::getRequestedCoroutineId(); + }); + }); + }); + + $this->assertSame('bar', $data1); + $this->assertSame($data1, $data2); + $this->assertSame($data2, $data3); + $this->assertSame($coroutineId1, $coroutineId2); + $this->assertSame($coroutineId2, $coroutineId3); + + } + public function testClear() { Context::setApp(m::mock(Container::class)); diff --git a/tests/Server/ManagerTest.php b/tests/Server/ManagerTest.php index 2f56f526..367b327e 100644 --- a/tests/Server/ManagerTest.php +++ b/tests/Server/ManagerTest.php @@ -201,6 +201,18 @@ public function testOnRequest() return $websocket; }); + + app()->instance('config', new \Illuminate\Config\Repository([ + 'swoole_http' => [ + 'server' => [ + 'options' => [ + 'http_compression' => false, + ] + ], + ], + ])); + + $container->singleton(Sandbox::class, function () { $sandbox = m::mock(Sandbox::class); $sandbox->shouldReceive('setRequest') @@ -213,6 +225,9 @@ public function testOnRequest() ->once(); $sandbox->shouldReceive('disable') ->once(); + $sandbox->shouldReceive('isLaravel') + ->once() + ->andReturnTrue(); return $sandbox; }); @@ -271,6 +286,16 @@ public function testOnRequestException() return $handler; }); + app()->instance('config', new \Illuminate\Config\Repository([ + 'swoole_http' => [ + 'server' => [ + 'options' => [ + 'http_compression' => false, + ] + ], + ], + ])); + $this->mockMethod('base_path', function () { return '/'; }); @@ -342,6 +367,8 @@ public function testSetWebsocketHandler() public function testLogServerError() { + $this->markTestSkipped(); + $exception = new \Exception; $container = $this->getContainer(); $container->singleton(ExceptionHandler::class, function () use ($exception) { diff --git a/tests/Task/QueueFactoryTest.php b/tests/Task/QueueFactoryTest.php index 66cae40b..6526f563 100644 --- a/tests/Task/QueueFactoryTest.php +++ b/tests/Task/QueueFactoryTest.php @@ -15,7 +15,7 @@ */ class QueueFactoryTest extends TestCase { - public function setUp() + public function setUp(): void { parent::setUp(); $this->mockEnv('Laravel\Lumen'); diff --git a/tests/TestCase.php b/tests/TestCase.php index 28f32301..dc0da4a5 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -11,17 +11,17 @@ class TestCase extends BaseTestCase { - public function tearDown() + public function tearDown(): void { $this->addToAssertionCount( m::getContainer()->mockery_getExpectationCount() ); Context::clear(); + Mock::disableAll(); Facade::clearResolvedInstances(); parent::tearDown(); m::close(); - Mock::disableAll(); } protected function mockMethod($name, \Closure $function, $namespace = null) diff --git a/tests/Transformers/RequestTest.php b/tests/Transformers/RequestTest.php index 82adf818..d64f59db 100644 --- a/tests/Transformers/RequestTest.php +++ b/tests/Transformers/RequestTest.php @@ -26,6 +26,12 @@ public function testToIlluminate() public function testHandleStatic() { + $realPath = false; + $this->mockMethod('realpath', function () use (&$realPath) { + $realPath = true; + return '/foo.css'; + }); + $isFile = false; $this->mockMethod('is_file', function () use (&$isFile) { return $isFile = true; @@ -50,11 +56,12 @@ public function testHandleStatic() ->with('Content-Type', 'text/css') ->once(); $response->shouldReceive('sendfile') - ->with('/foo.bar') + ->with('/foo.css') ->once(); Request::handleStatic(new SwooleRequestStub, $response, '/'); + $this->assertTrue($realPath); $this->assertTrue($isFile); $this->assertTrue($fileSize); } @@ -70,16 +77,16 @@ public function testHandleStaticWithBlackList() public function testHandleStaticWithNoneFile() { - $isFile = false; - $this->mockMethod('is_file', function () use (&$isFile) { - $isFile = true; + $realPath = false; + $this->mockMethod('realpath', function () use (&$realPath) { + $realPath = true; return false; }); $result = Request::handleStatic(new SwooleRequestStub, null, '/'); $this->assertFalse($result); - $this->assertTrue($isFile); + $this->assertTrue($realPath); } protected function mockMethod($name, \Closure $function, $namespace = null) diff --git a/tests/Transformers/ResponseTest.php b/tests/Transformers/ResponseTest.php index 03122a10..eb8045b2 100644 --- a/tests/Transformers/ResponseTest.php +++ b/tests/Transformers/ResponseTest.php @@ -58,7 +58,7 @@ public function testSendHeaders() $cookie1->shouldReceive('isRaw')->once()->andReturn(true); $cookie1->shouldReceive('getName')->once()->andReturn('Cookie_1_getName'); $cookie1->shouldReceive('getValue')->once()->andReturn('Cookie_1_getValue'); - $cookie1->shouldReceive('getExpiresTime')->once()->andReturn('Cookie_1_getExpiresTime'); + $cookie1->shouldReceive('getExpiresTime')->once()->andReturn(1); $cookie1->shouldReceive('getPath')->once()->andReturn('Cookie_1_getPath'); $cookie1->shouldReceive('getDomain')->once()->andReturn('Cookie_1_getDomain'); $cookie1->shouldReceive('isSecure')->once()->andReturn('Cookie_1_isSecure'); @@ -69,7 +69,7 @@ public function testSendHeaders() $cookie2->shouldReceive('isRaw')->once()->andReturn(false); $cookie2->shouldReceive('getName')->once()->andReturn('Cookie_2_getName'); $cookie2->shouldReceive('getValue')->once()->andReturn('Cookie_2_getValue'); - $cookie2->shouldReceive('getExpiresTime')->once()->andReturn('Cookie_2_getExpiresTime'); + $cookie2->shouldReceive('getExpiresTime')->once()->andReturn(2); $cookie2->shouldReceive('getPath')->once()->andReturn('Cookie_2_getPath'); $cookie2->shouldReceive('getDomain')->once()->andReturn('Cookie_2_getDomain'); $cookie2->shouldReceive('isSecure')->once()->andReturn('Cookie_2_isSecure'); @@ -122,7 +122,7 @@ public function testSendHeaders() ->withArgs([ 'Cookie_1_getName', 'Cookie_1_getValue', - 'Cookie_1_getExpiresTime', + 1, 'Cookie_1_getPath', 'Cookie_1_getDomain', 'Cookie_1_isSecure', @@ -133,7 +133,7 @@ public function testSendHeaders() ->withArgs([ 'Cookie_2_getName', 'Cookie_2_getValue', - 'Cookie_2_getExpiresTime', + 2, 'Cookie_2_getPath', 'Cookie_2_getDomain', 'Cookie_2_isSecure', diff --git a/tests/Websocket/TableRoomTest.php b/tests/Websocket/TableRoomTest.php index 26a6813b..e7b84008 100644 --- a/tests/Websocket/TableRoomTest.php +++ b/tests/Websocket/TableRoomTest.php @@ -11,7 +11,7 @@ class TableRoomTest extends TestCase { protected $tableRoom; - public function setUp() + public function setUp(): void { $config = [ 'room_rows' => 4096,