Completed
Push — master ( 6a6e14...e9047f )
by Julián
02:21
created

AbstractScheduledTest::testBadTimeZoneOffset()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Effortless maintenance management (http://juliangut.com/janitor)
4
 *
5
 * @link https://github.com/juliangut/janitor for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/janitor/blob/master/LICENSE
8
 */
9
10
namespace Janitor\Test\Watcher\Scheduled;
11
12
use Janitor\Watcher\Scheduled\AbstractScheduled;
13
14
/**
15
 * Class AbstractScheduledTest
16
 */
17
class AbstractScheduledTest extends \PHPUnit_Framework_TestCase
18
{
19
    /**
20
     * @var AbstractScheduled
21
     */
22
    protected $watcher;
23
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function setUp()
28
    {
29
        $this->watcher = $this->getMockForAbstractClass(AbstractScheduled::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...stractScheduled::class) of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<Janitor\Watcher\S...uled\AbstractScheduled> of property $watcher.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
    }
31
32
    /**
33
     * @expectedException \InvalidArgumentException
34
     */
35
    public function testBadTimeZoneName()
36
    {
37
        $this->watcher->setTimeZone('World/Unknown');
38
    }
39
40
    /**
41
     * @expectedException \InvalidArgumentException
42
     */
43
    public function testBadTimeZoneOffset()
44
    {
45
        $this->watcher->setTimeZone(158622);
46
    }
47
48
    public function testTimeZone()
49
    {
50
        self::assertEquals(
51
            (new \DateTimeZone(date_default_timezone_get()))->getName(),
52
            $this->watcher->getTimeZone()->getName()
53
        );
54
55
        $this->watcher->setTimeZone(1);
56
        self::assertEquals('Europe/London', $this->watcher->getTimeZone()->getName());
57
58
        $this->watcher->setTimeZone('Europe/Madrid');
59
        self::assertEquals('Europe/Madrid', $this->watcher->getTimeZone()->getName());
60
    }
61
}
62