Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 30, 2020
1 parent c6a8c4e commit 43e15a7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
8 changes: 5 additions & 3 deletions tests/Rules/DelimitedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 */
Expand Down
17 changes: 1 addition & 16 deletions tests/Rules/EnumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
}
10 changes: 10 additions & 0 deletions tests/TestClasses/Enums/MyCLabsEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Spatie\ValidationRules\Tests\TestClasses\Enums;

class MyCLabsEnum extends \MyCLabs\Enum\Enum
{
const ONE = 'one';
const TWO = 'two';
const THREE = 'three';
}
12 changes: 12 additions & 0 deletions tests/TestClasses/Enums/SpatieEnum.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Spatie\ValidationRules\Tests\TestClasses\Enums;

/**
* @method static self ONE()
* @method static self TWO()
* @method static self THREE()
*/
class SpatieEnum extends \Spatie\Enum\Enum
{
}

0 comments on commit 43e15a7

Please sign in to comment.