Passed
Push — master ( 9213a8...e174b6 )
by Kevin
02:14
created

ScheduleRunContextTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
c 1
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set_results_count_mismatch() 0 8 1
A cannot_access_results_if_has_not_run() 0 8 1
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Tests\Schedule;
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;
7
use Zenstruck\ScheduleBundle\Schedule\ScheduleRunContext;
8
use Zenstruck\ScheduleBundle\Schedule\Task\Result;
9
use Zenstruck\ScheduleBundle\Tests\Fixture\MockTask;
10
11
/**
12
 * @author Kevin Bond <[email protected]>
13
 */
14
final class ScheduleRunContextTest extends TestCase
15
{
16
    /**
17
     * @test
18
     */
19
    public function cannot_access_results_if_has_not_run()
20
    {
21
        $context = new ScheduleRunContext(new Schedule());
22
23
        $this->expectException(\LogicException::class);
24
        $this->expectExceptionMessage('"The Schedule" has not yet run.');
25
26
        $context->getResults();
27
    }
28
29
    /**
30
     * @test
31
     */
32
    public function set_results_count_mismatch()
33
    {
34
        $context = new ScheduleRunContext(new Schedule(), new MockTask(), new MockTask());
35
36
        $this->expectException(\LogicException::class);
37
        $this->expectExceptionMessage('The number of results (1) does not match the number of due tasks (2).');
38
39
        $context->setResults(Result::successful(new MockTask()));
40
    }
41
}
42