2011-11-29 22:20:07 +01:00
|
|
|
<?php
|
2015-06-08 16:47:14 +02:00
|
|
|
|
2015-06-08 17:09:25 +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.
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
{
|
2013-01-14 23:44:49 +01:00
|
|
|
public function testStaticCreateShouldReturnNewValidator()
|
2011-11-29 22:20:07 +01:00
|
|
|
{
|
2016-10-30 20:07:28 +01:00
|
|
|
$this->assertInstanceOf(Validator::class, Validator::create());
|
2011-11-29 22:20:07 +01:00
|
|
|
}
|
2012-05-17 20:51:49 +02:00
|
|
|
|
2013-01-14 23:44:49 +01:00
|
|
|
public function testInvalidRuleClassShouldThrowComponentException()
|
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
|
|
|
|
2015-01-19 23:12:07 +01:00
|
|
|
/**
|
|
|
|
* Regression test #174.
|
|
|
|
*/
|
|
|
|
public function testShouldReturnValidatorInstanceWhenTheNotRuleIsCalledWithArguments()
|
|
|
|
{
|
|
|
|
$validator = new Validator();
|
|
|
|
|
|
|
|
$this->assertSame($validator, $validator->not($validator->notEmpty()));
|
|
|
|
}
|
|
|
|
}
|