From 6d88ccb8f152790abc713c0718927b22cd3f8d8b Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Wed, 29 Nov 2023 12:05:56 +0100 Subject: [PATCH] Add full string assertion for Document --- src/Document.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/Document.php b/src/Document.php index 1e66fbc..75a2926 100644 --- a/src/Document.php +++ b/src/Document.php @@ -8,8 +8,9 @@ use PHPUnit\Framework\Assert; use ReflectionClass; use ReflectionMethod; use ReflectionProperty; +use Spatie\LaravelData\Data; -abstract class Document +abstract class Document extends Data { abstract public function basename(): string; @@ -35,6 +36,15 @@ abstract class Document ); } + public function assertIsContent(string $content): void + { + Assert::assertEquals( + $content, + $this->renderBody(), + "Failed asserting that Content is {$content}" + ); + } + /** * @param array $content */ @@ -80,12 +90,12 @@ abstract class Document public function filename(): string { - return $this->basename().'.tex'; + return $this->basename() . '.tex'; } public function compiledFilename(): string { - return $this->basename().'.pdf'; + return $this->basename() . '.pdf'; } /** @@ -144,8 +154,8 @@ abstract class Document protected function createVariableFromMethod(ReflectionMethod $method): Closure|InvokableComponentVariable { return 0 === $method->getNumberOfParameters() - ? $this->createInvokableVariable($method->getName()) - : Closure::fromCallable([$this, $method->getName()]); + ? $this->createInvokableVariable($method->getName()) + : Closure::fromCallable([$this, $method->getName()]); } protected function createInvokableVariable(string $method): InvokableComponentVariable