testSetRemindDaysThrowsExceptionIfStringInvalid()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace JhFlexiTimeTest\Options;
4
5
use JhFlexiTime\DateTime\DateTime;
6
use JhFlexiTime\Options\NotificationOptions;
7
use PHPUnit_Framework_TestCase;
8
9
/**
10
 * Class NotificationOptionsTest
11
 * @package JhFlexiTimeTest\Options
12
 * @author Aydin Hassan <[email protected]>
13
 */
14
class NotificationOptionsTest extends PHPUnit_Framework_TestCase
15
{
16
    public function testSetRemindStartThrowsExceptionIfNotDateStringInvalid()
17
    {
18
        $this->setExpectedException('Exception');
19
        $options = new NotificationOptions;
20
        $options->setRemindStart('lolnotadate');
21
    }
22
23
    public function testGetSetRemindStart()
24
    {
25
        $options = new NotificationOptions;
26
        $options->setRemindStart('3 days ago');
27
        $this->assertEquals(new DateTime('3 days ago 00:00:00'), $options->getRemindStart());
28
    }
29
30
    public function testSetRemindDaysThrowsExceptionIfStringInvalid()
31
    {
32
        $this->setExpectedException('InvalidArgumentException', 'remind_days should be like: "7 days"');
33
        $options = new NotificationOptions;
34
        $options->setRemindDays('invalid');
35
    }
36
37
    public function testGetSetRemindDays()
38
    {
39
        $options = new NotificationOptions;
40
        $options->setRemindDays('3 days');
41
        $this->assertEquals('3 days', $options->getRemindDays());
42
    }
43
44
    public function testGetRemindPeriod()
45
    {
46
        $options = new NotificationOptions;
47
        $options->setRemindDays('3 days');
48
        $options->setRemindStart('11 November 2014');
49
50
        $result = $options->getRemindPeriod();
51
52
        $expected = [
53
            new DateTime('7 November 2014'),
54
            //8 - 9 Is weekend
55
            new DateTime('10 November 2014'),
56
            new DateTime('11 November 2014'),
57
        ];
58
59
        $this->assertEquals($expected, $result);
60
    }
61
}
62