From 8098e8c48f2b0fc54abf7811c2ac8b71cb904346 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 19 Sep 2025 21:52:37 +0100 Subject: [PATCH 1/6] stan --- composer.json | 2 +- src/DomAssertionsServiceProvider.php | 6 ++---- src/TestComponentMacros.php | 16 ++++++++-------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/composer.json b/composer.json index 25d983a..1e3b2a0 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "symfony/css-selector": "^6.0|^7.0" }, "require-dev": { - "laravel/pint": "^1.2", + "laravel/pint": "^v1.25.1", "larastan/larastan": "^2.0|^3.0", "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", "pestphp/pest": "^1.0|^2.34|^3.7", diff --git a/src/DomAssertionsServiceProvider.php b/src/DomAssertionsServiceProvider.php index 78305c4..4ba02b0 100644 --- a/src/DomAssertionsServiceProvider.php +++ b/src/DomAssertionsServiceProvider.php @@ -3,7 +3,6 @@ namespace Sinnbeck\DomAssertions; use Illuminate\Support\ServiceProvider; -use Illuminate\Support\Traits\Macroable; use Illuminate\Testing\TestComponent; use Illuminate\Testing\TestResponse; use Illuminate\Testing\TestView; @@ -15,9 +14,8 @@ public function boot() if ($this->app->runningUnitTests()) { TestResponse::mixin(new TestResponseMacros); TestView::mixin(new TestViewMacros); - - // https://github.com/laravel/framework/pull/54359 - if (in_array(Macroable::class, class_uses(TestComponent::class) ?? [])) { + if (version_compare($this->app->version(), '11.41.0', '>=')) { + // @phpstan-ignore-next-line TestComponent::mixin(new TestComponentMacros); } } diff --git a/src/TestComponentMacros.php b/src/TestComponentMacros.php index 3156cd4..8900707 100644 --- a/src/TestComponentMacros.php +++ b/src/TestComponentMacros.php @@ -24,12 +24,12 @@ public function assertHtml5(): Closure return function () { /** @var TestComponent $this */ Assert::assertNotEmpty( - (string) $this->rendered, + (string) $this, 'The component is empty!' ); try { - $parser = DomParser::new((string) $this->rendered); + $parser = DomParser::new((string) $this); } catch (DOMException $exception) { Assert::fail($exception->getMessage()); } @@ -49,12 +49,12 @@ public function assertElementExists(): Closure return function ($selector = 'body', $callback = null): TestComponent { /** @var TestComponent $this */ Assert::assertNotEmpty( - (string) $this->rendered, + (string) $this, 'The component is empty!' ); try { - $parser = DomParser::new((string) $this->rendered); + $parser = DomParser::new((string) $this); } catch (DOMException $exception) { Assert::fail($exception->getMessage()); } @@ -73,7 +73,7 @@ public function assertElementExists(): Closure Assert::assertNotNull($element, sprintf('No element found with selector: %s', $selector)); if ($callback) { - $callback(new AssertElement((string) $this->rendered, $element)); + $callback(new AssertElement((string) $this, $element)); } return $this; @@ -85,12 +85,12 @@ public function assertFormExists(): Closure return function ($selector = 'form', $callback = null): TestComponent { /** @var TestComponent $this */ Assert::assertNotEmpty( - (string) $this->rendered, + (string) $this, 'The component is empty!' ); try { - $parser = DomParser::new((string) $this->rendered); + $parser = DomParser::new((string) $this); } catch (DOMException $exception) { Assert::fail($exception->getMessage()); } @@ -116,7 +116,7 @@ public function assertFormExists(): Closure 'Element is not of type form!'); if ($callback) { - $callback(new AssertForm((string) $this->rendered, $form)); + $callback(new AssertForm((string) $this, $form)); } return $this; From 93176a766f9e597f61fb7e7a19f774a66c815516 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 19 Sep 2025 21:58:07 +0100 Subject: [PATCH 2/6] ignore pint lad --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1e3b2a0..25d983a 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "symfony/css-selector": "^6.0|^7.0" }, "require-dev": { - "laravel/pint": "^v1.25.1", + "laravel/pint": "^1.2", "larastan/larastan": "^2.0|^3.0", "orchestra/testbench": "^7.0|^8.0|^9.0|^10.0", "pestphp/pest": "^1.0|^2.34|^3.7", From a95dbe15eb6dd3cdd7c67f0629bcf43045538058 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 19 Sep 2025 21:59:22 +0100 Subject: [PATCH 3/6] test test --- .github/workflows/run-tests.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 4fe3698..beba3fb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,12 +1,6 @@ name: Run all tests -on: - push: - branches: - - main - pull_request: - branches: - - main +on: [push] jobs: test: From 04f6bb73ae6bd82970d5a7f23cde3cebe532fba0 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 19 Sep 2025 22:04:20 +0100 Subject: [PATCH 4/6] may as well --- tests/ComponentTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ComponentTest.php b/tests/ComponentTest.php index bfd02e0..01ffc62 100644 --- a/tests/ComponentTest.php +++ b/tests/ComponentTest.php @@ -13,7 +13,7 @@ use Tests\Views\Components\NestedComponent; beforeEach(function () { - if (! in_array(Macroable::class, class_uses(TestComponent::class) ?? [])) { + if (! version_compare(app()->version(), '11.41.0', '>=')) { TestCase::markTestSkipped('Testing Blade components is unavailable in this version of Laravel'); } }); From ac2a756d1807e382ea2ca091e696eb7cfdf749ba Mon Sep 17 00:00:00 2001 From: jackbayliss Date: Fri, 19 Sep 2025 21:02:38 +0000 Subject: [PATCH 5/6] Fix styling --- tests/ComponentTest.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/ComponentTest.php b/tests/ComponentTest.php index 01ffc62..7c6a798 100644 --- a/tests/ComponentTest.php +++ b/tests/ComponentTest.php @@ -1,7 +1,5 @@ Date: Fri, 19 Sep 2025 22:06:18 +0100 Subject: [PATCH 6/6] Revert "test test" This reverts commit a95dbe15eb6dd3cdd7c67f0629bcf43045538058. --- .github/workflows/run-tests.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index beba3fb..4fe3698 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,6 +1,12 @@ name: Run all tests -on: [push] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: test: