mirror of
https://github.com/Respect/Validation.git
synced 2024-06-27 09:40:05 +02:00
Create a class to help test the Callable rule
With that, the tests will be more straightforward, and we won't need to use the test class in the data providers. That will help us later because, on PHPUnit 10, all data providers need to be static. Signed-off-by: Henrique Moody <henriquemoody@gmail.com>
This commit is contained in:
parent
ee8dd98f54
commit
445af454fd
21
tests/library/Stubs/WithMethods.php
Normal file
21
tests/library/Stubs/WithMethods.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (c) Alexandre Gomes Gaigalas <alganet@gmail.com>
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Respect\Validation\Test\Stubs;
|
||||
|
||||
final class WithMethods
|
||||
{
|
||||
public function publicMethod(): void
|
||||
{
|
||||
}
|
||||
|
||||
public static function publicStaticMethod(): void
|
||||
{
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||
namespace Respect\Validation\Rules;
|
||||
|
||||
use Respect\Validation\Test\RuleTestCase;
|
||||
use Respect\Validation\Test\Stubs\WithMethods;
|
||||
use stdClass;
|
||||
|
||||
use const INF;
|
||||
|
@ -32,14 +33,10 @@ final class CallableTypeTest extends RuleTestCase
|
|||
$rule = new CallableType();
|
||||
|
||||
return [
|
||||
[
|
||||
$rule,
|
||||
static function (): void {
|
||||
},
|
||||
],
|
||||
[$rule, static fn() => null],
|
||||
[$rule, 'trim'],
|
||||
[$rule, self::class . '::staticMethod'],
|
||||
[$rule, [$this, __FUNCTION__]],
|
||||
[$rule, WithMethods::class . '::publicStaticMethod'],
|
||||
[$rule, [new WithMethods(), 'publicMethod']],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -58,9 +55,4 @@ final class CallableTypeTest extends RuleTestCase
|
|||
[$rule, null],
|
||||
];
|
||||
}
|
||||
|
||||
public static function staticMethod(): void
|
||||
{
|
||||
// This is a static method example
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue