diff --git a/Tests/Functional/Domain/Model/TeaTest.php b/Tests/Functional/Domain/Model/TeaTest.php new file mode 100644 index 00000000..79be1efb --- /dev/null +++ b/Tests/Functional/Domain/Model/TeaTest.php @@ -0,0 +1,70 @@ +subject = new Tea(); + $validatorResolver = $this->getContainer()->get(ValidatorResolver::class); + $this->validator = $validatorResolver->getBaseValidatorConjunction(Tea::class); + } + + #[Test] + public function titleWithMaximumLengthPassesValidation(): void + { + $this->subject->setTitle(str_repeat('p', 255)); + $result = $this->validator->validate($this->subject); + self::assertFalse($result->forProperty('title')->hasErrors()); + } + + #[Test] + public function titleLongerThanMaximumLengthDoesNotPassValidation(): void + { + $this->subject->setTitle(str_repeat('p', 256)); + $result = $this->validator->validate($this->subject); + self::assertTrue($result->forProperty('title')->hasErrors()); + } + + #[Test] + public function emptyTitleDoesNotPassValidation(): void + { + $this->subject->setTitle(''); + $result = $this->validator->validate($this->subject); + self::assertTrue($result->forProperty('title')->hasErrors()); + } + + #[Test] + public function descriptionWithMaximumLengthPassesValidation(): void + { + $this->subject->setDescription(str_repeat('d', 2000)); + $result = $this->validator->validate($this->subject); + self::assertFalse($result->forProperty('description')->hasErrors()); + } + + #[Test] + public function descriptionLongerThanMaximumLengthDoesNotPassValidation(): void + { + $this->subject->setDescription(str_repeat('d', 2001)); + $result = $this->validator->validate($this->subject); + self::assertTrue($result->forProperty('description')->hasErrors()); + } + +}