Skip to content

Commit

Permalink
Added testes for PR laravel#14651
Browse files Browse the repository at this point in the history
  • Loading branch information
carloscarucce authored and tillkruss committed Aug 30, 2016
1 parent ba400ea commit abc9dfe
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3047,6 +3047,76 @@ public function testUsingSettersWithImplicitRules()
$this->assertFalse($v->passes());
}

public function testInvalidMethod()
{
$trans = $this->getRealTranslator();

$v = new Validator($trans,
[
['name' => 'John'],
['name' => null],
['name' => '']
],
[
'*.name' => 'required',
]);

$this->assertEquals($v->invalid(), [
1 => ['name' => null],
2 => ['name' => '']
]);

$v = new Validator($trans,
[
'name' => ''
],
[
'name' => 'required',
]);

$this->assertEquals($v->invalid(), [
'name' => ''
]);
}

public function testValidMethod()
{
$trans = $this->getRealTranslator();

$v = new Validator($trans,
[
['name' => 'John'],
['name' => null],
['name' => ''],
['name' => 'Doe']
],
[
'*.name' => 'required',
]);

$this->assertEquals($v->valid(), [
0 => ['name' => 'John'],
3 => ['name' => 'Doe']
]);

$v = new Validator($trans,
[
'name' => 'Carlos',
'age' => 'unknown',
'gender' => 'male'
],
[
'name' => 'required',
'gernder' => 'in:male,female',
'age' => 'required|int'
]);

$this->assertEquals($v->valid(), [
'name' => 'Carlos',
'gender' => 'male'
]);
}

protected function getTranslator()
{
return m::mock('Symfony\Component\Translation\TranslatorInterface');
Expand Down

0 comments on commit abc9dfe

Please sign in to comment.