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:
Henrique Moody 2023-04-02 15:28:23 +02:00
parent ee8dd98f54
commit 445af454fd
No known key found for this signature in database
GPG key ID: 221E9281655813A6
2 changed files with 25 additions and 12 deletions

View 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
{
}
}

View file

@ -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
}
}