File: VTodoTest.php

package info (click to toggle)
php-sabre-vobject 2.1.7-6.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 1,172 kB
  • sloc: php: 6,487; makefile: 17; xml: 16
file content (67 lines) | stat: -rw-r--r-- 2,692 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php

namespace Sabre\VObject\Component;

use Sabre\VObject\Component;

class VTodoTest extends \PHPUnit\Framework\TestCase {

    /**
     * @dataProvider timeRangeTestData
     */
    public function testInTimeRange(VTodo $vtodo,$start,$end,$outcome) {

        $this->assertEquals($outcome, $vtodo->isInTimeRange($start, $end));

    }

    public function timeRangeTestData() {

        $tests = array();

        $vtodo = Component::create('VTODO');
        $vtodo->DTSTART = '20111223T120000Z';
        $tests[] = array($vtodo, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo2 = clone $vtodo;
        $vtodo2->DURATION = 'P1D';
        $tests[] = array($vtodo2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo3 = clone $vtodo;
        $vtodo3->DUE = '20111225';
        $tests[] = array($vtodo3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo4 = Component::create('VTODO');
        $vtodo4->DUE = '20111225';
        $tests[] = array($vtodo4, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo4, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo5 = Component::create('VTODO');
        $vtodo5->COMPLETED = '20111225';
        $tests[] = array($vtodo5, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo5, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo6 = Component::create('VTODO');
        $vtodo6->CREATED = '20111225';
        $tests[] = array($vtodo6, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo6, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo7 = Component::create('VTODO');
        $vtodo7->CREATED = '20111225';
        $vtodo7->COMPLETED = '20111226';
        $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false);

        $vtodo7 = Component::create('VTODO');
        $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true);
        $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), true);

        return $tests;

    }

}