Subversion Repositories Applications.papyrus

Rev

Rev 1372 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
493 ddelon 1
<?php
2
// $Id: unixts_engine_test.php,v 1.1 2005-09-30 14:58:00 ddelon Exp $
3
 
4
require_once('simple_include.php');
5
require_once('calendar_include.php');
6
 
7
class TestOfUnixTsEngine extends UnitTestCase {
8
    var $engine;
9
    function TestOfUnixTsEngine() {
10
        $this->UnitTestCase('Test of Calendar_Engine_UnixTs');
11
    }
12
    function setUp() {
13
        $this->engine = new Calendar_Engine_UnixTs();
14
    }
15
    function testGetSecondsInMinute() {
16
        $this->assertEqual($this->engine->getSecondsInMinute(),60);
17
    }
18
    function testGetMinutesInHour() {
19
        $this->assertEqual($this->engine->getMinutesInHour(),60);
20
    }
21
    function testGetHoursInDay() {
22
        $this->assertEqual($this->engine->getHoursInDay(),24);
23
    }
24
    function testGetFirstDayOfWeek() {
25
        $this->assertEqual($this->engine->getFirstDayOfWeek(),1);
26
    }
27
    function testGetWeekDays() {
28
        $this->assertEqual($this->engine->getWeekDays(),array(0,1,2,3,4,5,6));
29
    }
30
    function testGetDaysInWeek() {
31
        $this->assertEqual($this->engine->getDaysInWeek(),7);
32
    }
33
    function testGetWeekNInYear() {
34
        $this->assertEqual($this->engine->getWeekNInYear(2003, 11, 3), 45);
35
    }
36
    function testGetWeekNInMonth() {
37
        $this->assertEqual($this->engine->getWeekNInMonth(2003, 11, 3), 2);
38
    }
39
    function testGetWeeksInMonth0() {
40
        $this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 0), 6); //week starts on sunday
41
    }
42
    function testGetWeeksInMonth1() {
43
        $this->assertEqual($this->engine->getWeeksInMonth(2003, 11, 1), 5); //week starts on monday
44
    }
45
    function testGetWeeksInMonth2() {
46
        $this->assertEqual($this->engine->getWeeksInMonth(2003, 2, 6), 4); //week starts on saturday
47
    }
48
    function testGetWeeksInMonth3() {
49
        // Unusual cases that can cause fails (shows up with example 21.php)
50
        $this->assertEqual($this->engine->getWeeksInMonth(2004,2,1),5);
51
        $this->assertEqual($this->engine->getWeeksInMonth(2004,8,1),6);
52
    }
53
    function testGetDayOfWeek() {
54
        $this->assertEqual($this->engine->getDayOfWeek(2003, 11, 18), 2);
55
    }
56
    function testGetFirstDayInMonth() {
57
        $this->assertEqual($this->engine->getFirstDayInMonth(2003,10),3);
58
    }
59
    function testGetDaysInMonth() {
60
        $this->assertEqual($this->engine->getDaysInMonth(2003,10),31);
61
    }
62
    function testGetMinYears() {
63
        $test = strpos(PHP_OS, 'WIN') >= 0 ? 1970 : 1902;
64
        $this->assertEqual($this->engine->getMinYears(),$test);
65
    }
66
    function testGetMaxYears() {
67
        $this->assertEqual($this->engine->getMaxYears(),2037);
68
    }
69
    function testDateToStamp() {
70
        $stamp = mktime(0,0,0,10,15,2003);
71
        $this->assertEqual($this->engine->dateToStamp(2003,10,15,0,0,0),$stamp);
72
    }
73
    function testStampToSecond() {
74
        $stamp = mktime(13,30,45,10,15,2003);
75
        $this->assertEqual($this->engine->stampToSecond($stamp),45);
76
    }
77
    function testStampToMinute() {
78
        $stamp = mktime(13,30,45,10,15,2003);
79
        $this->assertEqual($this->engine->stampToMinute($stamp),30);
80
    }
81
    function testStampToHour() {
82
        $stamp = mktime(13,30,45,10,15,2003);
83
        $this->assertEqual($this->engine->stampToHour($stamp),13);
84
    }
85
    function testStampToDay() {
86
        $stamp = mktime(13,30,45,10,15,2003);
87
        $this->assertEqual($this->engine->stampToDay($stamp),15);
88
    }
89
    function testStampToMonth() {
90
        $stamp = mktime(13,30,45,10,15,2003);
91
        $this->assertEqual($this->engine->stampToMonth($stamp),10);
92
    }
93
    function testStampToYear() {
94
        $stamp = mktime(13,30,45,10,15,2003);
95
        $this->assertEqual($this->engine->stampToYear($stamp),2003);
96
    }
97
}
98
 
99
if (!defined('TEST_RUNNING')) {
100
    define('TEST_RUNNING', true);
101
    $test = &new TestOfUnixTsEngine();
102
    $test->run(new HtmlReporter());
103
}
104
?>