Completed
Push — master ( ecd5d7...f9662e )
by Julián
11:22
created

AbstractScheduledTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 2
dl 0
loc 45
rs 10
1
<?php
2
3
/*
4
 * janitor (http://juliangut.com/janitor).
5
 * Effortless maintenance management.
6
 *
7
 * @license BSD-3-Clause
8
 * @link https://github.com/juliangut/janitor
9
 * @author Julián Gutiérrez <[email protected]>
10
 */
11
12
namespace Janitor\Test\Watcher\Scheduled;
13
14
use Janitor\Watcher\Scheduled\AbstractScheduled;
15
16
/**
17
 * Class AbstractScheduledTest.
18
 */
19
class AbstractScheduledTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var AbstractScheduled
23
     */
24
    protected $watcher;
25
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function setUp()
30
    {
31
        $this->watcher = $this->getMockForAbstractClass(AbstractScheduled::class);
32
    }
33
34
    /**
35
     * @expectedException \InvalidArgumentException
36
     */
37
    public function testBadTimeZoneName()
38
    {
39
        $this->watcher->setTimeZone('World/Unknown');
40
    }
41
42
    /**
43
     * @expectedException \InvalidArgumentException
44
     */
45
    public function testBadTimeZoneOffset()
46
    {
47
        $this->watcher->setTimeZone(158622);
48
    }
49
50
    public function testTimeZone()
51
    {
52
        self::assertEquals(
53
            (new \DateTimeZone(date_default_timezone_get()))->getName(),
54
            $this->watcher->getTimeZone()->getName()
55
        );
56
57
        $this->watcher->setTimeZone(1);
58
        self::assertEquals('Europe/London', $this->watcher->getTimeZone()->getName());
59
60
        $this->watcher->setTimeZone('Europe/Madrid');
61
        self::assertEquals('Europe/Madrid', $this->watcher->getTimeZone()->getName());
62
    }
63
}
64