From cc6f3bd585ea84d46910c2fb711bc3afcb6fc453 Mon Sep 17 00:00:00 2001 From: Derek Date: Sun, 20 Oct 2024 12:59:02 -0400 Subject: [PATCH] refactor: Remove TogglesHeadlessMode redundant methods https://github.com/laravel/dusk/pull/1098 Laravel Dusk 8.x now defines these methods in class Laravel\Dusk\TestCase so the stub classes that extend TestCase don't need to redefine hasHeadlessDisabled() and shouldStartMaximized(). --- src/Concerns/TogglesHeadlessMode.php | 22 ---------------------- tests/Stubs/TogglesHeadlessStub.php | 28 ++++++++++++++++++++++++++++ tests/TogglesHeadlessModeTest.php | 10 ++++------ 3 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 tests/Stubs/TogglesHeadlessStub.php diff --git a/src/Concerns/TogglesHeadlessMode.php b/src/Concerns/TogglesHeadlessMode.php index 57e4a17..b4df78e 100644 --- a/src/Concerns/TogglesHeadlessMode.php +++ b/src/Concerns/TogglesHeadlessMode.php @@ -19,26 +19,4 @@ protected function filterHeadlessArguments(array $args = []) ]); })->values()->all(); } - - /** - * Determine whether the Dusk command has disabled headless mode. - * - * @return bool - */ - protected function hasHeadlessDisabled() - { - return isset($_SERVER['DUSK_HEADLESS_DISABLED']) || - isset($_ENV['DUSK_HEADLESS_DISABLED']); - } - - /** - * Determine if the browser window should start maximized. - * - * @return bool - */ - protected function shouldStartMaximized() - { - return isset($_SERVER['DUSK_START_MAXIMIZED']) || - isset($_ENV['DUSK_START_MAXIMIZED']); - } } diff --git a/tests/Stubs/TogglesHeadlessStub.php b/tests/Stubs/TogglesHeadlessStub.php new file mode 100644 index 0000000..c7db6c6 --- /dev/null +++ b/tests/Stubs/TogglesHeadlessStub.php @@ -0,0 +1,28 @@ +filterHeadlessArgumentsProtected($args); + } +} diff --git a/tests/TogglesHeadlessModeTest.php b/tests/TogglesHeadlessModeTest.php index 5db829d..d218fb0 100644 --- a/tests/TogglesHeadlessModeTest.php +++ b/tests/TogglesHeadlessModeTest.php @@ -2,14 +2,12 @@ namespace Derekmd\Dusk\Tests; -use Derekmd\Dusk\Concerns\TogglesHeadlessMode; +use Derekmd\Dusk\Tests\Stubs\TogglesHeadlessStub; use PHPUnit\Framework\TestCase; class TogglesHeadlessModeTest extends TestCase { - use TogglesHeadlessMode; - - protected function tearDown() : void + protected function tearDown(): void { unset($_ENV['DUSK_HEADLESS_DISABLED']); @@ -20,7 +18,7 @@ public function test_building_arguments_with_headless_mode() { unset($_ENV['DUSK_HEADLESS_DISABLED']); - $args = $this->filterHeadlessArguments([ + $args = (new TogglesHeadlessStub)->filterHeadlessArguments([ '--disable-gpu', '--headless', '--window-size=1920,1080', @@ -37,7 +35,7 @@ public function test_building_arguments_when_headless_mode_is_disabled() { $_ENV['DUSK_HEADLESS_DISABLED'] = true; - $args = $this->filterHeadlessArguments([ + $args = (new TogglesHeadlessStub)->filterHeadlessArguments([ '--disable-gpu', '--headless', '--window-size=1920,1080',