入力値が指定の日付より過去かを判定。
以下の実行で、ダウンロードできます
$ git clone git@gist.github.com:590983f0bdd25a7e0c4ba1ee99b1d300.git tests/Unit/Validations/Before
入力値が指定の日付より過去かを判定。
以下の実行で、ダウンロードできます
$ git clone git@gist.github.com:590983f0bdd25a7e0c4ba1ee99b1d300.git tests/Unit/Validations/Before
<?php | |
namespace Tests\Unit\Validations\Before; | |
use Tests\TestCase; | |
use Validator; | |
class BeforeTest extends TestCase | |
{ | |
/** | |
* @test | |
* @dataProvider provider_before | |
*/ | |
public function before($input, $expected) | |
{ | |
$v = Validator::make( | |
$input, | |
['field' => 'required|date|before:2018-01-01'] | |
); | |
$this->assertEquals($expected, $v->passes()); | |
} | |
public function provider_before() | |
{ | |
return [ | |
[['field' => '2017-12-31'], true], | |
[['field' => '12/31/17'], true], | |
[['field' => '2018-01-02'], false], | |
[['field' => '2018-01-01'], false], | |
[['field' => '1/2/18'], false], | |
[['field' => '1/1/18'], false], | |
]; | |
} | |
} |