Passed
Pull Request — master (#8)
by Kevin
17:55
created

askRunnerTest.php$0   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 4
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Tests\Schedule\Task\Runner;
4
5
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Zenstruck\ScheduleBundle\Schedule\Task\CallbackTask;
7
use Zenstruck\ScheduleBundle\Schedule\Task\Runner\CallbackTaskRunner;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class CallbackTaskRunnerTest extends TestCase
13
{
14
    /**
15
     * @test
16
     */
17
    public function can_create_successful_result()
18
    {
19
        $result = (new CallbackTaskRunner())(new CallbackTask(function () {}));
20
21
        $this->assertTrue($result->isSuccessful());
22
        $this->assertNull($result->getOutput());
23
    }
24
25
    /**
26
     * @test
27
     * @dataProvider outputProvider
28
     */
29
    public function stringifies_output($output, $expectedOutput)
30
    {
31
        $result = (new CallbackTaskRunner())(new CallbackTask(function () use ($output) { return $output; }));
32
33
        $this->assertTrue($result->isSuccessful());
34
        $this->assertSame($expectedOutput, $result->getOutput());
35
    }
36
37
    public static function outputProvider()
38
    {
39
        $stringClass = new class() {
40
            public function __toString(): string
41
            {
42
                return 'as string';
43
            }
44
        };
45
46
        return [
47
            [null, null],
48
            [10, '10'],
49
            [true, '1'],
50
            [false, ''],
51
            [new \stdClass(), '[object] stdClass'],
52
            [['foo'], '(array)'],
53
            [$stringClass, 'as string'],
54
        ];
55
    }
56
57
    /**
58
     * @test
59
     */
60
    public function supports_callback_task()
61
    {
62
        $this->assertTrue((new CallbackTaskRunner())->supports(new CallbackTask(function () {})));
63
    }
64
}
65