From 8cebd9cfa9785e00687dd1915dedac4e45cd57b8 Mon Sep 17 00:00:00 2001 From: Jason Adams Date: Mon, 18 Nov 2024 16:13:57 -0700 Subject: [PATCH] test: adds test for NoticeLocation VO --- .../unit/ValueObjects/NoticeLocationTest.php | 106 ++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 tests/unit/ValueObjects/NoticeLocationTest.php diff --git a/tests/unit/ValueObjects/NoticeLocationTest.php b/tests/unit/ValueObjects/NoticeLocationTest.php new file mode 100644 index 0000000..77915c6 --- /dev/null +++ b/tests/unit/ValueObjects/NoticeLocationTest.php @@ -0,0 +1,106 @@ +assertEquals('above_header', $location); + } + + /** + * @covers ::standard + * + * @unreleased + */ + public function testStandard(): void + { + $location = NoticeLocation::standard(); + + $this->assertEquals('below_header', $location); + } + + /** + * @covers ::belowHeader + * + * @unreleased + */ + public function testBelowHeader(): void + { + $location = NoticeLocation::belowHeader(); + + $this->assertEquals('below_header', $location); + } + + /** + * @covers ::inline + * + * @unreleased + */ + public function testInline(): void + { + $location = NoticeLocation::inline(); + + $this->assertEquals('inline', $location); + } + + /** + * @covers ::__toString + * + * @unreleased + */ + public function testToString(): void + { + $location = new NoticeLocation('above_header'); + + $this->assertSame('above_header', (string)$location); + } + + /** + * @dataProvider constructorValidationDataProvider + * @covers ::__construct + */ + public function testConstructorValidation($value, $shouldPass): void + { + if ($shouldPass) { + $this->assertInstanceOf(NoticeLocation::class, new NoticeLocation($value)); + } else { + $this->expectException(InvalidArgumentException::class); + new NoticeLocation($value); + } + } + + /** + * @unreleased + * + * @return array + */ + public function constructorValidationDataProvider(): array + { + return [ + 'above header is valid' => ['above_header', true], + 'below header is valid' => ['below_header', true], + 'inline is valid' => ['inline', true], + 'standard is invalid' => ['standard', false], + 'empty string is invalid' => ['', false], + ]; + } +}