mirror of
https://github.com/Respect/Validation.git
synced 2026-03-16 23:35:45 +01:00
Because of how the validation engine works now [1], there's no reason to
keep adding names to each rule. Instead, create a single rule that
handles naming rules with a few other accessories. This change is not
necessarily simple, but it shrinks the `Rule` interface, and it's more
aligned with how the library works right now.
Personally, I think this API is much more straightforward than the
`setName()` method, as it's way more explicit about which rule we're
naming. Because of this change, the behaviour changed slightly, but it's
for the best.
Because of this change, I managed to remove a lot of code, but
unfortunately, it's quite a big-bang commit. It would be too complicated
to make it atomic since names are an intrinsic part of the library.
[1]: 238f2d506a
34 lines
809 B
PHP
34 lines
809 B
PHP
<?php
|
|
|
|
/*
|
|
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Respect\Validation\Rules\Core;
|
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Group;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use Respect\Validation\Test\Rules\Core\ConcreteWrapper;
|
|
use Respect\Validation\Test\Rules\Stub;
|
|
use Respect\Validation\Test\TestCase;
|
|
|
|
#[Group('core')]
|
|
#[CoversClass(Wrapper::class)]
|
|
final class WrapperTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function shouldUseWrappedToEvaluate(): void
|
|
{
|
|
$wrapped = Stub::pass(2);
|
|
|
|
$wrapper = new ConcreteWrapper($wrapped);
|
|
|
|
$input = 'Whatever';
|
|
|
|
self::assertEquals($wrapped->evaluate($input), $wrapper->evaluate($input));
|
|
}
|
|
}
|