OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / include / lib / Calendar-0.5.5 / tests / minute_test.php
1 <?php
2 // $Id: minute_test.php 4940 2012-06-06 02:20:28Z fishbone $
3
4 require_once('simple_include.php');
5 require_once('calendar_include.php');
6
7 require_once('./calendar_test.php');
8
9 class TestOfMinute extends TestOfCalendar {
10     function TestOfMinute() {
11         $this->UnitTestCase('Test of Minute');
12     }
13     function setUp() {
14         $this->cal = new Calendar_Minute(2003,10,25,13,32);
15     }
16     function testPrevDay_Array () {
17         $this->assertEqual(
18             array(
19                 'year'   => 2003,
20                 'month'  => 10,
21                 'day'    => 24,
22                 'hour'   => 0,
23                 'minute' => 0,
24                 'second' => 0),
25             $this->cal->prevDay('array'));
26     }
27     function testPrevSecond () {
28         $this->assertEqual(59,$this->cal->prevSecond());
29     }
30     function testThisSecond () {
31         $this->assertEqual(0,$this->cal->thisSecond());
32     }
33     function testThisSecond_Timestamp () {
34         $this->assertEqual($this->cal->cE->dateToStamp(
35                 2003, 10, 25, 13, 32, 0),
36             $this->cal->thisSecond('timestamp'));
37     }
38     function testNextSecond () {
39         $this->assertEqual(1,$this->cal->nextSecond());
40     }
41     function testNextSecond_Timestamp () {
42         $this->assertEqual($this->cal->cE->dateToStamp(
43                 2003, 10, 25, 13, 32, 1),
44             $this->cal->nextSecond('timestamp'));
45     }
46     function testGetTimeStamp() {
47         $stamp = mktime(13,32,0,10,25,2003);
48         $this->assertEqual($stamp,$this->cal->getTimeStamp());
49     }
50 }
51
52 class TestOfMinuteBuild extends TestOfMinute {
53     function TestOfMinuteBuild() {
54         $this->UnitTestCase('Test of Minute::build()');
55     }
56     function testSize() {
57         $this->cal->build();
58         $this->assertEqual(60,$this->cal->size());
59     }
60     function testFetch() {
61         $this->cal->build();
62         $i=0;
63         while ( $Child = $this->cal->fetch() ) {
64             $i++;
65         }
66         $this->assertEqual(60,$i);
67     }
68     function testFetchAll() {
69         $this->cal->build();
70         $children = array();
71         $i = 0;
72         while ( $Child = $this->cal->fetch() ) {
73             $children[$i]=$Child;
74             $i++;
75         }
76         $this->assertEqual($children,$this->cal->fetchAll());
77     }
78     function testSelection() {
79         require_once(CALENDAR_ROOT . 'Second.php');
80         $selection = array(new Calendar_Second(2003,10,25,13,32,43));
81         $this->cal->build($selection);
82         $i = 0;
83         while ( $Child = $this->cal->fetch() ) {
84             if ( $i == 43 )
85                 break;
86             $i++;
87         }
88         $this->assertTrue($Child->isSelected());
89     }
90 }
91
92 if (!defined('TEST_RUNNING')) {
93     define('TEST_RUNNING', true);
94     $test = &new TestOfMinute();
95     $test->run(new HtmlReporter());
96     $test = &new TestOfMinuteBuild();
97     $test->run(new HtmlReporter());
98 }
99 ?>