Passed
Push — master ( 751812...ad3fb0 )
by Kevin
02:24
created

ScheduleTimezoneSubscriberTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 24
rs 10
c 0
b 0
f 0
eloc 15

1 Method

Rating   Name   Duplication   Size   Complexity  
A can_set_a_default_timezone() 0 19 1
1
<?php
2
3
namespace Zenstruck\ScheduleBundle\Tests\EventListener;
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\EventListener\ScheduleTimezoneSubscriber;
7
use Zenstruck\ScheduleBundle\Schedule\Task\CompoundTask;
8
use Zenstruck\ScheduleBundle\Tests\Fixture\MockScheduleBuilder;
9
use Zenstruck\ScheduleBundle\Tests\Fixture\MockTask;
10
11
/**
12
 * @author Kevin Bond <[email protected]>
13
 */
14
final class ScheduleTimezoneSubscriberTest extends TestCase
15
{
16
    /**
17
     * @test
18
     */
19
    public function can_set_a_default_timezone()
20
    {
21
        $tasks = (new MockScheduleBuilder())
22
            ->addTask(new MockTask())
23
            ->addTask((new MockTask())->timezone('America/Edmonton'))
24
            ->addTask((new CompoundTask())
25
                ->add(new MockTask())
26
                ->add((new MockTask())->timezone(new \DateTimeZone('America/Edmonton')))
27
            )
28
            ->addSubscriber(new ScheduleTimezoneSubscriber('America/Toronto'))
29
            ->getRunner()
30
            ->buildSchedule()
31
            ->all()
32
        ;
33
34
        $this->assertSame('America/Toronto', $tasks[0]->getTimezone()->getName());
35
        $this->assertSame('America/Edmonton', $tasks[1]->getTimezone()->getName());
36
        $this->assertSame('America/Toronto', $tasks[2]->getTimezone()->getName());
37
        $this->assertSame('America/Edmonton', $tasks[3]->getTimezone()->getName());
38
    }
39
}
40