svn: /pear/packages/Validate/trunk/tests/ testdate.phpt testdate_minmax.phpt
| From: | Helgi Þormar Þorbjörnsson | Date: | Tue, 15 Mar 2011 00:27:44 +0000 |
| Subject: | svn: /pear/packages/Validate/trunk/tests/ testdate.phpt testdate_minmax.phpt | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-61438@lists.php.net to get a copy of this message | ||
dufuz Tue, 15 Mar 2011 00:27:44 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=309241
Log:
Separate the date() check and date() check that requires PEAR::Date
Changed paths:
U pear/packages/Validate/trunk/tests/testdate.phpt
A pear/packages/Validate/trunk/tests/testdate_minmax.phpt
Modified: pear/packages/Validate/trunk/tests/testdate.phpt
===================================================================
--- pear/packages/Validate/trunk/tests/testdate.phpt 2011-03-14 23:59:22 UTC (rev 309240)
+++ pear/packages/Validate/trunk/tests/testdate.phpt 2011-03-15 00:27:44 UTC (rev 309241)
@@ -9,7 +9,6 @@
// Validate test script
$noYes = array('NO', 'YES');
-require_once 'Date.php';
echo "Test Validate_Date\n";
echo "******************\n";
@@ -50,16 +49,7 @@
array('13120001', 'format'=>'%d%m%Y') // OK
);
-$dateObjects = array(
- array('11111996', 'format'=>'%d%m%Y', 'min' =>
new Date('19950101')), // OK
- array('12121996', 'format'=>'%d%m%Y', 'min' =>
new Date('19970101')), // NOK
- array('10101994', 'format'=>'%d%m%Y', 'max' =>
new Date('2005-04-27 06:24:05')), // OK
- array('11111994', 'format'=>'%d%m%Y', 'max' =>
new Date('19920101')), // NOK
- array('12121996', 'format'=>'%d%m%Y',
- 'min' => new Date('19950101'), 'max' =>
new Date('2005-04-27 06:24:05')) // OK
-);
-
-echo "\nTest dates\n";
+echo "\nTest dates\n";
foreach ($dates as $data){
$date = array_shift($data);
echo "{$date} (";
@@ -76,20 +66,6 @@
}
echo "): ".$noYes[Validate::date($date, $data)]."\n";
}
-
-echo "\nTest dates with min max object\n";
-foreach ($dateObjects as $data){
- $date = array_shift($data);
- echo "{$date} (";
- foreach ($data as $key=>$val) {
- if (($key == 'min') or ($key == 'max')) {
- echo "{$key}=>".$val->getDate()." ";
- } else {
- echo "{$key}=>{$val} ";
- }
- }
- echo "): ".$noYes[Validate::date($date, $data)]."\n";
-}
?>
--EXPECT--
Test Validate_Date
@@ -120,10 +96,3 @@
25:00 (format=>%G:%i:%s ): NO
121902 (format=>%m%Y ): YES
13120001 (format=>%d%m%Y ): YES
-
-Test dates with min max object
-11111996 (format=>%d%m%Y min=>1995-01-01 00:00:00 ): YES
-12121996 (format=>%d%m%Y min=>1997-01-01 00:00:00 ): NO
-10101994 (format=>%d%m%Y max=>2005-04-27 06:24:05 ): YES
-11111994 (format=>%d%m%Y max=>1992-01-01 00:00:00 ): NO
-12121996 (format=>%d%m%Y min=>1995-01-01 00:00:00 max=>2005-04-27 06:24:05 ): YES
Added: pear/packages/Validate/trunk/tests/testdate_minmax.phpt
===================================================================
--- pear/packages/Validate/trunk/tests/testdate_minmax.phpt (rev 0)
+++ pear/packages/Validate/trunk/tests/testdate_minmax.phpt 2011-03-15 00:27:44 UTC (rev 309241)
@@ -0,0 +1,55 @@
+--TEST--
+Unit tests for date() with min / max functionality
+--INI--
+date.timezone=UTC
+--SKIPIF--
+<?php
+if (!@include 'Date.php') {
+ echo 'skip Requires PEAR::Date';
+}
+?>
+--FILE--
+<?php
+// $Id: testdate.phpt 304327 2010-10-11 23:49:39Z clockwerx $
+require_once 'Validate.php';
+
+// Validate test script
+$noYes = array('NO', 'YES');
+require_once 'Date.php';
+
+echo "Test Validate_Date\n";
+echo "******************\n";
+
+$dateObjects = array(
+ array('11111996', 'format'=>'%d%m%Y', 'min' =>
new Date('19950101')), // OK
+ array('12121996', 'format'=>'%d%m%Y', 'min' =>
new Date('19970101')), // NOK
+ array('10101994', 'format'=>'%d%m%Y', 'max' =>
new Date('2005-04-27 06:24:05')), // OK
+ array('11111994', 'format'=>'%d%m%Y', 'max' =>
new Date('19920101')), // NOK
+ array('12121996', 'format'=>'%d%m%Y',
+ 'min' => new Date('19950101'), 'max' =>
new Date('2005-04-27 06:24:05')) // OK
+);
+
+echo "\nTest dates with min max object\n";
+foreach ($dateObjects as $data){
+ $date = array_shift($data);
+ echo "{$date} (";
+ foreach ($data as $key=>$val) {
+ if (($key == 'min') or ($key == 'max')) {
+ echo "{$key}=>".$val->getDate()." ";
+ } else {
+ echo "{$key}=>{$val} ";
+ }
+ }
+ echo "): ".$noYes[Validate::date($date, $data)]."\n";
+}
+?>
+--EXPECT--
+Test Validate_Date
+******************
+
+Test dates with min max object
+11111996 (format=>%d%m%Y min=>1995-01-01 00:00:00 ): YES
+12121996 (format=>%d%m%Y min=>1997-01-01 00:00:00 ): NO
+10101994 (format=>%d%m%Y max=>2005-04-27 06:24:05 ): YES
+11111994 (format=>%d%m%Y max=>1992-01-01 00:00:00 ): NO
+12121996 (format=>%d%m%Y min=>1995-01-01 00:00:00 max=>2005-04-27 06:24:05 ): YES