respect-validation/tests/unit/Rules/LeapDateTest.php
Henrique Moody e044e4b16e
Add some code standards for PHPUnit tests
Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
2018-07-23 20:46:18 +02:00

74 lines
1.6 KiB
PHP

<?php
/*
* This file is part of Respect/Validation.
*
* (c) Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
*
* For the full copyright and license information, please view the "LICENSE.md"
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use DateTime;
use PHPUnit\Framework\TestCase;
/**
* @group rule
* @covers \Respect\Validation\Exceptions\LeapDateException
* @covers \Respect\Validation\Rules\LeapDate
*/
class LeapDateTest extends TestCase
{
protected $leapDateValidator;
protected function setUp(): void
{
$this->leapDateValidator = new LeapDate('Y-m-d');
}
/**
* @test
*/
public function validLeapDate_with_string(): void
{
self::assertTrue($this->leapDateValidator->validate('1988-02-29'));
}
/**
* @test
*/
public function validLeapDate_with_date_time(): void
{
self::assertTrue($this->leapDateValidator->validate(
new DateTime('1988-02-29')));
}
/**
* @test
*/
public function invalidLeapDate_with_string(): void
{
self::assertFalse($this->leapDateValidator->validate('1989-02-29'));
}
/**
* @test
*/
public function invalidLeapDate_with_date_time(): void
{
self::assertFalse($this->leapDateValidator->validate(
new DateTime('1989-02-29')));
}
/**
* @test
*/
public function invalidLeapDate_input(): void
{
self::assertFalse($this->leapDateValidator->validate([]));
}
}