00001 <?php
00008 class utFOUnitTestBase extends foUnitTestBase
00009 {
00010 public function doTest()
00011 {
00012 $this->_testNeedEmpty();
00013 $this->_testNeedNotEmpty();
00014 $this->_testNeedTrue();
00015 $this->_testNeedFalse();
00016 $this->_testNeedEqual();
00017 $this->_testNeedDiff();
00018 $this->_testNeedDiffReq();
00019 $this->_testNeedDate();
00020 }
00021
00022 private function _testNeedEmpty()
00023 {
00024 $this->setSectionLabel('needEmpty');
00025 $this->addSectionText('Will check FOUnitTestBase::needEmpty().');
00026
00027
00028 eval($this->needEmpty('""'));
00029
00030 $nullVar = NULL;
00031 eval($this->needEmpty('$nullVar'));
00032
00033 $emptyArray = array();
00034 eval($this->needEmpty('$emptyArray'));
00035 }
00036
00037 private function _testNeedNotEmpty()
00038 {
00039 $this->setSectionLabel('needNotEmpty');
00040
00041
00042 eval($this->needNotEmpty('"Fareoffice"'));
00043 eval($this->needNotEmpty('0'));
00044
00045 $nonEmptyVar = 'Fareoffice';
00046 eval($this->needNotEmpty('$nonEmptyVar'));
00047
00048 $trueVar = true;
00049 eval($this->needNotEmpty('$trueVar'));
00050
00051 $nonEmptyArray = array(0,1,2);
00052 eval($this->needNotEmpty('$nonEmptyArray'));
00053 }
00054
00055 private function _testNeedTrue()
00056 {
00057 $this->setSectionLabel('needTrue');
00058
00059 eval($this->needTrue('(1==1)'));
00060 eval($this->needTrue('true'));
00061 eval($this->needTrue('!false'));
00062
00063 $trueVar = true;
00064 eval($this->needTrue('$trueVar'));
00065 }
00066
00067 private function _testNeedFalse()
00068 {
00069 $this->setSectionLabel('needFalse');
00070
00071 eval($this->needFalse('(1 != 1)'));
00072 eval($this->needFalse('false'));
00073 eval($this->needFalse('!true'));
00074
00075 $falseVar = false;
00076 eval($this->needFalse('$falseVar'));
00077 }
00078
00079 private function _testNeedEqual()
00080 {
00081 $this->setSectionLabel('needEqual');
00082
00083 eval($this->needEqual('(3+2)', '5'));
00084
00085 $numVar = 5;
00086 eval($this->needEqual('$numVar', '5'));
00087
00088 $stringVar = 'Fareoffice';
00089 eval($this->needEqual('$stringVar', '"Fareoffice"'));
00090
00091 $rootDir = dir("/tmp");
00092 eval($this->needEqual('$rootDir->path', '"/tmp"'));
00093
00094 $arr = array(1,2,3,4);
00095 eval($this->needEqual('$arr', 'unserialize("a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;i:4;}")'));
00096 }
00097
00098 private function _testNeedDiff()
00099 {
00100 $this->setSectionLabel('needDiff');
00101
00102 eval($this->needDiff('(3+2)', '4'));
00103
00104 $numVar = 5;
00105 eval($this->needDiff('$numVar', '4'));
00106
00107 $stringVar = 'Fareoffice';
00108 eval($this->needDiff('$stringVar', '"fareoffice"'));
00109
00110 $rootDir = dir("/tmp");
00111 eval($this->needDiff('$rootDir->path', '"/tMp"'));
00112
00113 $arr = array(1,2,3,4);
00114 eval($this->needDiff('$arr', 'unserialize("a:4:{i:0;si:1;i:1;i:2;i:2;i:3;i:3;i:4;}")'));
00115 }
00116
00117 private function _testNeedDiffReq()
00118 {
00119 $this->setSectionLabel('needEqualReg');
00120
00121 eval($this->needEqualReg('(3+102)', '"/^[\d]{2,3}$/"'));
00122
00123 $numVar = 5;
00124 eval($this->needEqualReg('$numVar', '"/^[5]$/"'));
00125
00126 $stringVar = 'Fareoffice';
00127 eval($this->needEqualReg('$stringVar', '"/^[\w]*$/"'));
00128
00129 $rootDir = dir("/tmp");
00130 eval($this->needEqualReg('$rootDir->path', '"/^[\/][\w]*$/"'));
00131
00132 $today = date('dMY H:i:s', strtotime('now'));
00133 eval($this->needEqualReg('$today', '"/^[\d]{2}[\w]{3}[\d]{4} [\d]{2}[:][\d]{2}[:][\d]{2}$/"'));
00134 }
00135
00136 private function _testNeedDate()
00137 {
00138 $this->setSectionLabel('needDate');
00139
00140 eval($this->needDate('"2001-01-01"'));
00141 eval($this->needDate('"2001-01-30"'));
00142 eval($this->needDate('"2001-01-20 20:00"'));
00143 eval($this->needDate('"2001-01-20 20:00:00"'));
00144 eval($this->needDate('"2001-01-20 20:00:00"'));
00145 eval($this->needDate('"01jan2009"'));
00146 }
00147 }
00148 ?>