2010-12-06 19:30:56 +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);
|
|
|
|
|
2010-12-06 19:30:56 +01:00
|
|
|
namespace Respect\Validation\Rules;
|
|
|
|
|
2017-02-05 11:55:30 +01:00
|
|
|
use ArrayObject;
|
2024-01-28 01:46:21 +01:00
|
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2018-01-07 14:12:55 +01:00
|
|
|
use Respect\Validation\Test\RuleTestCase;
|
2017-02-05 11:55:30 +01:00
|
|
|
use SimpleXMLElement;
|
|
|
|
use stdClass;
|
|
|
|
|
2024-01-28 01:46:21 +01:00
|
|
|
#[Group(' rule')]
|
|
|
|
#[CoversClass(ArrayVal::class)]
|
2018-03-16 12:09:52 +01:00
|
|
|
final class ArrayValTest extends RuleTestCase
|
2010-12-06 19:30:56 +01:00
|
|
|
{
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{ArrayVal, mixed}> */
|
|
|
|
public static function providerForValidInput(): iterable
|
2010-12-06 19:30:56 +01:00
|
|
|
{
|
2015-10-17 22:52:35 +02:00
|
|
|
$rule = new ArrayVal();
|
2010-12-06 19:30:56 +01:00
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2015-10-17 22:52:35 +02:00
|
|
|
[$rule, []],
|
|
|
|
[$rule, [1, 2, 3]],
|
2017-02-05 11:55:30 +01:00
|
|
|
[$rule, new ArrayObject()],
|
|
|
|
[$rule, new SimpleXMLElement('<foo></foo>')],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2010-12-06 19:30:56 +01:00
|
|
|
}
|
|
|
|
|
2024-02-04 19:23:04 +01:00
|
|
|
/** @return iterable<array{ArrayVal, mixed}> */
|
|
|
|
public static function providerForInvalidInput(): iterable
|
2010-12-06 19:30:56 +01:00
|
|
|
{
|
2015-10-17 22:52:35 +02:00
|
|
|
$rule = new ArrayVal();
|
|
|
|
|
2015-10-18 03:44:47 +02:00
|
|
|
return [
|
2015-10-17 22:52:35 +02:00
|
|
|
[$rule, ''],
|
|
|
|
[$rule, null],
|
|
|
|
[$rule, 121],
|
2017-02-05 11:55:30 +01:00
|
|
|
[$rule, new stdClass()],
|
2015-10-17 22:52:35 +02:00
|
|
|
[$rule, false],
|
|
|
|
[$rule, 'aaa'],
|
2015-10-18 03:44:47 +02:00
|
|
|
];
|
2010-12-06 19:30:56 +01:00
|
|
|
}
|
2013-01-14 23:44:49 +01:00
|
|
|
}
|