respect-validation/tests/unit/ValidatorTest.php
2018-12-05 08:57:05 +01:00

58 lines
1.4 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;
use Respect\Validation\Exceptions\ComponentException;
use Respect\Validation\Test\TestCase;
/**
* @covers \Respect\Validation\Validator
*
* @author Alexandre Gomes Gaigalas <alexandre@gaigalas.net>
* @author Gabriel Caruso <carusogabriel34@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Nick Lombard <github@jigsoft.co.za>
*/
class ValidatorTest extends TestCase
{
/**
* @test
*/
public function staticCreateShouldReturnNewValidator(): void
{
self::assertInstanceOf(Validator::class, Validator::create());
}
/**
* @test
*/
public function invalidRuleClassShouldThrowComponentException(): void
{
$this->expectException(ComponentException::class);
Validator::iDoNotExistSoIShouldThrowException();
}
/**
* Regression test #174.
*
* @test
*/
public function shouldReturnValidatorInstanceWhenTheNotRuleIsCalledWithArguments(): void
{
$validator = new Validator();
self::assertSame($validator, $validator->not($validator->notEmpty()));
}
}