respect-validation/tests/unit/ValidatorTest.php

42 lines
1 KiB
PHP
Raw Normal View History

2011-11-29 22:20:07 +01:00
<?php
2015-06-08 16:47:14 +02:00
/*
* 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);
2011-11-29 22:20:07 +01:00
namespace Respect\Validation;
2017-11-04 11:21:40 +01:00
use PHPUnit\Framework\TestCase;
2016-10-30 20:07:28 +01:00
use Respect\Validation\Exceptions\ComponentException;
2017-11-04 11:21:40 +01:00
class ValidatorTest extends TestCase
2011-11-29 22:20:07 +01:00
{
public function testStaticCreateShouldReturnNewValidator(): 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
public function testInvalidRuleClassShouldThrowComponentException(): 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.
*/
public function testShouldReturnValidatorInstanceWhenTheNotRuleIsCalledWithArguments(): void
{
$validator = new Validator();
self::assertSame($validator, $validator->not($validator->notEmpty()));
}
}