respect-validation/tests/unit/Rules/KeySetTest.php

36 lines
1.2 KiB
PHP
Raw Normal View History

2015-07-20 12:16:46 +02:00
<?php
/*
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
* SPDX-License-Identifier: MIT
2015-07-20 12:16:46 +02:00
*/
declare(strict_types=1);
2015-07-20 12:16:46 +02:00
namespace Respect\Validation\Rules;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Group;
use Respect\Validation\Test\Rules\Stub;
use Respect\Validation\Test\RuleTestCase;
#[Group('rule')]
#[CoversClass(KeySet::class)]
final class KeySetTest extends RuleTestCase
2015-07-20 12:16:46 +02:00
{
/** @return iterable<string, array{KeySet, mixed}> */
public static function providerForValidInput(): iterable
2015-07-20 12:16:46 +02:00
{
yield 'correct keys, with passing rule' => [new KeySet(new Key('foo', Stub::pass(1))), ['foo' => 'bar']];
}
/** @return iterable<string, array{KeySet, mixed}> */
public static function providerForInvalidInput(): iterable
{
yield 'not array' => [new KeySet(new Key('foo', Stub::daze())), null];
yield 'missing keys' => [new KeySet(new Key('foo', Stub::daze())), []];
yield 'extra keys' => [new KeySet(new Key('foo', Stub::daze())), ['foo' => 'bar', 'baz' => 'qux']];
yield 'correct keys, with failing rule' => [new KeySet(new Key('foo', Stub::fail(1))), ['foo' => 'bar']];
}
2015-07-20 12:16:46 +02:00
}