Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Propaganistas committed Jan 15, 2024
1 parent 57ec1db commit d8c0e5f
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions tests/RuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,22 +183,6 @@ public function it_converts_string_validation_parameters()
$this->assertEquals(['mobile', 'fixed_line'], $this->getProtectedProperty($rule, 'blockedTypes'));
}

/** @test */
public function it_allows_data_field_names_to_be_parameters()
{
$base = (new Phone)->setValidator(validator([
'mobile' => null,
'fixed_line' => null,
'lenient' => null,
'international' => null,
]));

$rule = $base->setParameters(['mobile', 'fixed_line', 'lenient', 'international']);
$this->assertEquals(['mobile', 'fixed_line'], $this->getProtectedProperty($rule, 'allowedTypes'));
$this->assertTrue($this->getProtectedProperty($rule, 'lenient'));
$this->assertTrue($this->getProtectedProperty($rule, 'international'));
}

/** @test */
public function it_treats_string_validation_parameters_case_insensitive()
{
Expand All @@ -213,10 +197,30 @@ public function it_treats_string_validation_parameters_case_insensitive()
$rule = (clone $base)->setParameters('MoBIle');
$this->assertEquals(['MoBIle'], $this->getProtectedProperty($rule, 'allowedTypes'));

$rule = (clone $base)->setParameters(['!MoBIle']);
$rule = (clone $base)->setParameters('!MoBIle');
$this->assertEquals(['MoBIle'], $this->getProtectedProperty($rule, 'blockedTypes'));
}

/** @test */
public function it_treats_coinciding_field_names_as_parameters()
{
$base = (new Phone)->setValidator(validator([
'mobile' => null,
'fixed_line' => null,
'lenient' => null,
'international' => null,
]));

$rule = (clone $base)->setParameters(['mobile', 'fixed_line', 'lenient', 'international']);

$this->assertEquals([], $this->getProtectedProperty($rule, 'countries'));
$this->assertNull($this->getProtectedProperty($rule, 'countryField'));
$this->assertEquals(['mobile', 'fixed_line'], $this->getProtectedProperty($rule, 'allowedTypes'));
$this->assertEquals([], $this->getProtectedProperty($rule, 'blockedTypes'));
$this->assertTrue($this->getProtectedProperty($rule, 'lenient'));
$this->assertTrue($this->getProtectedProperty($rule, 'international'));
}

/** @test */
public function it_ignores_invalid_string_validation_parameters()
{
Expand Down

0 comments on commit d8c0e5f

Please sign in to comment.