respect-validation/tests/unit/ValidatorTest.php
Alexandre Gomes Gaigalas ab3732f91f Use SPDX IDs for licensing
SPDX IDs are shorter than licensing notes previously used, and
adhere better to FOSS standards. It is also machine-readable.
2023-02-19 00:19:10 -03:00

54 lines
1.2 KiB
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
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 <alganet@gmail.com>
* @author Gabriel Caruso <carusogabriel34@gmail.com>
* @author Henrique Moody <henriquemoody@gmail.com>
* @author Nick Lombard <github@jigsoft.co.za>
*/
final 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()));
}
}