From c1729107b860fc178261133e99194be0aa0eb60c Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Jul 2024 08:02:51 +0800 Subject: [PATCH 1/2] wip Signed-off-by: Mior Muhammad Zaki --- pint.json | 4 ++++ src/DuskServer.php | 2 +- src/Options.php | 8 ++++---- src/server.php | 2 +- tests/Unit/Concerns/CanServeSiteTest.php | 4 ++-- tests/Unit/DuskServerTest.php | 12 ++++++------ tests/Unit/ResolvesProjectRootTest.php | 4 ++-- 7 files changed, 20 insertions(+), 16 deletions(-) diff --git a/pint.json b/pint.json index 628bd22f..da9f100d 100644 --- a/pint.json +++ b/pint.json @@ -6,6 +6,10 @@ "scope": "namespaced", "strict": true }, + "new_with_parentheses": { + "named_class": false, + "anonymous_class": false + }, "no_superfluous_phpdoc_tags": false, "php_unit_method_casing": false, "nullable_type_declaration_for_default_null_value": { diff --git a/src/DuskServer.php b/src/DuskServer.php index 46ee4541..c84df170 100644 --- a/src/DuskServer.php +++ b/src/DuskServer.php @@ -253,7 +253,7 @@ protected function guardServerStarting() protected function prepareCommand(): array { return [ - (string) (new PhpExecutableFinder())->find(false), + (string) (new PhpExecutableFinder)->find(false), '-S', sprintf('%s:%s', $this->host, $this->port), __DIR__.'/server.php', diff --git a/src/Options.php b/src/Options.php index c93755d7..0d44780b 100644 --- a/src/Options.php +++ b/src/Options.php @@ -64,7 +64,7 @@ public static function using($callback) { static::$chromeOptionsCallback = $callback; - return new static(); + return new static; } /** @@ -78,7 +78,7 @@ public static function addArgument(string $argument) array_push(static::$arguments, $argument); } - return new static(); + return new static; } /** @@ -94,7 +94,7 @@ public static function removeArgument(string $argument) })); } - return new static(); + return new static; } /** @@ -232,7 +232,7 @@ public static function userAgent(string $useragent) */ public static function getChromeOptions() { - return tap(new ChromeOptions(), static function ($option) { + return tap(new ChromeOptions, static function ($option) { if (static::$w3cCompliant === false) { $option->setExperimentalOption('w3c', static::$w3cCompliant); } diff --git a/src/server.php b/src/server.php index e3af0a80..6393921c 100644 --- a/src/server.php +++ b/src/server.php @@ -32,7 +32,7 @@ /** @var class-string<\Orchestra\Testbench\Dusk\TestCase> $originatingTestClass */ $originatingTestClass = $orchestraServer->getStash('class'); -$app = (new $originatingTestClass())->createServingApplicationForDuskServer($orchestraServer); +$app = (new $originatingTestClass)->createServingApplicationForDuskServer($orchestraServer); // Emulation of mod_rewrite, but we use the applications set base path if ($uri !== '/' && file_exists($app->basePath().'/public'.$uri)) { diff --git a/tests/Unit/Concerns/CanServeSiteTest.php b/tests/Unit/Concerns/CanServeSiteTest.php index f5e63948..b252906a 100644 --- a/tests/Unit/Concerns/CanServeSiteTest.php +++ b/tests/Unit/Concerns/CanServeSiteTest.php @@ -12,7 +12,7 @@ class CanServeSiteTest extends TestCase /** @test * */ public function it_starts_and_stops_a_server() { - $dummy = new CanServeSiteDummy(); + $dummy = new CanServeSiteDummy; $dummy::serve('127.0.0.1', 8001); @@ -32,7 +32,7 @@ public function it_starts_and_stops_a_server() /** @test * */ public function it_stops_an_existing_server_and_starts_a_new_one_with_consecutive_serve_requests() { - $dummy = new CanServeSiteDummy(); + $dummy = new CanServeSiteDummy; $dummy::serve('127.0.0.1', 8001); diff --git a/tests/Unit/DuskServerTest.php b/tests/Unit/DuskServerTest.php index b0f03fda..0503fa42 100644 --- a/tests/Unit/DuskServerTest.php +++ b/tests/Unit/DuskServerTest.php @@ -12,14 +12,14 @@ public function it_provides_the_laravel_public_directory() { $this->assertEquals( realpath(__DIR__.'/../../laravel'), - (new DuskServer())->basePath() + (new DuskServer)->basePath() ); } /** @test */ public function it_provides_the_laravel_public_directory_from_custom_location() { - $server = new DuskServer(); + $server = new DuskServer; $server->setLaravel('/dir/project/laravel'); $this->assertEquals( @@ -32,8 +32,8 @@ public function it_provides_the_laravel_public_directory_from_custom_location() public function it_fails_when_there_is_a_server_on_the_host_and_port_already() { try { - $a = new DuskServer(); - $b = new DuskServer(); + $a = new DuskServer; + $b = new DuskServer; $a->start(); $this->waitForServerToStart(); @@ -68,7 +68,7 @@ public function an_early_exit_does_not_leave_an_orphan_server() // We have everything from the script so far available // So create a server and exit (to simluate a dd() or similar in a test) // Once complete, the parent can check for the orpahn server. - (new DuskServer())->start(); + (new DuskServer)->start(); $this->waitForServerToStart(); exit(); break; @@ -76,7 +76,7 @@ public function an_early_exit_does_not_leave_an_orphan_server() // @parent pcntl_waitpid($pid, $status); try { - (new DuskServer())->start(); + (new DuskServer)->start(); $this->assertTrue(true, 'We did not end up with an orphan server'); } catch (UnableToStartServer $e) { $this->fail('There was an orphan server. You\'ll need to remove it manually.'); diff --git a/tests/Unit/ResolvesProjectRootTest.php b/tests/Unit/ResolvesProjectRootTest.php index db859827..b3d5e30e 100644 --- a/tests/Unit/ResolvesProjectRootTest.php +++ b/tests/Unit/ResolvesProjectRootTest.php @@ -12,12 +12,12 @@ public function it_finds_the_correct_path_for_the_browser_tests() { $this->assertEquals( '/home/person/code/testbench-dusk/tests/Browser', - (new DummyTestCase())->resolveBrowserTestsPath('/home/person/code/testbench-dusk/src') + (new DummyTestCase)->resolveBrowserTestsPath('/home/person/code/testbench-dusk/src') ); $this->assertEquals( '/home/person/code/project/tests/Browser', - (new DummyTestCase())->resolveBrowserTestsPath('/home/person/code/project/vendor/orchestra/testbench-dusk/src') + (new DummyTestCase)->resolveBrowserTestsPath('/home/person/code/project/vendor/orchestra/testbench-dusk/src') ); } } From 1fa504229fe64749d6e8e50ad4f84b153555c411 Mon Sep 17 00:00:00 2001 From: Mior Muhammad Zaki Date: Wed, 24 Jul 2024 08:08:21 +0800 Subject: [PATCH 2/2] wip Signed-off-by: Mior Muhammad Zaki --- composer.json | 2 +- pint.json | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 70cd3193..236811e4 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "symfony/polyfill-php83": "^1.28" }, "require-dev": { - "laravel/pint": "^1.6", + "laravel/pint": "^1.17", "laravel/tinker": "^2.9", "phpstan/phpstan": "^1.11", "phpunit/phpunit": "^10.1" diff --git a/pint.json b/pint.json index da9f100d..628bd22f 100644 --- a/pint.json +++ b/pint.json @@ -6,10 +6,6 @@ "scope": "namespaced", "strict": true }, - "new_with_parentheses": { - "named_class": false, - "anonymous_class": false - }, "no_superfluous_phpdoc_tags": false, "php_unit_method_casing": false, "nullable_type_declaration_for_default_null_value": {