Skip to content

Commit

Permalink
Added 2 unit tests for the starts_with validation helper method
Browse files Browse the repository at this point in the history
  • Loading branch information
steffen25 committed Dec 13, 2018
1 parent 4dd5ff2 commit 5754ec5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1211,6 +1211,18 @@ public function testValidateStartsWith()
$trans = $this->getIlluminateArrayTranslator();
$v = new Validator($trans, ['x' => 'hello world'], ['x' => 'starts_with:world,hello']);
$this->assertTrue($v->passes());

$trans = $this->getIlluminateArrayTranslator();
$trans->addLines(['validation.starts_with' => 'The :attribute must start with one of the following values :values'], 'en');
$v = new Validator($trans, ['url' => 'laravel.com'], ['url' => 'starts_with:http']);
$this->assertFalse($v->passes());
$this->assertEquals('The url must start with one of the following values http', $v->messages()->first('url'));

$trans = $this->getIlluminateArrayTranslator();
$trans->addLines(['validation.starts_with' => 'The :attribute must start with one of the following values :values'], 'en');
$v = new Validator($trans, ['url' => 'laravel.com'], ['url' => 'starts_with:http,https']);
$this->assertFalse($v->passes());
$this->assertEquals('The url must start with one of the following values http, https', $v->messages()->first('url'));
}

public function testValidateString()
Expand Down

0 comments on commit 5754ec5

Please sign in to comment.