TYPO3 CMS  TYPO3_6-2
SchedulerModuleControllerTest.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $testObject;
28 
34  public function setUp() {
35  $this->testObject = $this->getMock('TYPO3\\CMS\\Scheduler\\Controller\\SchedulerModuleController', array('dummy'), array(), '', FALSE);
36  }
37 
45  return array(
46  'now' => array(
47  'now',
48  ),
49  '10 September 2000' => array(
50  '10 September 2000',
51  ),
52  '+1 day' => array(
53  '+1 day',
54  ),
55  '+1 week' => array(
56  '+1 week',
57  ),
58  '+1 week 2 days 4 hours 2 seconds' => array(
59  '+1 week 2 days 4 hours 2 seconds',
60  ),
61  'next Thursday' => array(
62  'next Thursday',
63  ),
64  'last Monday' => array(
65  'last Monday',
66  )
67  );
68  }
69 
77  public function checkDateWithStrtotimeValues($strToTimeValue) {
78  $expectedTimestamp = strtotime($strToTimeValue);
79  $checkDateResult = $this->testObject->checkDate($strToTimeValue);
80  // We use assertLessThan here, because we test with relative values (eg. next Thursday, now, ..)
81  // If this tests runs over 1 seconds the test will fail if we use assertSame / assertEquals
82  // With assertLessThan the tests could run 0 till 3 seconds ($delta = 4)
83  $delta = 4;
84  $this->assertLessThan($delta, $checkDateResult - $expectedTimestamp, 'assertLessThan fails with value "' . $strToTimeValue . '"');
85  $this->assertInternalType(\PHPUnit_Framework_Constraint_IsType::TYPE_INT, $checkDateResult, 'assertType fails with value "' . $strToTimeValue . '"');
86  }
87 
95  return array(
96  '00:00 2011-05-30' => array(
97  '00:00 2011-05-30',
98  mktime(0, 0, 0, 5, 30, 2011)
99  ),
100  '00:01 2011-05-30' => array(
101  '00:01 2011-05-30',
102  mktime(0, 1, 0, 5, 30, 2011)
103  ),
104  '23:59 2011-05-30' => array(
105  '23:59 2011-05-30',
106  mktime(23, 59, 0, 5, 30, 2011)
107  ),
108  '15:35 2000-12-24' => array(
109  '15:35 2000-12-24',
110  mktime(15, 35, 0, 12, 24, 2000)
111  ),
112  '00:01 1970-01-01' => array(
113  '00:01 1970-01-01',
114  mktime(0, 1, 0, 1, 1, 1970)
115  ),
116  '17:26 2020-03-15' => array(
117  '17:26 2020-03-15',
118  mktime(17, 26, 0, 3, 15, 2020)
119  ),
120  '1:5 2020-03-15' => array(
121  '1:5 2020-03-15',
122  mktime(1, 5, 0, 3, 15, 2020)
123  ),
124  '10:50 2020-3-5' => array(
125  '10:50 2020-3-5',
126  mktime(10, 50, 0, 3, 5, 2020)
127  ),
128  '01:01 1968-01-01' => array(
129  '01:01 1968-01-01',
130  mktime(1, 1, 0, 1, 1, 1968)
131  )
132  );
133  }
134 
141  public function checkDateWithTypo3DateSyntax($typo3DateValue, $expectedTimestamp) {
142  $this->assertSame($expectedTimestamp, $this->testObject->checkDate($typo3DateValue), 'Fails with value "' . $typo3DateValue . '"');
143  }
144 
152  return array(
153  'Not Good' => array(
154  'Not Good'
155  ),
156  'HH:ii yyyy-mm-dd' => array(
157  'HH:ii yyyy-mm-dd'
158  )
159  );
160  }
161 
170  public function checkDateWithInvalidDateValues($dateValue) {
171  $this->testObject->checkDate($dateValue);
172  }
173 
174 }