Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit e7a7242

Browse files
committed
feat(tests): added normalizer test
1 parent 70f74aa commit e7a7242

4 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/Test/Util/TestRuleCustomMessageTrait.php renamed to src/Test/Util/TestRuleMessageOptionTrait.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use PHPUnit\Framework\Attributes\DataProvider;
66
use ProgrammatorDev\YetAnotherPhpValidator\Rule\RuleInterface;
77

8-
trait TestRuleCustomMessageTrait
8+
trait TestRuleMessageOptionTrait
99
{
10-
public static abstract function provideRuleCustomMessageData(): \Generator;
10+
public static abstract function provideRuleMessageOptionData(): \Generator;
1111

12-
#[DataProvider('provideRuleCustomMessageData')]
13-
public function testRuleCustomMessage(RuleInterface $rule, mixed $value, string $exceptionMessage): void
12+
#[DataProvider('provideRuleMessageOptionData')]
13+
public function testRuleMessageOption(RuleInterface $rule, mixed $value, string $exceptionMessage): void
1414
{
1515
$this->expectExceptionMessage($exceptionMessage);
1616
$rule->assert($value, 'test');

tests/GreaterThanTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use ProgrammatorDev\YetAnotherPhpValidator\Exception\GreaterThanException;
66
use ProgrammatorDev\YetAnotherPhpValidator\Rule\GreaterThan;
7-
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleCustomMessageTrait;
7+
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleMessageOptionTrait;
88
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleFailureConditionTrait;
99
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleSuccessConditionTrait;
1010

1111
class GreaterThanTest extends AbstractTest
1212
{
1313
use TestRuleFailureConditionTrait;
1414
use TestRuleSuccessConditionTrait;
15-
use TestRuleCustomMessageTrait;
15+
use TestRuleMessageOptionTrait;
1616

1717
public static function provideRuleFailureConditionData(): \Generator
1818
{
@@ -49,7 +49,7 @@ public static function provideRuleSuccessConditionData(): \Generator
4949
yield 'string' => [new GreaterThan('a'), 'z'];
5050
}
5151

52-
public static function provideRuleCustomMessageData(): \Generator
52+
public static function provideRuleMessageOptionData(): \Generator
5353
{
5454
yield 'message' => [
5555
new GreaterThan(10, [

tests/LessThanTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use ProgrammatorDev\YetAnotherPhpValidator\Exception\LessThanException;
66
use ProgrammatorDev\YetAnotherPhpValidator\Rule\LessThan;
7-
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleCustomMessageTrait;
7+
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleMessageOptionTrait;
88
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleFailureConditionTrait;
99
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleSuccessConditionTrait;
1010

1111
class LessThanTest extends AbstractTest
1212
{
1313
use TestRuleFailureConditionTrait;
1414
use TestRuleSuccessConditionTrait;
15-
use TestRuleCustomMessageTrait;
15+
use TestRuleMessageOptionTrait;
1616

1717
public static function provideRuleFailureConditionData(): \Generator
1818
{
@@ -49,7 +49,7 @@ public static function provideRuleSuccessConditionData(): \Generator
4949
yield 'string' => [new LessThan('z'), 'a'];
5050
}
5151

52-
public static function provideRuleCustomMessageData(): \Generator
52+
public static function provideRuleMessageOptionData(): \Generator
5353
{
5454
yield 'message' => [
5555
new LessThan(10, [

tests/NotBlankTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

55
use ProgrammatorDev\YetAnotherPhpValidator\Exception\NotBlankException;
66
use ProgrammatorDev\YetAnotherPhpValidator\Rule\NotBlank;
7-
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleCustomMessageTrait;
7+
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleMessageOptionTrait;
88
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleFailureConditionTrait;
99
use ProgrammatorDev\YetAnotherPhpValidator\Test\Util\TestRuleSuccessConditionTrait;
1010

1111
class NotBlankTest extends AbstractTest
1212
{
1313
use TestRuleFailureConditionTrait;
1414
use TestRuleSuccessConditionTrait;
15-
use TestRuleCustomMessageTrait;
15+
use TestRuleMessageOptionTrait;
1616

1717
public static function provideRuleFailureConditionData(): \Generator
1818
{
@@ -23,6 +23,8 @@ public static function provideRuleFailureConditionData(): \Generator
2323
yield 'false' => [new NotBlank(), false, $exception, $exceptionMessage];
2424
yield 'blank string' => [new NotBlank(), '', $exception, $exceptionMessage];
2525
yield 'blank array' => [new NotBlank(), [], $exception, $exceptionMessage];
26+
27+
yield 'normalizer whitespace' => [new NotBlank(['normalizer' => 'trim']), ' ', $exception, $exceptionMessage];
2628
}
2729

2830
public static function provideRuleSuccessConditionData(): \Generator
@@ -42,7 +44,7 @@ public static function provideRuleSuccessConditionData(): \Generator
4244
yield 'zero number' => [new NotBlank(), 0];
4345
}
4446

45-
public static function provideRuleCustomMessageData(): \Generator
47+
public static function provideRuleMessageOptionData(): \Generator
4648
{
4749
yield 'message' => [
4850
new NotBlank([

0 commit comments

Comments
 (0)