diff --git a/docs/02-feature-guide.md b/docs/02-feature-guide.md index 3758694ea..3ae5c7b7b 100644 --- a/docs/02-feature-guide.md +++ b/docs/02-feature-guide.md @@ -43,7 +43,7 @@ Respect\Validation offers over 150 rules, many of which are designed to address * Validating the **Length** of the input: [Length](rules/Length.md). * Validating the **Maximum** value in the input: [Max](rules/Max.md). * Validating the **Minimum** value in the input: [Min](rules/Min.md). -* Handling **Special cases**: [Lazy](rules/Lazy.md), [Consecutive](rules/Consecutive.md), [Call](rules/Call.md). +* Handling **Special cases**: [Lazy](rules/Lazy.md), [Circuit](rules/Circuit.md), [Call](rules/Call.md). ### Custom templates diff --git a/docs/09-list-of-rules-by-category.md b/docs/09-list-of-rules-by-category.md index 38b5e3a93..0ba1fce8a 100644 --- a/docs/09-list-of-rules-by-category.md +++ b/docs/09-list-of-rules-by-category.md @@ -61,13 +61,11 @@ - [AllOf](rules/AllOf.md) - [AnyOf](rules/AnyOf.md) -- [Consecutive](rules/Consecutive.md) - [NoneOf](rules/NoneOf.md) - [OneOf](rules/OneOf.md) ## Conditions -- [Consecutive](rules/Consecutive.md) - [Not](rules/Not.md) - [When](rules/When.md) @@ -163,7 +161,6 @@ - [AllOf](rules/AllOf.md) - [AnyOf](rules/AnyOf.md) - [Call](rules/Call.md) -- [Consecutive](rules/Consecutive.md) - [Each](rules/Each.md) - [Key](rules/Key.md) - [KeySet](rules/KeySet.md) @@ -314,7 +311,6 @@ - [Charset](rules/Charset.md) - [Cnh](rules/Cnh.md) - [Cnpj](rules/Cnpj.md) -- [Consecutive](rules/Consecutive.md) - [Consonant](rules/Consonant.md) - [Contains](rules/Contains.md) - [ContainsAny](rules/ContainsAny.md) diff --git a/docs/rules/AllOf.md b/docs/rules/AllOf.md index fe40cddfb..6ca666d51 100644 --- a/docs/rules/AllOf.md +++ b/docs/rules/AllOf.md @@ -46,7 +46,7 @@ v::allOf(v::intVal(), v::positive())->isValid(15); // true See also: - [AnyOf](AnyOf.md) -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) - [NoneOf](NoneOf.md) - [OneOf](OneOf.md) - [When](When.md) diff --git a/docs/rules/AnyOf.md b/docs/rules/AnyOf.md index 974decb89..4c79ef547 100644 --- a/docs/rules/AnyOf.md +++ b/docs/rules/AnyOf.md @@ -44,7 +44,7 @@ so `AnyOf()` returns true. See also: - [AllOf](AllOf.md) -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) - [ContainsAny](ContainsAny.md) - [NoneOf](NoneOf.md) - [OneOf](OneOf.md) diff --git a/docs/rules/Consecutive.md b/docs/rules/Circuit.md similarity index 71% rename from docs/rules/Consecutive.md rename to docs/rules/Circuit.md index 6a37f8c47..9ee99d7ad 100644 --- a/docs/rules/Consecutive.md +++ b/docs/rules/Circuit.md @@ -1,8 +1,8 @@ -# Consecutive +# Circuit -- `Consecutive(Rule $rule1, Rule $rule2, Rule ...$rule)` +- `Circuit(Rule $rule1, Rule $rule2, Rule ...$rule)` -Validates the input against a series of rules until one fails. +Validates the input against a series of rules until the first fails. This rule can be handy for getting the least error messages possible from a chain. @@ -10,7 +10,7 @@ This rule can be helpful in combinations with [Lazy](Lazy.md). An excellent exam country code and a subdivision code. ```php -v::consecutive( +v::circuit( v::key('countryCode', v::countryCode()), v::lazy(static fn($input) => v::key('subdivisionCode', v::subdivisionCode($input['countryCode']))), )->isValid($_POST); @@ -22,11 +22,7 @@ would then have to write `v::key('countryCode', v::countryCode())` twice in your ## Templates -## Template placeholders - -| Placeholder | Description | -|-------------|------------------------------------------------------------------| -| `name` | The validated input or the custom validator name (if specified). | +This rule does not have any templates, because it will always return the result of the first rule that fails. When all the validation rules pass, it will return the result of the last rule of the circuit. ## Categorization diff --git a/docs/rules/Lazy.md b/docs/rules/Lazy.md index 1c877f6e9..e08ddfd61 100644 --- a/docs/rules/Lazy.md +++ b/docs/rules/Lazy.md @@ -47,4 +47,4 @@ See also: - [Call](Call.md) - [CallableType](CallableType.md) -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) diff --git a/docs/rules/NoneOf.md b/docs/rules/NoneOf.md index 46cdcaf7b..0126efb70 100644 --- a/docs/rules/NoneOf.md +++ b/docs/rules/NoneOf.md @@ -45,7 +45,7 @@ See also: - [AllOf](AllOf.md) - [AnyOf](AnyOf.md) -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) - [Not](Not.md) - [OneOf](OneOf.md) - [When](When.md) diff --git a/docs/rules/OneOf.md b/docs/rules/OneOf.md index 3775cff83..a2ee84e62 100644 --- a/docs/rules/OneOf.md +++ b/docs/rules/OneOf.md @@ -46,6 +46,6 @@ See also: - [AllOf](AllOf.md) - [AnyOf](AnyOf.md) -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) - [NoneOf](NoneOf.md) - [When](When.md) diff --git a/docs/rules/SubdivisionCode.md b/docs/rules/SubdivisionCode.md index f82c5490c..c909be436 100644 --- a/docs/rules/SubdivisionCode.md +++ b/docs/rules/SubdivisionCode.md @@ -44,7 +44,7 @@ v::subdivisionCode('US')->isValid('CA'); // true *** See also: -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) - [CountryCode](CountryCode.md) - [CurrencyCode](CurrencyCode.md) - [Nip](Nip.md) diff --git a/docs/rules/When.md b/docs/rules/When.md index 883cc4ee1..d2e3912ab 100644 --- a/docs/rules/When.md +++ b/docs/rules/When.md @@ -46,6 +46,6 @@ See also: - [AllOf](AllOf.md) - [AlwaysInvalid](AlwaysInvalid.md) - [AnyOf](AnyOf.md) -- [Consecutive](Consecutive.md) +- [Circuit](Circuit.md) - [NoneOf](NoneOf.md) - [OneOf](OneOf.md) diff --git a/library/Mixins/Builder.php b/library/Mixins/Builder.php index 182b45e82..0b6cd6542 100644 --- a/library/Mixins/Builder.php +++ b/library/Mixins/Builder.php @@ -65,12 +65,12 @@ public static function callback(callable $callback, mixed ...$arguments): Chain; public static function charset(string $charset, string ...$charsets): Chain; + public static function circuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public static function cnh(): Chain; public static function cnpj(): Chain; - public static function consecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public static function consonant(string ...$additionalChars): Chain; public static function contains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/Chain.php b/library/Mixins/Chain.php index 83fe671dd..dcac73a0d 100644 --- a/library/Mixins/Chain.php +++ b/library/Mixins/Chain.php @@ -70,12 +70,12 @@ public function callback(callable $callback, mixed ...$arguments): Chain; public function charset(string $charset, string ...$charsets): Chain; + public function circuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public function cnh(): Chain; public function cnpj(): Chain; - public function consecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public function consonant(string ...$additionalChars): Chain; public function contains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/KeyBuilder.php b/library/Mixins/KeyBuilder.php index 748d0de8a..4f7d72720 100644 --- a/library/Mixins/KeyBuilder.php +++ b/library/Mixins/KeyBuilder.php @@ -56,12 +56,12 @@ public static function keyCallback(int|string $key, callable $callback, mixed .. public static function keyCharset(int|string $key, string $charset, string ...$charsets): Chain; + public static function keyCircuit(int|string $key, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public static function keyCnh(int|string $key): Chain; public static function keyCnpj(int|string $key): Chain; - public static function keyConsecutive(int|string $key, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public static function keyConsonant(int|string $key, string ...$additionalChars): Chain; public static function keyContains(int|string $key, mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/KeyChain.php b/library/Mixins/KeyChain.php index b448653f6..be4e18a07 100644 --- a/library/Mixins/KeyChain.php +++ b/library/Mixins/KeyChain.php @@ -56,12 +56,12 @@ public function keyCallback(int|string $key, callable $callback, mixed ...$argum public function keyCharset(int|string $key, string $charset, string ...$charsets): Chain; + public function keyCircuit(int|string $key, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public function keyCnh(int|string $key): Chain; public function keyCnpj(int|string $key): Chain; - public function keyConsecutive(int|string $key, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public function keyConsonant(int|string $key, string ...$additionalChars): Chain; public function keyContains(int|string $key, mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/NotBuilder.php b/library/Mixins/NotBuilder.php index 259b4bf66..2c7f14710 100644 --- a/library/Mixins/NotBuilder.php +++ b/library/Mixins/NotBuilder.php @@ -55,12 +55,12 @@ public static function notCallback(callable $callback, mixed ...$arguments): Cha public static function notCharset(string $charset, string ...$charsets): Chain; + public static function notCircuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public static function notCnh(): Chain; public static function notCnpj(): Chain; - public static function notConsecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public static function notConsonant(string ...$additionalChars): Chain; public static function notContains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/NotChain.php b/library/Mixins/NotChain.php index 2088868ea..b4a00a33c 100644 --- a/library/Mixins/NotChain.php +++ b/library/Mixins/NotChain.php @@ -55,12 +55,12 @@ public function notCallback(callable $callback, mixed ...$arguments): Chain; public function notCharset(string $charset, string ...$charsets): Chain; + public function notCircuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public function notCnh(): Chain; public function notCnpj(): Chain; - public function notConsecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public function notConsonant(string ...$additionalChars): Chain; public function notContains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/NullOrBuilder.php b/library/Mixins/NullOrBuilder.php index 4ddf9cd1f..4c955e3c0 100644 --- a/library/Mixins/NullOrBuilder.php +++ b/library/Mixins/NullOrBuilder.php @@ -57,12 +57,12 @@ public static function nullOrCallback(callable $callback, mixed ...$arguments): public static function nullOrCharset(string $charset, string ...$charsets): Chain; + public static function nullOrCircuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public static function nullOrCnh(): Chain; public static function nullOrCnpj(): Chain; - public static function nullOrConsecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public static function nullOrConsonant(string ...$additionalChars): Chain; public static function nullOrContains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/NullOrChain.php b/library/Mixins/NullOrChain.php index 6ab9d4e3c..b3f8b3161 100644 --- a/library/Mixins/NullOrChain.php +++ b/library/Mixins/NullOrChain.php @@ -57,12 +57,12 @@ public function nullOrCallback(callable $callback, mixed ...$arguments): Chain; public function nullOrCharset(string $charset, string ...$charsets): Chain; + public function nullOrCircuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public function nullOrCnh(): Chain; public function nullOrCnpj(): Chain; - public function nullOrConsecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public function nullOrConsonant(string ...$additionalChars): Chain; public function nullOrContains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/PropertyBuilder.php b/library/Mixins/PropertyBuilder.php index ec069c751..6c9bb0b86 100644 --- a/library/Mixins/PropertyBuilder.php +++ b/library/Mixins/PropertyBuilder.php @@ -56,12 +56,12 @@ public static function propertyCallback(string $propertyName, callable $callback public static function propertyCharset(string $propertyName, string $charset, string ...$charsets): Chain; + public static function propertyCircuit(string $propertyName, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public static function propertyCnh(string $propertyName): Chain; public static function propertyCnpj(string $propertyName): Chain; - public static function propertyConsecutive(string $propertyName, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public static function propertyConsonant(string $propertyName, string ...$additionalChars): Chain; public static function propertyContains( diff --git a/library/Mixins/PropertyChain.php b/library/Mixins/PropertyChain.php index 96f909f66..984337fec 100644 --- a/library/Mixins/PropertyChain.php +++ b/library/Mixins/PropertyChain.php @@ -56,12 +56,12 @@ public function propertyCallback(string $propertyName, callable $callback, mixed public function propertyCharset(string $propertyName, string $charset, string ...$charsets): Chain; + public function propertyCircuit(string $propertyName, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public function propertyCnh(string $propertyName): Chain; public function propertyCnpj(string $propertyName): Chain; - public function propertyConsecutive(string $propertyName, Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public function propertyConsonant(string $propertyName, string ...$additionalChars): Chain; public function propertyContains(string $propertyName, mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/UndefOrBuilder.php b/library/Mixins/UndefOrBuilder.php index 3d06952f9..0c1be5826 100644 --- a/library/Mixins/UndefOrBuilder.php +++ b/library/Mixins/UndefOrBuilder.php @@ -55,12 +55,12 @@ public static function undefOrCallback(callable $callback, mixed ...$arguments): public static function undefOrCharset(string $charset, string ...$charsets): Chain; + public static function undefOrCircuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public static function undefOrCnh(): Chain; public static function undefOrCnpj(): Chain; - public static function undefOrConsecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public static function undefOrConsonant(string ...$additionalChars): Chain; public static function undefOrContains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Mixins/UndefOrChain.php b/library/Mixins/UndefOrChain.php index 3fd2d0fbc..def676fdc 100644 --- a/library/Mixins/UndefOrChain.php +++ b/library/Mixins/UndefOrChain.php @@ -55,12 +55,12 @@ public function undefOrCallback(callable $callback, mixed ...$arguments): Chain; public function undefOrCharset(string $charset, string ...$charsets): Chain; + public function undefOrCircuit(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; + public function undefOrCnh(): Chain; public function undefOrCnpj(): Chain; - public function undefOrConsecutive(Rule $rule1, Rule $rule2, Rule ...$rules): Chain; - public function undefOrConsonant(string ...$additionalChars): Chain; public function undefOrContains(mixed $containsValue, bool $identical = false): Chain; diff --git a/library/Rules/Consecutive.php b/library/Rules/Circuit.php similarity index 94% rename from library/Rules/Consecutive.php rename to library/Rules/Circuit.php index 11f2705fa..69f1da1b3 100644 --- a/library/Rules/Consecutive.php +++ b/library/Rules/Circuit.php @@ -15,7 +15,7 @@ use Respect\Validation\Rules\Core\Composite; #[Attribute(Attribute::TARGET_PROPERTY | Attribute::IS_REPEATABLE)] -final class Consecutive extends Composite +final class Circuit extends Composite { public function evaluate(mixed $input): Result { diff --git a/library/Rules/Domain.php b/library/Rules/Domain.php index e35510e90..d7ccc652a 100644 --- a/library/Rules/Domain.php +++ b/library/Rules/Domain.php @@ -58,9 +58,9 @@ public function evaluate(mixed $input): Result return new Result($this->partsRule->evaluate($parts)->isValid, $input, $this); } - private function createGenericRule(): Consecutive + private function createGenericRule(): Circuit { - return new Consecutive( + return new Circuit( new StringType(), new NoWhitespace(), new Contains('.'), @@ -74,13 +74,13 @@ private function createTldRule(bool $realTldCheck): Rule return new Tld(); } - return new Consecutive(new Not(new StartsWith('-')), new Length(new GreaterThanOrEqual(2))); + return new Circuit(new Not(new StartsWith('-')), new Length(new GreaterThanOrEqual(2))); } private function createPartsRule(): Rule { return new Each( - new Consecutive( + new Circuit( new Alnum('-'), new Not(new StartsWith('-')), new AnyOf( diff --git a/library/Transformers/DeprecatedKeyValue.php b/library/Transformers/DeprecatedKeyValue.php index f2c6e0c62..2a7dd9b2a 100644 --- a/library/Transformers/DeprecatedKeyValue.php +++ b/library/Transformers/DeprecatedKeyValue.php @@ -42,7 +42,7 @@ public function transform(RuleSpec $ruleSpec): RuleSpec [$comparedKey, $ruleName, $baseKey] = $ruleSpec->arguments; - return new RuleSpec('consecutive', [ + return new RuleSpec('circuit', [ new KeyExists($comparedKey), new KeyExists($baseKey), new Lazy( diff --git a/tests/feature/Rules/ConsecutiveTest.php b/tests/feature/Rules/CircuitTest.php similarity index 58% rename from tests/feature/Rules/ConsecutiveTest.php rename to tests/feature/Rules/CircuitTest.php index 4ca5cca79..b0b92e8c3 100644 --- a/tests/feature/Rules/ConsecutiveTest.php +++ b/tests/feature/Rules/CircuitTest.php @@ -8,81 +8,81 @@ declare(strict_types=1); test('Default', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::trueVal())->assert(false), + fn() => v::circuit(v::alwaysValid(), v::trueVal())->assert(false), '`false` must evaluate to `true`', '- `false` must evaluate to `true`', ['trueVal' => '`false` must evaluate to `true`'] )); test('Inverted', expectAll( - fn() => v::not(v::consecutive(v::alwaysValid(), v::trueVal()))->assert(true), + fn() => v::not(v::circuit(v::alwaysValid(), v::trueVal()))->assert(true), '`true` must not evaluate to `true`', '- `true` must not evaluate to `true`', ['notTrueVal' => '`true` must not evaluate to `true`'] )); test('Default with inverted failing rule', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::not(v::trueVal()))->assert(true), + fn() => v::circuit(v::alwaysValid(), v::not(v::trueVal()))->assert(true), '`true` must not evaluate to `true`', '- `true` must not evaluate to `true`', ['notTrueVal' => '`true` must not evaluate to `true`'] )); test('With wrapped name, default', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::trueVal()->setName('Wrapped'))->setName('Wrapper')->assert(false), + fn() => v::circuit(v::alwaysValid(), v::trueVal()->setName('Wrapped'))->setName('Wrapper')->assert(false), 'Wrapped must evaluate to `true`', '- Wrapped must evaluate to `true`', ['trueVal' => 'Wrapped must evaluate to `true`'] )); test('With wrapper name, default', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::trueVal())->setName('Wrapper')->assert(false), + fn() => v::circuit(v::alwaysValid(), v::trueVal())->setName('Wrapper')->assert(false), 'Wrapper must evaluate to `true`', '- Wrapper must evaluate to `true`', ['trueVal' => 'Wrapper must evaluate to `true`'] )); test('With the name set in the wrapped rule of an inverted failing rule', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::not(v::trueVal()->setName('Wrapped'))->setName('Not'))->setName('Wrapper')->assert(true), + fn() => v::circuit(v::alwaysValid(), v::not(v::trueVal()->setName('Wrapped'))->setName('Not'))->setName('Wrapper')->assert(true), 'Wrapped must not evaluate to `true`', '- Wrapped must not evaluate to `true`', ['notTrueVal' => 'Wrapped must not evaluate to `true`'] )); test('With the name set in an inverted failing rule', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::not(v::trueVal())->setName('Not'))->setName('Wrapper')->assert(true), + fn() => v::circuit(v::alwaysValid(), v::not(v::trueVal())->setName('Not'))->setName('Wrapper')->assert(true), 'Not must not evaluate to `true`', '- Not must not evaluate to `true`', ['notTrueVal' => 'Not must not evaluate to `true`'] )); -test('With the name set in the "consecutive" that has an inverted failing rule', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::not(v::trueVal()))->setName('Wrapper')->assert(true), +test('With the name set in the "circuit" that has an inverted failing rule', expectAll( + fn() => v::circuit(v::alwaysValid(), v::not(v::trueVal()))->setName('Wrapper')->assert(true), 'Wrapper must not evaluate to `true`', '- Wrapper must not evaluate to `true`', ['notTrueVal' => 'Wrapper must not evaluate to `true`'] )); test('With template', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::trueVal()) - ->setTemplate('Consecutive cool cats cunningly continuous cookies') + fn() => v::circuit(v::alwaysValid(), v::trueVal()) + ->setTemplate('Circuit cool cats cunningly continuous cookies') ->assert(false), - 'Consecutive cool cats cunningly continuous cookies', - '- Consecutive cool cats cunningly continuous cookies', - ['trueVal' => 'Consecutive cool cats cunningly continuous cookies'] + 'Circuit cool cats cunningly continuous cookies', + '- Circuit cool cats cunningly continuous cookies', + ['trueVal' => 'Circuit cool cats cunningly continuous cookies'] )); test('With multiple templates', expectAll( - fn() => v::consecutive(v::alwaysValid(), v::trueVal()) - ->setTemplates(['trueVal' => 'Clever clowns craft consecutive clever clocks']) + fn() => v::circuit(v::alwaysValid(), v::trueVal()) + ->setTemplates(['trueVal' => 'Clever clowns craft circuit clever clocks']) ->assert(false), - 'Clever clowns craft consecutive clever clocks', - '- Clever clowns craft consecutive clever clocks', - ['trueVal' => 'Clever clowns craft consecutive clever clocks'] + 'Clever clowns craft circuit clever clocks', + '- Clever clowns craft circuit clever clocks', + ['trueVal' => 'Clever clowns craft circuit clever clocks'] )); test('Real example', expectAll( - fn() => v::consecutive( + fn() => v::circuit( v::key('countyCode', v::countryCode()), v::lazy(fn($input) => v::key('subdivisionCode', v::subdivisionCode($input['countyCode']))) )->assert(['countyCode' => 'BR', 'subdivisionCode' => 'CA']), diff --git a/tests/unit/Rules/ConsecutiveTest.php b/tests/unit/Rules/CircuitTest.php similarity index 84% rename from tests/unit/Rules/ConsecutiveTest.php rename to tests/unit/Rules/CircuitTest.php index 73055dcce..88a989c5a 100644 --- a/tests/unit/Rules/ConsecutiveTest.php +++ b/tests/unit/Rules/CircuitTest.php @@ -19,21 +19,21 @@ use function rand; #[Group('rule')] -#[CoversClass(Consecutive::class)] -final class ConsecutiveTest extends TestCase +#[CoversClass(Circuit::class)] +final class CircuitTest extends TestCase { #[Test] #[DataProvider('providerForAnyValues')] public function itShouldValidateInputWhenAllRulesValidatesTheInput(mixed $input): void { - self::assertValidInput(new Consecutive(Stub::pass(1), Stub::pass(1)), $input); + self::assertValidInput(new Circuit(Stub::pass(1), Stub::pass(1)), $input); } #[Test] #[DataProvider('providerForFailingRules')] public function itShouldExecuteRulesInSequenceUntilOneFails(Stub ...$stub): void { - $rule = new Consecutive(...$stub); + $rule = new Circuit(...$stub); self::assertInvalidInput($rule, rand()); } @@ -43,7 +43,7 @@ public function itShouldReturnTheResultOfTheFailingRule(): void { $input = rand(); - $rule = new Consecutive(Stub::fail(1), Stub::daze()); + $rule = new Circuit(Stub::fail(1), Stub::daze()); $actual = $rule->evaluate($input); $expected = Stub::fail(1)->evaluate($input);