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
|
|
|
/*
|
2023-02-17 05:13:51 +01:00
|
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
|
|
* SPDX-License-Identifier: MIT
|
2015-06-08 17:09:25 +02:00
|
|
|
*/
|
|
|
|
|
2017-11-19 19:01:31 +01:00
|
|
|
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
|
|
|
|
2018-07-23 21:37:38 +02:00
|
|
|
/**
|
|
|
|
* @covers \Respect\Validation\Validator
|
2018-11-25 17:56:04 +01:00
|
|
|
*
|
2023-02-13 05:59:06 +01:00
|
|
|
* @author Alexandre Gomes Gaigalas <alganet@gmail.com>
|
2018-11-25 17:56:04 +01:00
|
|
|
* @author Gabriel Caruso <carusogabriel34@gmail.com>
|
|
|
|
* @author Henrique Moody <henriquemoody@gmail.com>
|
|
|
|
* @author Nick Lombard <github@jigsoft.co.za>
|
2018-07-23 21:37:38 +02:00
|
|
|
*/
|
2019-02-09 14:31:56 +01:00
|
|
|
final class ValidatorTest extends TestCase
|
2011-11-29 22:20:07 +01:00
|
|
|
{
|
2018-07-23 20:35:14 +02:00
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function staticCreateShouldReturnNewValidator(): void
|
2011-11-29 22:20:07 +01:00
|
|
|
{
|
2017-11-12 14:33:39 +01:00
|
|
|
self::assertInstanceOf(Validator::class, Validator::create());
|
2011-11-29 22:20:07 +01:00
|
|
|
}
|
2012-05-17 20:51:49 +02:00
|
|
|
|
2018-07-23 20:35:14 +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
|
|
|
|
2015-01-19 23:12:07 +01:00
|
|
|
/**
|
|
|
|
* Regression test #174.
|
2018-07-23 20:35:14 +02:00
|
|
|
*
|
|
|
|
* @test
|
2015-01-19 23:12:07 +01:00
|
|
|
*/
|
2018-07-23 20:35:14 +02:00
|
|
|
public function shouldReturnValidatorInstanceWhenTheNotRuleIsCalledWithArguments(): void
|
2015-01-19 23:12:07 +01:00
|
|
|
{
|
|
|
|
$validator = new Validator();
|
|
|
|
|
2017-11-12 14:33:39 +01:00
|
|
|
self::assertSame($validator, $validator->not($validator->notEmpty()));
|
2015-01-19 23:12:07 +01:00
|
|
|
}
|
|
|
|
}
|