-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: adds test for NoticeLocation VO
- Loading branch information
1 parent
872af37
commit 8cebd9c
Showing
1 changed file
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace StellarWP\AdminNotices\Tests\Unit\ValueObjects; | ||
|
||
use InvalidArgumentException; | ||
use StellarWP\AdminNotices\Tests\Support\Helper\TestCase; | ||
use StellarWP\AdminNotices\ValueObjects\NoticeLocation; | ||
|
||
/** | ||
* @coversDefaultClass \StellarWP\AdminNotices\ValueObjects\NoticeLocation | ||
*/ | ||
class NoticeLocationTest extends TestCase | ||
{ | ||
/** | ||
* @covers ::aboveHeader | ||
* | ||
* @unreleased | ||
*/ | ||
public function testAboveHeader(): void | ||
{ | ||
$location = NoticeLocation::aboveHeader(); | ||
|
||
$this->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<string, array{0: string, 1: bool}> | ||
*/ | ||
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], | ||
]; | ||
} | ||
} |