From 43e15a70fb6148b0128d7981b0c0f3e99463b9fb Mon Sep 17 00:00:00 2001 From: freek Date: Mon, 30 Nov 2020 16:23:31 +0100 Subject: [PATCH] wip --- tests/Rules/DelimitedTest.php | 8 +++++--- tests/Rules/EnumTest.php | 17 +---------------- tests/TestClasses/Enums/MyCLabsEnum.php | 10 ++++++++++ tests/TestClasses/Enums/SpatieEnum.php | 12 ++++++++++++ 4 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 tests/TestClasses/Enums/MyCLabsEnum.php create mode 100644 tests/TestClasses/Enums/SpatieEnum.php diff --git a/tests/Rules/DelimitedTest.php b/tests/Rules/DelimitedTest.php index 1fe93f6..994ad1c 100644 --- a/tests/Rules/DelimitedTest.php +++ b/tests/Rules/DelimitedTest.php @@ -4,7 +4,9 @@ use Spatie\ValidationRules\Rules\CountryCode; use Spatie\ValidationRules\Rules\Delimited; +use Spatie\ValidationRules\Rules\Enum; use Spatie\ValidationRules\Tests\TestCase; +use Spatie\ValidationRules\Tests\TestClasses\Enums\MyCLabsEnum; class DelimitedTest extends TestCase { @@ -113,10 +115,10 @@ public function it_can_use_composite_rules() /** @test */ public function it_can_accept_another_rule() { - $rule = new Delimited(new CountryCode()); + $rule = new Delimited(new Enum(MyCLabsEnum::class)); - $this->assertTrue($rule->passes('attribute', 'BE, NL')); - $this->assertFalse($rule->passes('attribute', 'BE, NL, blablabla')); + $this->assertTrue($rule->passes('attribute', 'ONE, TWO')); + $this->assertFalse($rule->passes('attribute', 'ONE, FOUR')); } /** @test */ diff --git a/tests/Rules/EnumTest.php b/tests/Rules/EnumTest.php index 230f6a7..550e274 100644 --- a/tests/Rules/EnumTest.php +++ b/tests/Rules/EnumTest.php @@ -5,6 +5,7 @@ use Illuminate\Support\Facades\Lang; use Spatie\ValidationRules\Rules\Enum; use Spatie\ValidationRules\Tests\TestCase; +use Spatie\ValidationRules\Tests\TestClasses\Enums\MyCLabsEnum; class EnumTest extends TestCase { @@ -56,19 +57,3 @@ public function spatie_it_passes_attribute_and_valid_values_to_the_validation_me $this->assertEquals('enum_field ONE, TWO, THREE', $rule->message()); } } - -class MyCLabsEnum extends \MyCLabs\Enum\Enum -{ - const ONE = 'one'; - const TWO = 'two'; - const THREE = 'three'; -} - -/** - * @method static self ONE() - * @method static self TWO() - * @method static self THREE() - */ -class SpatieEnum extends \Spatie\Enum\Enum -{ -} diff --git a/tests/TestClasses/Enums/MyCLabsEnum.php b/tests/TestClasses/Enums/MyCLabsEnum.php new file mode 100644 index 0000000..3fba96b --- /dev/null +++ b/tests/TestClasses/Enums/MyCLabsEnum.php @@ -0,0 +1,10 @@ +