respect-validation/tests/unit/Rules/SubsetTest.php
Danilo Correa 719f12a424
Increase code coverage of some rules
We were not thoroughly testing quite a few rules, especially the
constructor of some of them.

This commit increases the code coverage, ensuring almost every single
line in the "Rules" namespace is covered.
2024-04-23 16:01:55 +02:00

45 lines
1.2 KiB
PHP

<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
*/
declare(strict_types=1);
namespace Respect\Validation\Rules;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Respect\Validation\Test\RuleTestCase;
#[Group('rule')]
#[CoversClass(Subset::class)]
final class SubsetTest extends RuleTestCase
{
/** @return iterable<array{Subset, mixed}> */
public static function providerForValidInput(): iterable
{
return [
[new Subset([]), []],
[new Subset([1]), [1]],
[new Subset([1, 1]), [1]],
[new Subset([1]), [1, 1]],
[new Subset([2, 1, 3]), [1, 2]],
[new Subset([1, 2, 3]), [1, 2]],
[new Subset(['a', 1, 2]), [1]],
];
}
/** @return iterable<array{Subset, mixed}> */
public static function providerForInvalidInput(): iterable
{
return [
[new Subset([]), '1'],
[new Subset([]), [1]],
[new Subset([1]), [2]],
[new Subset([1, 2]), [1, 2, 3]],
[new Subset(['a', 'b']), ['c']],
];
}
}