| 1 | <?php |
|---|
| 2 | // $Id: helper_test.php,v 1.1 2004/05/24 22:25:43 quipo Exp $ |
|---|
| 3 | |
|---|
| 4 | require_once('simple_include.php'); |
|---|
| 5 | require_once('calendar_include.php'); |
|---|
| 6 | |
|---|
| 7 | Mock::generate('Calendar_Engine_Interface','Mock_Calendar_Engine'); |
|---|
| 8 | Mock::generate('Calendar_Second','Mock_Calendar_Second'); |
|---|
| 9 | |
|---|
| 10 | class TestOfTableHelper extends UnitTestCase { |
|---|
| 11 | var $mockengine; |
|---|
| 12 | var $mockcal; |
|---|
| 13 | function TestOfTableHelper() { |
|---|
| 14 | $this->UnitTestCase('Test of Calendar_Table_Helper'); |
|---|
| 15 | } |
|---|
| 16 | function setUp() { |
|---|
| 17 | $this->mockengine = new Mock_Calendar_Engine($this); |
|---|
| 18 | $this->mockengine->setReturnValue('getMinYears',1970); |
|---|
| 19 | $this->mockengine->setReturnValue('getMaxYears',2037); |
|---|
| 20 | $this->mockengine->setReturnValue('getMonthsInYear',12); |
|---|
| 21 | $this->mockengine->setReturnValue('getDaysInMonth',31); |
|---|
| 22 | $this->mockengine->setReturnValue('getHoursInDay',24); |
|---|
| 23 | $this->mockengine->setReturnValue('getMinutesInHour',60); |
|---|
| 24 | $this->mockengine->setReturnValue('getSecondsInMinute',60); |
|---|
| 25 | $this->mockengine->setReturnValue('getWeekDays',array(0,1,2,3,4,5,6)); |
|---|
| 26 | $this->mockengine->setReturnValue('getDaysInWeek',7); |
|---|
| 27 | $this->mockengine->setReturnValue('getFirstDayOfWeek',1); |
|---|
| 28 | $this->mockengine->setReturnValue('getFirstDayInMonth',3); |
|---|
| 29 | $this->mockcal = new Mock_Calendar_Second($this); |
|---|
| 30 | $this->mockcal->setReturnValue('thisYear',2003); |
|---|
| 31 | $this->mockcal->setReturnValue('thisMonth',10); |
|---|
| 32 | $this->mockcal->setReturnValue('thisDay',15); |
|---|
| 33 | $this->mockcal->setReturnValue('thisHour',13); |
|---|
| 34 | $this->mockcal->setReturnValue('thisMinute',30); |
|---|
| 35 | $this->mockcal->setReturnValue('thisSecond',45); |
|---|
| 36 | $this->mockcal->setReturnValue('getEngine',$this->mockengine); |
|---|
| 37 | } |
|---|
| 38 | function testGetFirstDay() { |
|---|
| 39 | for ( $i = 0; $i <= 7; $i++ ) { |
|---|
| 40 | $Helper = & new Calendar_Table_Helper($this->mockcal,$i); |
|---|
| 41 | $this->assertEqual($Helper->getFirstDay(),$i); |
|---|
| 42 | } |
|---|
| 43 | } |
|---|
| 44 | function testGetDaysOfWeekMonday() { |
|---|
| 45 | $Helper = & new Calendar_Table_Helper($this->mockcal); |
|---|
| 46 | $this->assertEqual($Helper->getDaysOfWeek(),array(1,2,3,4,5,6,0)); |
|---|
| 47 | } |
|---|
| 48 | function testGetDaysOfWeekSunday() { |
|---|
| 49 | $Helper = & new Calendar_Table_Helper($this->mockcal,0); |
|---|
| 50 | $this->assertEqual($Helper->getDaysOfWeek(),array(0,1,2,3,4,5,6)); |
|---|
| 51 | } |
|---|
| 52 | function testGetDaysOfWeekThursday() { |
|---|
| 53 | $Helper = & new Calendar_Table_Helper($this->mockcal,4); |
|---|
| 54 | $this->assertEqual($Helper->getDaysOfWeek(),array(4,5,6,0,1,2,3)); |
|---|
| 55 | } |
|---|
| 56 | function testGetNumWeeks() { |
|---|
| 57 | $Helper = & new Calendar_Table_Helper($this->mockcal); |
|---|
| 58 | $this->assertEqual($Helper->getNumWeeks(),5); |
|---|
| 59 | } |
|---|
| 60 | function testGetNumTableDaysInMonth() { |
|---|
| 61 | $Helper = & new Calendar_Table_Helper($this->mockcal); |
|---|
| 62 | $this->assertEqual($Helper->getNumTableDaysInMonth(),35); |
|---|
| 63 | } |
|---|
| 64 | function testGetEmptyDaysBefore() { |
|---|
| 65 | $Helper = & new Calendar_Table_Helper($this->mockcal); |
|---|
| 66 | $this->assertEqual($Helper->getEmptyDaysBefore(),2); |
|---|
| 67 | } |
|---|
| 68 | function testGetEmptyDaysAfter() { |
|---|
| 69 | $Helper = & new Calendar_Table_Helper($this->mockcal); |
|---|
| 70 | $this->assertEqual($Helper->getEmptyDaysAfter(),33); |
|---|
| 71 | } |
|---|
| 72 | function testGetEmptyDaysAfterOffset() { |
|---|
| 73 | $Helper = & new Calendar_Table_Helper($this->mockcal); |
|---|
| 74 | $this->assertEqual($Helper->getEmptyDaysAfterOffset(),5); |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | if (!defined('TEST_RUNNING')) { |
|---|
| 79 | define('TEST_RUNNING', true); |
|---|
| 80 | $test = &new TestOfTableHelper(); |
|---|
| 81 | $test->run(new HtmlReporter()); |
|---|
| 82 | } |
|---|
| 83 | ?> |
|---|