Skip to content

Commit 7fa158d

Browse files
authored
fix: php stan (#28)
* fix phpstan errors Authored-by: jackbayliss <[email protected]>
1 parent c591729 commit 7fa158d

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

src/DomAssertionsServiceProvider.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Sinnbeck\DomAssertions;
44

55
use Illuminate\Support\ServiceProvider;
6-
use Illuminate\Support\Traits\Macroable;
76
use Illuminate\Testing\TestComponent;
87
use Illuminate\Testing\TestResponse;
98
use Illuminate\Testing\TestView;
@@ -15,9 +14,8 @@ public function boot()
1514
if ($this->app->runningUnitTests()) {
1615
TestResponse::mixin(new TestResponseMacros);
1716
TestView::mixin(new TestViewMacros);
18-
19-
// https://github.com/laravel/framework/pull/54359
20-
if (in_array(Macroable::class, class_uses(TestComponent::class) ?? [])) {
17+
if (version_compare($this->app->version(), '11.41.0', '>=')) {
18+
// @phpstan-ignore-next-line
2119
TestComponent::mixin(new TestComponentMacros);
2220
}
2321
}

src/TestComponentMacros.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public function assertHtml5(): Closure
2424
return function () {
2525
/** @var TestComponent $this */
2626
Assert::assertNotEmpty(
27-
(string) $this->rendered,
27+
(string) $this,
2828
'The component is empty!'
2929
);
3030

3131
try {
32-
$parser = DomParser::new((string) $this->rendered);
32+
$parser = DomParser::new((string) $this);
3333
} catch (DOMException $exception) {
3434
Assert::fail($exception->getMessage());
3535
}
@@ -49,12 +49,12 @@ public function assertElementExists(): Closure
4949
return function ($selector = 'body', $callback = null): TestComponent {
5050
/** @var TestComponent $this */
5151
Assert::assertNotEmpty(
52-
(string) $this->rendered,
52+
(string) $this,
5353
'The component is empty!'
5454
);
5555

5656
try {
57-
$parser = DomParser::new((string) $this->rendered);
57+
$parser = DomParser::new((string) $this);
5858
} catch (DOMException $exception) {
5959
Assert::fail($exception->getMessage());
6060
}
@@ -73,7 +73,7 @@ public function assertElementExists(): Closure
7373
Assert::assertNotNull($element, sprintf('No element found with selector: %s', $selector));
7474

7575
if ($callback) {
76-
$callback(new AssertElement((string) $this->rendered, $element));
76+
$callback(new AssertElement((string) $this, $element));
7777
}
7878

7979
return $this;
@@ -85,12 +85,12 @@ public function assertFormExists(): Closure
8585
return function ($selector = 'form', $callback = null): TestComponent {
8686
/** @var TestComponent $this */
8787
Assert::assertNotEmpty(
88-
(string) $this->rendered,
88+
(string) $this,
8989
'The component is empty!'
9090
);
9191

9292
try {
93-
$parser = DomParser::new((string) $this->rendered);
93+
$parser = DomParser::new((string) $this);
9494
} catch (DOMException $exception) {
9595
Assert::fail($exception->getMessage());
9696
}
@@ -116,7 +116,7 @@ public function assertFormExists(): Closure
116116
'Element is not of type form!');
117117

118118
if ($callback) {
119-
$callback(new AssertForm((string) $this->rendered, $form));
119+
$callback(new AssertForm((string) $this, $form));
120120
}
121121

122122
return $this;

tests/ComponentTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
use Illuminate\Support\Traits\Macroable;
4-
use Illuminate\Testing\TestComponent;
53
use PHPUnit\Framework\AssertionFailedError;
64
use PHPUnit\Framework\TestCase;
75
use Sinnbeck\DomAssertions\Asserts\AssertElement;
@@ -13,7 +11,7 @@
1311
use Tests\Views\Components\NestedComponent;
1412

1513
beforeEach(function () {
16-
if (! in_array(Macroable::class, class_uses(TestComponent::class) ?? [])) {
14+
if (! version_compare(app()->version(), '11.41.0', '>=')) {
1715
TestCase::markTestSkipped('Testing Blade components is unavailable in this version of Laravel');
1816
}
1917
});

0 commit comments

Comments
 (0)