respect-validation/tests/unit/ValidatorTest.php

54 lines
1.2 KiB
PHP
Raw Normal View History

2011-11-29 22:20:07 +01:00
<?php
2015-06-08 16:47:14 +02:00
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
2011-11-29 22:20:07 +01:00
namespace Respect\Validation;
2016-10-30 20:07:28 +01:00
use Respect\Validation\Exceptions\ComponentException;
2018-12-05 08:36:38 +01:00
use Respect\Validation\Test\TestCase;
2016-10-30 20:07:28 +01:00
/**
* @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
2011-11-29 22:20:07 +01:00
{
/**
* @test
*/
public function staticCreateShouldReturnNewValidator(): void
2011-11-29 22:20:07 +01:00
{
self::assertInstanceOf(Validator::class, Validator::create());
2011-11-29 22:20:07 +01:00
}
2012-05-17 20:51:49 +02:00
/**
* @test
*/
public function invalidRuleClassShouldThrowComponentException(): void
2011-11-29 22:20:07 +01:00
{
2017-11-04 11:21:40 +01:00
$this->expectException(ComponentException::class);
2011-11-29 22:20:07 +01:00
Validator::iDoNotExistSoIShouldThrowException();
}
2013-01-22 20:25:34 +01:00
/**
* Regression test #174.
*
* @test
*/
public function shouldReturnValidatorInstanceWhenTheNotRuleIsCalledWithArguments(): void
{
$validator = new Validator();
self::assertSame($validator, $validator->not($validator->notEmpty()));
}
}