diff --git a/src/TestComponentMacros.php b/src/TestComponentMacros.php index 2ff04ab..608875c 100644 --- a/src/TestComponentMacros.php +++ b/src/TestComponentMacros.php @@ -96,12 +96,14 @@ public function assertContainsElement(): Closure ); try { - $parser = DomParser::new((string) $this); + if (! app()->has('dom-assertions.parser')) { + app()->instance('dom-assertions.parser', DomParser::new((string) $this)); + } } catch (DOMException $exception) { Assert::fail($exception->getMessage()); } - $element = $parser->query($selector); + $element = app()->make('dom-assertions.parser')->query($selector); Assert::assertNotNull( $element, diff --git a/src/TestResponseMacros.php b/src/TestResponseMacros.php index 7ab39b9..3a4bb0e 100644 --- a/src/TestResponseMacros.php +++ b/src/TestResponseMacros.php @@ -96,12 +96,14 @@ public function assertContainsElement(): Closure ); try { - $parser = DomParser::new($this->getContent()); + if (! app()->has('dom-assertions.parser')) { + app()->instance('dom-assertions.parser', DomParser::new($this->getContent())); + } } catch (DOMException $exception) { Assert::fail($exception->getMessage()); } - $element = $parser->query($selector); + $element = app()->make('dom-assertions.parser')->query($selector); Assert::assertNotNull( $element, diff --git a/src/TestViewMacros.php b/src/TestViewMacros.php index ae55f8a..e811404 100644 --- a/src/TestViewMacros.php +++ b/src/TestViewMacros.php @@ -96,12 +96,14 @@ public function assertContainsElement(): Closure ); try { - $parser = DomParser::new((string) $this); + if (! app()->has('dom-assertions.parser')) { + app()->instance('dom-assertions.parser', DomParser::new((string) $this)); + } } catch (DOMException $exception) { Assert::fail($exception->getMessage()); } - $element = $parser->query($selector); + $element = app()->make('dom-assertions.parser')->query($selector); Assert::assertNotNull( $element,