Passed
Push — master ( 82bd79...a09bf3 )
by Alex
07:52
created

staticMethodCallDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 4
c 1
b 1
f 0
dl 0
loc 13
rs 10
cc 1
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
namespace Mezon\Router\Tests\Base;
4
5
/**
6
 *
7
 * @psalm-suppress PropertyNotSetInConstructor
8
 */
9
abstract class StaticMethodsCallsTestClass extends BaseRouterUnitTestClass
10
{
11
12
    /**
13
     *
14
     * {@inheritdoc}
15
     * @see \PHPUnit\Framework\TestCase::setUp()
16
     */
17
    protected function setUp(): void
18
    {
19
        $_SERVER['REQUEST_METHOD'] = 'GET';
20
    }
21
22
    /**
23
     * Static method for calling
24
     *
25
     * @return string
26
     */
27
    public static function staticMethod(): string
28
    {
29
        return 'static method was called';
30
    }
31
32
    /**
33
     * Testing data provider
34
     *
35
     * @return array testing data
36
     */
37
    public function staticMethodCallDataProvider(): array
38
    {
39
        return [
40
            // #0, the first case
41
            [
42
                [
43
                    StaticMethodsCallsTestClass::class,
44
                    'staticMethod'
45
                ]
46
            ],
47
            // #1, the second case
48
            [
49
                '\Mezon\Router\Tests\Base\StaticMethodsCallsTestClass::staticMethod'
50
            ]
51
        ];
52
    }
53
54
    /**
55
     * Testing static method calls
56
     *
57
     * @param callable|string|array $callback
58
     *            callback
59
     * @dataProvider staticMethodCallDataProvider
60
     */
61
    public function testStaticMethodCalls($callback): void
62
    {
63
        // setup
64
        $router = $this->getRouter();
65
        $router->addRoute('static', $callback, 'GET');
66
67
        // test body and assertions
68
        $this->assertEquals('static method was called', $router->callRoute('static'));
69
    }
70
}
71