From 61bb16ee2e5f0a66234e1575242169a10fde47b5 Mon Sep 17 00:00:00 2001 From: xue <> Date: Fri, 7 Jul 2006 14:54:15 +0000 Subject: Merge from 3.0 branch till 1253. --- tests/UnitTests/framework/Collections/utList.php | 236 ------------ tests/UnitTests/framework/Collections/utMap.php | 160 -------- tests/UnitTests/framework/Data/CacheTestCase.php | 98 ----- tests/UnitTests/framework/Data/test.db | Bin 4096 -> 0 bytes tests/UnitTests/framework/Data/utAPCCache.php | 45 --- .../framework/Data/utDateTimeSimpleFormatter.php | 81 ---- tests/UnitTests/framework/Data/utMemCache.php | 66 ---- tests/UnitTests/framework/Data/utSqliteCache.php | 59 --- tests/UnitTests/framework/Data/utXmlDocument.php | 82 ---- tests/UnitTests/framework/Data/xml/data1.xml | 45 --- tests/UnitTests/framework/Data/xml/data1.xml.out | 41 -- tests/UnitTests/framework/Data/xml/data2.xml | 41 -- tests/UnitTests/framework/Data/xml/data2.xml.out | 40 -- tests/UnitTests/framework/Data/xml/data3.xml | 46 --- tests/UnitTests/framework/Data/xml/data3.xml.out | 45 --- .../framework/I18N/TestOfDateTimeFormatInfo.php | 223 ----------- .../UnitTests/framework/I18N/messages/en/tests.mo | Bin 403 -> 0 bytes .../UnitTests/framework/I18N/messages/en/tests.po | 18 - .../UnitTests/framework/I18N/messages/en/tests.xml | 17 - .../framework/I18N/messages/en_AU/tests.mo | Bin 371 -> 0 bytes .../framework/I18N/messages/en_AU/tests.mo.bak | Bin 371 -> 0 bytes .../framework/I18N/messages/en_AU/tests.po | 15 - .../framework/I18N/messages/en_AU/tests.po.bak | 15 - .../framework/I18N/messages/en_AU/tests.xml | 13 - .../framework/I18N/messages/en_AU/tests.xml.bak | 13 - .../UnitTests/framework/I18N/messages/messages.db | Bin 8192 -> 0 bytes .../framework/I18N/messages/messages.db.bak | Bin 8192 -> 0 bytes .../framework/I18N/messages/messages.en.mo | Bin 373 -> 0 bytes .../framework/I18N/messages/messages.en.po | 15 - .../framework/I18N/messages/messages.en.xml | 19 - .../framework/I18N/messages/messages.en_AU.mo | Bin 414 -> 0 bytes .../framework/I18N/messages/messages.en_AU.mo.bak | Bin 414 -> 0 bytes .../framework/I18N/messages/messages.en_AU.po | 18 - .../framework/I18N/messages/messages.en_AU.po.bak | 18 - .../framework/I18N/messages/messages.en_AU.xml | 17 - .../framework/I18N/messages/messages.en_AU.xml.bak | 17 - .../UnitTests/framework/I18N/messages/messages.mo | Bin 409 -> 0 bytes .../UnitTests/framework/I18N/messages/messages.po | 18 - .../UnitTests/framework/I18N/messages/messages.xml | 23 -- .../framework/I18N/messages/messages_mysql.sql | 69 ---- .../framework/I18N/messages/tests.en_AU.po | 7 - tests/UnitTests/framework/I18N/messages/tests.mo | Bin 404 -> 0 bytes tests/UnitTests/framework/I18N/messages/tests.po | 18 - tests/UnitTests/framework/I18N/messages/tests.xml | 17 - .../UnitTests/framework/I18N/testChoiceFormat.php | 34 -- tests/UnitTests/framework/I18N/testCultureInfo.php | 94 ----- tests/UnitTests/framework/I18N/testDateFormat.php | 99 ----- .../UnitTests/framework/I18N/testMessageFormat.php | 13 - .../framework/I18N/testMessageFormat_SQLite.php | 142 ------- .../framework/I18N/testMessageFormat_XLIFF.php | 174 --------- .../framework/I18N/testMessageFormat_gettext.php | 176 --------- .../UnitTests/framework/I18N/testNumberFormat.php | 113 ------ .../framework/I18N/testNumberFormatInfo.php | 105 ------ tests/UnitTests/framework/I18N/tmp/cache.txt | 0 .../framework/TestSystem/protected/application.xml | 21 -- .../framework/TestSystem/protected/data/test.db | Bin 5120 -> 0 bytes .../TestSystem/protected/pages/config.xml | 12 - tests/UnitTests/framework/Web/UI/utControl.php | 416 --------------------- .../framework/Web/UI/utJavascriptSerializer.php | 181 --------- tests/UnitTests/framework/Web/utHttpRequest.php | 268 ------------- tests/UnitTests/framework/common.php | 99 ----- tests/UnitTests/framework/index.php | 103 ----- tests/UnitTests/framework/utApplication.php | 25 -- tests/UnitTests/framework/utComponent.php | 329 ---------------- tests/UnitTests/framework/utPradoBase.php | 110 ------ 65 files changed, 4169 deletions(-) delete mode 100644 tests/UnitTests/framework/Collections/utList.php delete mode 100644 tests/UnitTests/framework/Collections/utMap.php delete mode 100644 tests/UnitTests/framework/Data/CacheTestCase.php delete mode 100644 tests/UnitTests/framework/Data/test.db delete mode 100644 tests/UnitTests/framework/Data/utAPCCache.php delete mode 100644 tests/UnitTests/framework/Data/utDateTimeSimpleFormatter.php delete mode 100644 tests/UnitTests/framework/Data/utMemCache.php delete mode 100644 tests/UnitTests/framework/Data/utSqliteCache.php delete mode 100644 tests/UnitTests/framework/Data/utXmlDocument.php delete mode 100644 tests/UnitTests/framework/Data/xml/data1.xml delete mode 100644 tests/UnitTests/framework/Data/xml/data1.xml.out delete mode 100644 tests/UnitTests/framework/Data/xml/data2.xml delete mode 100644 tests/UnitTests/framework/Data/xml/data2.xml.out delete mode 100644 tests/UnitTests/framework/Data/xml/data3.xml delete mode 100644 tests/UnitTests/framework/Data/xml/data3.xml.out delete mode 100644 tests/UnitTests/framework/I18N/TestOfDateTimeFormatInfo.php delete mode 100644 tests/UnitTests/framework/I18N/messages/en/tests.mo delete mode 100644 tests/UnitTests/framework/I18N/messages/en/tests.po delete mode 100644 tests/UnitTests/framework/I18N/messages/en/tests.xml delete mode 100644 tests/UnitTests/framework/I18N/messages/en_AU/tests.mo delete mode 100644 tests/UnitTests/framework/I18N/messages/en_AU/tests.mo.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/en_AU/tests.po delete mode 100644 tests/UnitTests/framework/I18N/messages/en_AU/tests.po.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/en_AU/tests.xml delete mode 100644 tests/UnitTests/framework/I18N/messages/en_AU/tests.xml.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.db delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.db.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en.mo delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en.po delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en.xml delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en_AU.mo delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en_AU.mo.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en_AU.po delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en_AU.po.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en_AU.xml delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.en_AU.xml.bak delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.mo delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.po delete mode 100644 tests/UnitTests/framework/I18N/messages/messages.xml delete mode 100644 tests/UnitTests/framework/I18N/messages/messages_mysql.sql delete mode 100644 tests/UnitTests/framework/I18N/messages/tests.en_AU.po delete mode 100644 tests/UnitTests/framework/I18N/messages/tests.mo delete mode 100644 tests/UnitTests/framework/I18N/messages/tests.po delete mode 100644 tests/UnitTests/framework/I18N/messages/tests.xml delete mode 100644 tests/UnitTests/framework/I18N/testChoiceFormat.php delete mode 100644 tests/UnitTests/framework/I18N/testCultureInfo.php delete mode 100644 tests/UnitTests/framework/I18N/testDateFormat.php delete mode 100644 tests/UnitTests/framework/I18N/testMessageFormat.php delete mode 100644 tests/UnitTests/framework/I18N/testMessageFormat_SQLite.php delete mode 100644 tests/UnitTests/framework/I18N/testMessageFormat_XLIFF.php delete mode 100644 tests/UnitTests/framework/I18N/testMessageFormat_gettext.php delete mode 100644 tests/UnitTests/framework/I18N/testNumberFormat.php delete mode 100644 tests/UnitTests/framework/I18N/testNumberFormatInfo.php delete mode 100644 tests/UnitTests/framework/I18N/tmp/cache.txt delete mode 100644 tests/UnitTests/framework/TestSystem/protected/application.xml delete mode 100644 tests/UnitTests/framework/TestSystem/protected/data/test.db delete mode 100644 tests/UnitTests/framework/TestSystem/protected/pages/config.xml delete mode 100644 tests/UnitTests/framework/Web/UI/utControl.php delete mode 100644 tests/UnitTests/framework/Web/UI/utJavascriptSerializer.php delete mode 100644 tests/UnitTests/framework/Web/utHttpRequest.php delete mode 100644 tests/UnitTests/framework/common.php delete mode 100644 tests/UnitTests/framework/index.php delete mode 100644 tests/UnitTests/framework/utApplication.php delete mode 100644 tests/UnitTests/framework/utComponent.php delete mode 100644 tests/UnitTests/framework/utPradoBase.php (limited to 'tests/UnitTests/framework') diff --git a/tests/UnitTests/framework/Collections/utList.php b/tests/UnitTests/framework/Collections/utList.php deleted file mode 100644 index e95f718b..00000000 --- a/tests/UnitTests/framework/Collections/utList.php +++ /dev/null @@ -1,236 +0,0 @@ -list=new TList; - $this->item1=new ListItem; - $this->item2=new ListItem; - $this->item3=new ListItem; - $this->list->add($this->item1); - $this->list->add($this->item2); - } - - public function tearDown() - { - $this->list=null; - $this->item1=null; - $this->item2=null; - $this->item3=null; - } - - public function testConstruct() - { - $a=array(1,2,3); - $list=new TList($a); - $this->assertEqual(3,$list->getCount()); - $list2=new TList($this->list); - $this->assertEqual(2,$list2->getCount()); - } - public function testGetCount() - { - $this->assertEqual(2,$this->list->getCount()); - $this->assertEqual(2,$this->list->Count); - } - - public function testAdd() - { - $this->list->add(null); - $this->list->add($this->item3); - $this->assertEqual(4,$this->list->getCount()); - $this->assertEqual(3,$this->list->indexOf($this->item3)); - } - - - public function testInsertAt() - { - $this->list->insertAt(0,$this->item3); - $this->assertEqual(3,$this->list->getCount()); - $this->assertEqual(2,$this->list->indexOf($this->item2)); - $this->assertEqual(0,$this->list->indexOf($this->item3)); - $this->assertEqual(1,$this->list->indexOf($this->item1)); - try - { - $this->list->insertAt(4,$this->item3); - $this->fail('exception not raised when adding item at an out-of-range index'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - } - - public function testRemove() - { - $this->list->remove($this->item1); - $this->assertEqual(1,$this->list->getCount()); - $this->assertEqual(-1,$this->list->indexOf($this->item1)); - $this->assertEqual(0,$this->list->indexOf($this->item2)); - try - { - $this->list->remove($this->item1); - $this->fail('exception not raised when removing nonexisting item'); - } - catch(Exception $e) - { - $this->pass(); - } - } - - public function testRemoveAt() - { - $this->list->add($this->item3); - $this->list->removeAt(1); - $this->assertEqual(-1,$this->list->indexOf($this->item2)); - $this->assertEqual(1,$this->list->indexOf($this->item3)); - $this->assertEqual(0,$this->list->indexOf($this->item1)); - try - { - $this->list->removeAt(2); - $this->fail('exception not raised when removing item with invalid index'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - } - - public function testClear() - { - $this->list->clear(); - $this->assertEqual(0,$this->list->getCount()); - $this->assertEqual(-1,$this->list->indexOf($this->item1)); - $this->assertEqual(-1,$this->list->indexOf($this->item2)); - } - - public function testContains() - { - $this->assertTrue($this->list->contains($this->item1)); - $this->assertTrue($this->list->contains($this->item2)); - $this->assertFalse($this->list->contains($this->item3)); - } - - public function testIndexOf() - { - $this->assertEqual(0,$this->list->indexOf($this->item1)); - $this->assertEqual(1,$this->list->indexOf($this->item2)); - $this->assertEqual(-1,$this->list->indexOf($this->item3)); - } - - public function testCopyFrom() - { - $array=array($this->item3,$this->item1); - $this->list->copyFrom($array); - $this->assertTrue(count($array)==2 && $this->list[0]===$this->item3 && $this->list[1]===$this->item1); - try - { - $this->list->copyFrom($this); - $this->fail('exception not raised when copying from non-traversable object'); - } - catch(TInvalidDataTypeException $e) - { - $this->pass(); - } - } - - public function testMergeWith() - { - $array=array($this->item3,$this->item1); - $this->list->mergeWith($array); - $this->assertTrue($this->list->getCount()==4 && $this->list[0]===$this->item1 && $this->list[3]===$this->item1); - try - { - $this->list->mergeWith($this); - $this->fail('exception not raised when copying from non-traversable object'); - } - catch(TInvalidDataTypeException $e) - { - $this->pass(); - } - } - - public function testToArray() - { - $array=$this->list->toArray(); - $this->assertTrue(count($array)==2 && $array[0]===$this->item1 && $array[1]===$this->item2); - } - - public function testArrayRead() - { - $this->assertTrue($this->list[0]===$this->item1); - $this->assertTrue($this->list[1]===$this->item2); - try - { - $a=$this->list[2]; - $this->fail('exception not raised when accessing item with out-of-range index'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - } - - public function testArrayWrite() - { - $this->list[]=$this->item3; - $this->assertTrue($this->list[2]===$this->item3 && $this->list->getCount()===3); - $this->list[0]=$this->item3; - $this->assertTrue($this->list[0]===$this->item3 && $this->list->getCount()===3 && $this->list->indexOf($this->item1)===-1); - unset($this->list[1]); - $this->assertTrue($this->list->getCount()===2 && $this->list->indexOf($this->item2)===-1); - try - { - $this->list[5]=$this->item3; - $this->fail('exception not raised when setting item at an out-of-range index'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - try - { - unset($this->list[5]); - $this->fail('exception not raised when unsetting item at an out-of-range index'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - } - - public function testGetIterator() - { - $n=0; - $found=0; - foreach($this->list as $index=>$item) - { - foreach($this->list as $a=>$b); // test of iterator - $n++; - if($index===0 && $item===$this->item1) - $found++; - if($index===1 && $item===$this->item2) - $found++; - } - $this->assertTrue($n==2 && $found==2); - } - - public function testArrayMisc() - { - $this->assertEqual(1,count($this->list)); - $this->assertTrue(isset($this->list[1])); - $this->assertFalse(isset($this->list[2])); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Collections/utMap.php b/tests/UnitTests/framework/Collections/utMap.php deleted file mode 100644 index 37818542..00000000 --- a/tests/UnitTests/framework/Collections/utMap.php +++ /dev/null @@ -1,160 +0,0 @@ -map=new TMap; - $this->item1=new MapItem; - $this->item2=new MapItem; - $this->item3=new MapItem; - $this->map->add('key1',$this->item1); - $this->map->add('key2',$this->item2); - } - - public function tearDown() - { - $this->map=null; - $this->item1=null; - $this->item2=null; - $this->item3=null; - } - - public function testConstruct() - { - $a=array(1,2,'key3'=>3); - $map=new TMap($a); - $this->assertEqual(3,$map->getCount()); - $map2=new TMap($this->map); - $this->assertEqual(2,$map2->getCount()); - } - - public function testGetCount() - { - $this->assertEqual(2,$this->map->getCount()); - } - - public function testGetKeys() - { - $keys=$this->map->getKeys(); - $this->assertTrue(count($keys)===2 && $keys[0]==='key1' && $keys[1]==='key2'); - } - - public function testAdd() - { - $this->map->add('key3',$this->item3); - $this->assertTrue($this->map->getCount()==3 && $this->map->contains('key3')); - } - - public function testRemove() - { - $this->map->remove('key1'); - $this->assertTrue($this->map->getCount()==1 && !$this->map->contains('key1')); - $this->assertTrue($this->map->remove('unknown key')===null); - } - - public function testClear() - { - $this->map->clear(); - $this->assertTrue($this->map->getCount()==0 && !$this->map->contains('key1') && !$this->map->contains('key2')); - } - - public function testContains() - { - $this->assertTrue($this->map->contains('key1')); - $this->assertTrue($this->map->contains('key2')); - $this->assertFalse($this->map->contains('key3')); - } - - public function testCopyFrom() - { - $array=array('key3'=>$this->item3,'key4'=>$this->item1); - $this->map->copyFrom($array); - $this->assertTrue($this->map->getCount()==2 && $this->map['key3']===$this->item3 && $this->map['key4']===$this->item1); - try - { - $this->map->copyFrom($this); - $this->fail('no exception raised when copying a non-traversable object'); - } - catch(TInvalidDataTypeException $e) - { - $this->pass(); - } - } - - public function testMergeWith() - { - $array=array('key2'=>$this->item1,'key3'=>$this->item3); - $this->map->mergeWith($array); - $this->assertTrue($this->map->getCount()==3 && $this->map['key2']===$this->item1 && $this->map['key3']===$this->item3); - try - { - $this->map->mergeWith($this); - $this->fail('no exception raised when copying a non-traversable object'); - } - catch(TInvalidDataTypeException $e) - { - $this->pass(); - } - } - - public function testArrayRead() - { - $this->assertTrue($this->map['key1']===$this->item1); - $this->assertTrue($this->map['key2']===$this->item2); - $this->assertEqual(null,$this->map['key3']); - } - - public function testArrayWrite() - { - $this->map['key3']=$this->item3; - $this->assertTrue($this->map['key3']===$this->item3 && $this->map->getCount()===3); - $this->map['key1']=$this->item3; - $this->assertTrue($this->map['key1']===$this->item3 && $this->map->getCount()===3); - unset($this->map['key2']); - $this->assertTrue($this->map->getCount()===2 && !$this->map->contains('key2')); - try - { - unset($this->map['unknown key']); - $this->pass(); - } - catch(Exception $e) - { - $this->fail('exception raised when unsetting element with unknown key'); - } - } - - public function testArrayForeach() - { - $n=0; - $found=0; - foreach($this->map as $index=>$item) - { - $n++; - if($index==='key1' && $item===$this->item1) - $found++; - if($index==='key2' && $item===$this->item2) - $found++; - } - $this->assertTrue($n==2 && $found==2); - } - - public function testArrayMisc() - { - $this->assertEqual(1,count($this->map)); - $this->assertTrue(isset($this->map['key1'])); - $this->assertFalse(isset($this->map['unknown key'])); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/CacheTestCase.php b/tests/UnitTests/framework/Data/CacheTestCase.php deleted file mode 100644 index 68a7b067..00000000 --- a/tests/UnitTests/framework/Data/CacheTestCase.php +++ /dev/null @@ -1,98 +0,0 @@ -_cache; - } - - public function setCache($cache) - { - $this->_cache=$cache; - } - - public function basicOperations() - { - $object=new TComponent; - $number=12345; - $string='12345\'"'; - $array=array('123'=>123,'abc'=>'def'); - - // test set (first time) - $this->assertFalse($this->_cache->get('object')); - $this->assertTrue($this->_cache->set('object',$object)); - $this->assertTrue($this->_cache->get('object') instanceof TComponent); - $this->assertFalse($this->_cache->get('number')); - $this->assertTrue($this->_cache->set('number',$number)); - $this->assertTrue($this->_cache->get('number')===$number); - $this->assertFalse($this->_cache->get('string')); - $this->assertTrue($this->_cache->set('string',$string)); - $this->assertTrue($this->_cache->get('string')===$string); - $this->assertFalse($this->_cache->get('array')); - $this->assertTrue($this->_cache->set('array',$array)); - $this->assertTrue($this->_cache->get('array')===$array); - - // test set (second time) - $this->assertTrue($this->_cache->set('object',$array)); - $this->assertTrue($this->_cache->get('object')===$array); - - // test delete - $this->assertTrue($this->_cache->delete('object')); - $this->assertFalse($this->_cache->get('object')); - $this->assertTrue($this->_cache->delete('number')); - $this->assertFalse($this->_cache->get('number')); - $this->assertTrue($this->_cache->delete('string')); - $this->assertFalse($this->_cache->get('string')); - $this->assertTrue($this->_cache->delete('array')); - $this->assertFalse($this->_cache->get('array')); - - // test add (first time) - $this->assertFalse($this->_cache->get('object')); - $this->assertTrue($this->_cache->add('object',$object)); - $this->assertTrue($this->_cache->get('object') instanceof TComponent); - $this->assertFalse($this->_cache->get('number')); - $this->assertTrue($this->_cache->add('number',$number)); - $this->assertTrue($this->_cache->get('number')===$number); - $this->assertFalse($this->_cache->get('string')); - $this->assertTrue($this->_cache->add('string',$string)); - $this->assertTrue($this->_cache->get('string')===$string); - $this->assertFalse($this->_cache->get('array')); - $this->assertTrue($this->_cache->add('array',$array)); - $this->assertTrue($this->_cache->get('array')===$array); - - // test add (second time) - $this->assertFalse($this->_cache->add('object',$array)); - $this->assertTrue($this->_cache->get('object') instanceof TComponent); - - // test replace - $this->assertTrue($this->_cache->replace('object',$array)); - $this->assertTrue($this->_cache->get('object')===$array); - $this->assertFalse($this->_cache->replace('object2',$array)); - $this->assertFalse($this->_cache->get('object2')); - - // test flush - $this->assertTrue($this->_cache->set('number',$number)); - $this->assertTrue($this->_cache->get('number')===$number); - $this->assertTrue($this->_cache->flush()); - $this->assertFalse($this->_cache->get('number')); - - // test expiring - // set a value with 5sec valid time - $this->_cache->set('expiring',123,3); - $this->assertTrue($this->_cache->get('expiring')===123); - $this->_cache->set('nonexpiring',456); - $this->assertTrue($this->_cache->get('nonexpiring')===456); - - // wait 6sec to see if the value still exists - sleep(4); - $this->assertFalse($this->_cache->get('expiring')); - $this->assertTrue($this->_cache->get('nonexpiring')===456); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/test.db b/tests/UnitTests/framework/Data/test.db deleted file mode 100644 index fcf08f16..00000000 Binary files a/tests/UnitTests/framework/Data/test.db and /dev/null differ diff --git a/tests/UnitTests/framework/Data/utAPCCache.php b/tests/UnitTests/framework/Data/utAPCCache.php deleted file mode 100644 index 48458c27..00000000 --- a/tests/UnitTests/framework/Data/utAPCCache.php +++ /dev/null @@ -1,45 +0,0 @@ -fail('TAPCCache is not tested. PHP extension "apc" is required by TAPCCache.'); - return; - } - //compatibility test as this time of writing 01/02/2006 (dd//mm//yyyy) - $apc_default_ini = $apc_default=ini_get('apc.cache_by_default'); - if ($apc_default=='Off' || $apc_default='off') - $apc_default=0; - elseif($apc_default=='On' || $apc_default='on') - $apc_default=1; - $apc_default=(boolean)$apc_default; - if($apc_default) { - $this->fail('You have to disable apc.cache_by_default in your php.ini : you have apc.cache_by_default='.$apc_default_ini.' but currently prado won\'t execute without errors with APC caching all prado php files.'); - return; - } - } - - public function testBasicOperations() - { - if(!extension_loaded('apc')) - { - $this->fail('TAPCCache is not tested. PHP extension "apc" is required by TAPCCache.'); - return; - } - $cache=new TAPCCache; - $cache->init(null); - $this->setCache($cache); - $this->basicOperations(); - $this->setCache(null); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/utDateTimeSimpleFormatter.php b/tests/UnitTests/framework/Data/utDateTimeSimpleFormatter.php deleted file mode 100644 index 9c505481..00000000 --- a/tests/UnitTests/framework/Data/utDateTimeSimpleFormatter.php +++ /dev/null @@ -1,81 +0,0 @@ -assertEqual($expect, $formatter->format($time)); - - $time = mktime(0,0,0,5,6,2005); - $pattern = "d-M-yy"; - $expect = "6-5-05"; - - $formatter->setPattern($pattern); - $this->assertEqual($expect, $formatter->format($time)); - - $pattern = "dd-MM-yy"; - $expect = "06-05-05"; - - $formatter->setPattern($pattern); - $this->assertEqual($expect, $formatter->format($time)); - - $pattern = "yyyy年MM月dd日"; - $expect = "2005年05月06日"; - - $formatter = new TDateTimeSimpleFormatter($pattern, 'GB2312'); - $this->assertEqual($expect, $formatter->format($time)); - - $pattern = "MM/dd/yyyy"; - $expect = "05/06/2005"; - - $formatter = new TDateTimeSimpleFormatter($pattern, 'UTF-8'); - $this->assertEqual($expect, $formatter->format($time)); - - } - - function testParsing() - { - $pattern = "yyyy年MM月dd日"; - $value = "2005年05月06日"; - $expect = mktime(0,0,0,5,6,2005); - - $formatter = new TDateTimeSimpleFormatter($pattern, 'GB2312'); - $this->assertEqual($expect, $formatter->parse($value)); - - $pattern = "dd-MM-yy"; - $value= "06-05-05"; - - $formatter = new TDateTimeSimpleFormatter($pattern); - $this->assertEqual($expect, $formatter->parse($value)); - - $pattern = "d-M-yy"; - $value = "6-5-05"; - $formatter = new TDateTimeSimpleFormatter($pattern); - $this->assertEqual($expect, $formatter->parse($value)); - - $pattern = "MM/dd/yyyy"; - $value = "05/06/2005"; - $formatter = new TDateTimeSimpleFormatter($pattern); - $this->assertEqual($expect, $formatter->parse($value)); - - - $pattern = "dd-MM-yyyy"; - $value = '30-12-2005'; - $expect = mktime(0,0,0,12,30,2005); - - $formatter = new TDateTimeSimpleFormatter($pattern); - $this->assertEqual($expect, $formatter->parse($value)); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/utMemCache.php b/tests/UnitTests/framework/Data/utMemCache.php deleted file mode 100644 index cbe9bdad..00000000 --- a/tests/UnitTests/framework/Data/utMemCache.php +++ /dev/null @@ -1,66 +0,0 @@ -fail('TMemCache is not tested. PHP extension "memcache" is required by TMemCache.'); - return; - } - $cache=new TMemCache; - - $this->assertTrue($cache->getHost()==='localhost'); - $cache->setHost('localhost2'); - $this->assertTrue($cache->getHost()==='localhost2'); - - $this->assertTrue($cache->getPort()===11211); - $cache->setPort(1000); - $this->assertTrue($cache->getPort()===1000); - - $cache->init(null,null); - try - { - $cache->setHost('newhost'); - $this->fail('exception not raised when setting Server after init'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - try - { - $cache->setPort(10000); - $this->fail('exception not raised when setting Port after init'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testBasicOperations() - { - if(!extension_loaded('memcache')) - { - $this->fail('TMemCache is not tested. PHP extension "memcache" is required by TMemCache.'); - return; - } - $cache=new TMemCache; - $cache->init(null,null); - $this->setCache($cache); - $this->basicOperations(); - $this->setCache(null); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/utSqliteCache.php b/tests/UnitTests/framework/Data/utSqliteCache.php deleted file mode 100644 index eded351f..00000000 --- a/tests/UnitTests/framework/Data/utSqliteCache.php +++ /dev/null @@ -1,59 +0,0 @@ -dbFile='utSqliteCache.test'; - } - - public function tearDown() - { - $file=Prado::getPathOfNamespace('utSqliteCache.test',TSqliteCache::DB_FILE_EXT); - if(is_file($file)) - unlink($file); - else - $this->fail("Unable to clean up db file: '".$file."'."); - } - - public function testInit() - { - $cache=new TSqliteCache; - - $this->assertTrue($cache->getDbFile()===null); - $cache->setDbFile($this->dbFile); - $this->assertTrue($cache->getDbFile()===$this->dbFile); - - $cache->init(null,null); - try - { - $cache->setDbFile('newfile.db'); - $this->fail('exception not raised when setting DbFile after init'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testBasicOperations() - { - $cache=new TSqliteCache; - $cache->setDbFile($this->dbFile); - $cache->init(null,null); - $this->setCache($cache); - $this->basicOperations(); - $this->setCache(null); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/utXmlDocument.php b/tests/UnitTests/framework/Data/utXmlDocument.php deleted file mode 100644 index ec0e43c7..00000000 --- a/tests/UnitTests/framework/Data/utXmlDocument.php +++ /dev/null @@ -1,82 +0,0 @@ -loadFromFile('nonexisting.xml'); - $this->fail('exception not raised when openning a nonexistent file.'); - } - catch(TIOException $e) - { - $this->pass(); - } - - $doc=new TXmlDocument; - $this->assertFalse(@$doc->loadFromString('$12341')); - - // a regular XML file - $doc=new TXmlDocument; - $doc->loadFromFile($dir.'/data1.xml'); - $doc->saveToFile($dir.'/data1.xml.tmp'); - $this->assertTrue($this->compareFiles($dir.'/data1.xml.tmp',$dir.'/data1.xml.out')); - @unlink($dir.'/data1.xml.tmp'); - - // an XML file with Chinese characters - $doc->loadFromFile($dir.'/data2.xml'); - $doc->saveToFile($dir.'/data2.xml.tmp'); - $this->assertTrue($this->compareFiles($dir.'/data2.xml.tmp',$dir.'/data2.xml.out')); - @unlink($dir.'/data2.xml.tmp'); - - // a typical Prado Application configuration file - $doc=new TXmlDocument; - $doc->loadFromFile($dir.'/data3.xml'); - $doc->saveToFile($dir.'/data3.xml.tmp'); - $this->assertTrue($this->compareFiles($dir.'/data3.xml.tmp',$dir.'/data3.xml.out')); - @unlink($dir.'/data3.xml.tmp'); - } - - protected function compareFiles($file1,$file2) - { - return file_get_contents($file1)===file_get_contents($file2); - } - - public function testAccessDomTree() - { - $dir=dirname(__FILE__).'/xml'; - $doc=new TXmlDocument; - $doc->loadFromFile($dir.'/data1.xml'); - $this->assertTrue($doc->getVersion()==='1.0'); - $this->assertTrue($doc->getEncoding()==='utf-8'); - $this->assertTrue($doc->getElements()->getCount()===2); - $this->assertTrue($doc->getElements()->itemAt(0)->getTagName()==='title'); - $this->assertTrue($doc->getElements()->itemAt(0)->getValue()==='My lists'); - $this->assertTrue($doc->getElements()->itemAt(1)->getTagName()==='chapter'); - $this->assertTrue($doc->getElements()->itemAt(1)->getAttribute('id')==='books'); - } - - public function testUpdateDomTree() - { - } - - public function testComposeDomTree() - { - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/xml/data1.xml b/tests/UnitTests/framework/Data/xml/data1.xml deleted file mode 100644 index d865680a..00000000 --- a/tests/UnitTests/framework/Data/xml/data1.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - My lists - - My books - - - - - - Title - Author - Language - ISBN - - - - - The Grapes of Wrath - John Steinbeck - en - 0140186409 - - - The Pearl - John Steinbeck - en - 014017737X - - - Samarcande - Amine Maalouf - fr - 2253051209 - - - - - - - - diff --git a/tests/UnitTests/framework/Data/xml/data1.xml.out b/tests/UnitTests/framework/Data/xml/data1.xml.out deleted file mode 100644 index de491e4c..00000000 --- a/tests/UnitTests/framework/Data/xml/data1.xml.out +++ /dev/null @@ -1,41 +0,0 @@ - - - My lists - - My books - - - - - - Title - Author - Language - ISBN - - - - - The Grapes of Wrath - John Steinbeck - en - 0140186409 - - - The Pearl - John Steinbeck - en - 014017737X - - - Samarcande - Amine Maalouf - fr - 2253051209 - - - - - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/xml/data2.xml b/tests/UnitTests/framework/Data/xml/data2.xml deleted file mode 100644 index 9231ef7b..00000000 --- a/tests/UnitTests/framework/Data/xml/data2.xml +++ /dev/null @@ -1,41 +0,0 @@ -锘 - - - 鎴戠殑涔 - - - - - - 鏍囬 - 浣滆 - 璇█ - ISBN - - - - - The Grapes of Wrath - John Steinbeck - en - 0140186409 - - - The Pearl - John Steinbeck - en - 014017737X - - - Samarcande - Amine Maalouf - fr - 2253051209 - - - - - - - - diff --git a/tests/UnitTests/framework/Data/xml/data2.xml.out b/tests/UnitTests/framework/Data/xml/data2.xml.out deleted file mode 100644 index d688884c..00000000 --- a/tests/UnitTests/framework/Data/xml/data2.xml.out +++ /dev/null @@ -1,40 +0,0 @@ - - - - 鎴戠殑涔 - - - - - - 鏍囬 - 浣滆 - 璇█ - ISBN - - - - - The Grapes of Wrath - John Steinbeck - en - 0140186409 - - - The Pearl - John Steinbeck - en - 014017737X - - - Samarcande - Amine Maalouf - fr - 2253051209 - - - - - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/Data/xml/data3.xml b/tests/UnitTests/framework/Data/xml/data3.xml deleted file mode 100644 index 5eaece3b..00000000 --- a/tests/UnitTests/framework/Data/xml/data3.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - qiang.xue@gmail.com - - - diff --git a/tests/UnitTests/framework/Data/xml/data3.xml.out b/tests/UnitTests/framework/Data/xml/data3.xml.out deleted file mode 100644 index d46e65b9..00000000 --- a/tests/UnitTests/framework/Data/xml/data3.xml.out +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - qiang.xue@gmail.com - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/TestOfDateTimeFormatInfo.php b/tests/UnitTests/framework/I18N/TestOfDateTimeFormatInfo.php deleted file mode 100644 index a2d78807..00000000 --- a/tests/UnitTests/framework/I18N/TestOfDateTimeFormatInfo.php +++ /dev/null @@ -1,223 +0,0 @@ -UnitTestCase(); - } - - function setUp() - { - $this->format = DateTimeFormatInfo::getInstance('en'); - } - - function testAbbreviatedDayNames() - { - $names = $this->format->AbbreviatedDayNames; - $this->assertTrue(is_array($names),'Must be an array!'); - $this->assertEqual(count($names),7,'Must have 7 day names'); - - //assuming invariant culture. - $days = array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); - $this->assertEqual($names, $days); - - //try to set the data - $data = array('Hel', 'wor'); - $this->format->AbbreviatedDayNames = $data; - $newNames = $this->format->AbbreviatedDayNames; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - } - - function testNarrowDayNames() - { - $names = $this->format->NarrowDayNames; - $this->assertTrue(is_array($names),'Must be an array!'); - $this->assertEqual(count($names),7,'Must have 7 day names'); - - //assuming invariant culture. - $days = array("S", "M", "T", "W", "T", "F", "S"); - $this->assertEqual($names, $days); - - //try to set the data - $data = array('H', 'w'); - $this->format->NarrowDayNames = $data; - $newNames = $this->format->NarrowDayNames; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - } - - function testDayNames() - { - $names = $this->format->DayNames; - $this->assertTrue(is_array($names),'Must be an array!'); - $this->assertEqual(count($names),7,'Must have 7 day names'); - - //assuming invariant culture. - $days = array( "Sunday","Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday"); - $this->assertEqual($names, $days); - - //try to set the data - $data = array('Hello', 'world'); - $this->format->DayNames = $data; - $newNames = $this->format->DayNames; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - } - - function testMonthNames() - { - $names = $this->format->MonthNames; - $this->assertTrue(is_array($names),'Must be an array!'); - $this->assertEqual(count($names),12,'Must have 12 month names'); - - //assuming invariant culture. - $days = array( "January", "February", "March", "April", - "May", "June", "July", "August", "September", - "October", "November", "December"); - $this->assertEqual($names, $days); - - //try to set the data - $data = array('Hello', 'world'); - $this->format->MonthNames = $data; - $newNames = $this->format->MonthNames; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - } - - function testNarrowMonthNames() - { - $names = $this->format->NarrowMonthNames; - $this->assertTrue(is_array($names),'Must be an array!'); - $this->assertEqual(count($names),12,'Must have 12 month names'); - - //assuming invariant culture. - $days = array( "J", "F", "M", "A", "M", "J", "J", - "A", "S", "O", "N", "D"); - $this->assertEqual($names, $days); - - //try to set the data - $data = array('Hello', 'world'); - $this->format->NarrowMonthNames = $data; - $newNames = $this->format->NarrowMonthNames; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - } - - function testAbbreviatedMonthNames() - { - $names = $this->format->AbbreviatedMonthNames; - $this->assertTrue(is_array($names),'Must be an array!'); - $this->assertEqual(count($names),12,'Must have 12 month names'); - - //assuming invariant culture. - $days = array( "Jan", "Feb", "Mar", "Apr", - "May", "Jun", "Jul", "Aug", "Sep", - "Oct", "Nov", "Dec"); - $this->assertEqual($names, $days); - - //try to set the data - $data = array('Hello', 'world'); - $this->format->AbbreviatedMonthNames = $data; - $newNames = $this->format->AbbreviatedMonthNames; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - } - - function testEra() - { - //era for invariant culture is assumed to have - // 1 for AD and 0 for BC - $this->assertEqual('AD', $this->format->getEra(1)); - $this->assertEqual('BC', $this->format->getEra(0)); - } - - function testAMPMMarkers() - { - $am_pm = array('AM','PM'); - $data = $this->format->AMPMMarkers; - $this->assertTrue(is_array($data)); - $this->assertEqual($am_pm, $data); - $this->assertEqual('AM', $this->format->AMDesignator); - $this->assertEqual('PM', $this->format->PMDesignator); - - //try to set the data - $data = array('Hello', 'world'); - $this->format->AMPMMarkers = $data; - $newNames = $this->format->AMPMMarkers; - $this->assertTrue(is_array($newNames),'Must be an array!'); - $this->assertEqual(count($newNames),2,'Must have 2 entries'); - $this->assertEqual($newNames, $data); - - $this->format->AMDesignator = 'TTTT'; - $this->assertEqual('TTTT',$this->format->AMDesignator); - - $this->format->PMDesignator = 'SSS'; - $this->assertEqual('SSS',$this->format->PMDesignator); - } - - function testPatterns() - { - //patterns for invariant - $patterns = array( - 'FullTimePattern' => 'h:mm:ss a z', - 'LongTimePattern' => 'h:mm:ss a z', - 'MediumTimePattern' => 'h:mm:ss a', - 'ShortTimePattern' => 'h:mm a', - 'FullDatePattern' => 'EEEE, MMMM d, yyyy', - 'LongDatePattern' => 'MMMM d, yyyy', - 'MediumDatePattern' => 'MMM d, yyyy', - 'ShortDatePattern' => 'M/d/yy', - 'DateTimeOrderPattern' => '{1} {0}' - ); - - foreach($patterns as $property => $pattern) - { - $this->assertEqual($pattern, $this->format->$property); - } - - $hello = 'Hello'; - $world = 'world'; - $expectedResult = $hello.' '.$world; - $this->assertEqual($expectedResult, - $this->format->formatDateTime($hello, $world)); - } - - function testInvariantInfo() - { - $format = DateTimeFormatInfo::getInstance(); - - //the variant datetime format for medium date - //should be the follow - $pattern = 'MMM d, yyyy'; - - $this->assertEqual($pattern, $format->MediumDatePattern); - - $invariant = $format->getInvariantInfo(); - - $this->assertIdentical($format, $invariant); - } - - function testGetInstance() - { - $format = DateTimeFormatInfo::getInstance('zh_CN'); - - $pattern = 'yyyy-M-d'; - $this->assertEqual($pattern, $format->MediumDatePattern); - } -} - - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/messages/en/tests.mo b/tests/UnitTests/framework/I18N/messages/en/tests.mo deleted file mode 100644 index ee243202..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/en/tests.mo and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/en/tests.po b/tests/UnitTests/framework/I18N/messages/en/tests.po deleted file mode 100644 index 07860851..00000000 --- a/tests/UnitTests/framework/I18N/messages/en/tests.po +++ /dev/null @@ -1,18 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2005-01-09 14:11+1000\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\tests\n" - -msgid "Hello" -msgstr "hello" - -msgid "Goodbye" -msgstr "Sayonara" - diff --git a/tests/UnitTests/framework/I18N/messages/en/tests.xml b/tests/UnitTests/framework/I18N/messages/en/tests.xml deleted file mode 100644 index dbcd6831..00000000 --- a/tests/UnitTests/framework/I18N/messages/en/tests.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - Hello - hello - - - Goodbye - Sayonara - - - - diff --git a/tests/UnitTests/framework/I18N/messages/en_AU/tests.mo b/tests/UnitTests/framework/I18N/messages/en_AU/tests.mo deleted file mode 100644 index a9a26db2..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/en_AU/tests.mo and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/en_AU/tests.mo.bak b/tests/UnitTests/framework/I18N/messages/en_AU/tests.mo.bak deleted file mode 100644 index a9a26db2..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/en_AU/tests.mo.bak and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/en_AU/tests.po b/tests/UnitTests/framework/I18N/messages/en_AU/tests.po deleted file mode 100644 index 9f81f650..00000000 --- a/tests/UnitTests/framework/I18N/messages/en_AU/tests.po +++ /dev/null @@ -1,15 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2004-12-25 12:25+1000\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\tests\n" - -msgid "Hello" -msgstr "Howdy!" - diff --git a/tests/UnitTests/framework/I18N/messages/en_AU/tests.po.bak b/tests/UnitTests/framework/I18N/messages/en_AU/tests.po.bak deleted file mode 100644 index 9f81f650..00000000 --- a/tests/UnitTests/framework/I18N/messages/en_AU/tests.po.bak +++ /dev/null @@ -1,15 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2004-12-25 12:25+1000\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\tests\n" - -msgid "Hello" -msgstr "Howdy!" - diff --git a/tests/UnitTests/framework/I18N/messages/en_AU/tests.xml b/tests/UnitTests/framework/I18N/messages/en_AU/tests.xml deleted file mode 100644 index 7ed84220..00000000 --- a/tests/UnitTests/framework/I18N/messages/en_AU/tests.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - Hello - Howdy! - - - - diff --git a/tests/UnitTests/framework/I18N/messages/en_AU/tests.xml.bak b/tests/UnitTests/framework/I18N/messages/en_AU/tests.xml.bak deleted file mode 100644 index 7ed84220..00000000 --- a/tests/UnitTests/framework/I18N/messages/en_AU/tests.xml.bak +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - Hello - Howdy! - - - - diff --git a/tests/UnitTests/framework/I18N/messages/messages.db b/tests/UnitTests/framework/I18N/messages/messages.db deleted file mode 100644 index 73b518c5..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/messages.db and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/messages.db.bak b/tests/UnitTests/framework/I18N/messages/messages.db.bak deleted file mode 100644 index 73b518c5..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/messages.db.bak and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/messages.en.mo b/tests/UnitTests/framework/I18N/messages/messages.en.mo deleted file mode 100644 index db8838e3..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/messages.en.mo and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/messages.en.po b/tests/UnitTests/framework/I18N/messages/messages.en.po deleted file mode 100644 index 9299045c..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.en.po +++ /dev/null @@ -1,15 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2004-12-25 12:26+1000\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\tests\n" - -msgid "Hello" -msgstr "Hello :)" - diff --git a/tests/UnitTests/framework/I18N/messages/messages.en.xml b/tests/UnitTests/framework/I18N/messages/messages.en.xml deleted file mode 100644 index c3eb465b..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.en.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - Hello - Hello :) - - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/messages/messages.en_AU.mo b/tests/UnitTests/framework/I18N/messages/messages.en_AU.mo deleted file mode 100644 index f4822800..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/messages.en_AU.mo and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/messages.en_AU.mo.bak b/tests/UnitTests/framework/I18N/messages/messages.en_AU.mo.bak deleted file mode 100644 index f4822800..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/messages.en_AU.mo.bak and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/messages.en_AU.po b/tests/UnitTests/framework/I18N/messages/messages.en_AU.po deleted file mode 100644 index d795be2b..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.en_AU.po +++ /dev/null @@ -1,18 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2005-01-09 14:02:25\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\ ests\n" - -msgid "Hello" -msgstr "G'day Mate!" - -msgid "Welcome" -msgstr "Welcome Mate!" - diff --git a/tests/UnitTests/framework/I18N/messages/messages.en_AU.po.bak b/tests/UnitTests/framework/I18N/messages/messages.en_AU.po.bak deleted file mode 100644 index d795be2b..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.en_AU.po.bak +++ /dev/null @@ -1,18 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2005-01-09 14:02:25\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\ ests\n" - -msgid "Hello" -msgstr "G'day Mate!" - -msgid "Welcome" -msgstr "Welcome Mate!" - diff --git a/tests/UnitTests/framework/I18N/messages/messages.en_AU.xml b/tests/UnitTests/framework/I18N/messages/messages.en_AU.xml deleted file mode 100644 index cb4c4255..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.en_AU.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - Hello - G'day Mate! - - - Welcome - Welcome Mate! - - - - diff --git a/tests/UnitTests/framework/I18N/messages/messages.en_AU.xml.bak b/tests/UnitTests/framework/I18N/messages/messages.en_AU.xml.bak deleted file mode 100644 index cb4c4255..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.en_AU.xml.bak +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - Hello - G'day Mate! - - - Welcome - Welcome Mate! - - - - diff --git a/tests/UnitTests/framework/I18N/messages/messages.mo b/tests/UnitTests/framework/I18N/messages/messages.mo deleted file mode 100644 index 12cf1ff8..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/messages.mo and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/messages.po b/tests/UnitTests/framework/I18N/messages/messages.po deleted file mode 100644 index ade60e01..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.po +++ /dev/null @@ -1,18 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2004-12-25 12:25+1000\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\tests\n" - -msgid "Hello" -msgstr "Hello World" - -msgid "Welcome" -msgstr "Welcome!" - diff --git a/tests/UnitTests/framework/I18N/messages/messages.xml b/tests/UnitTests/framework/I18N/messages/messages.xml deleted file mode 100644 index 5fe588b6..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - Hello - Hello World - - - Welcome - Welcome! - - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/messages/messages_mysql.sql b/tests/UnitTests/framework/I18N/messages/messages_mysql.sql deleted file mode 100644 index 811010c4..00000000 --- a/tests/UnitTests/framework/I18N/messages/messages_mysql.sql +++ /dev/null @@ -1,69 +0,0 @@ -# phpMyAdmin SQL Dump -# version 2.5.5-rc2 -# http://www.phpmyadmin.net -# -# Host: localhost -# Generation Time: Jan 09, 2005 at 09:24 PM -# Server version: 4.0.17 -# PHP Version: 5.0.2 -# -# Database : `messages` -# - -# -------------------------------------------------------- - -# -# Table structure for table `catalogue` -# - -DROP TABLE IF EXISTS catalogue; -CREATE TABLE catalogue ( - cat_id int(11) NOT NULL auto_increment, - name varchar(100) NOT NULL default '', - source_lang varchar(100) NOT NULL default '', - target_lang varchar(100) NOT NULL default '', - date_created int(11) NOT NULL default '0', - date_modified int(11) NOT NULL default '0', - author varchar(255) NOT NULL default '', - PRIMARY KEY (cat_id) -) TYPE=MyISAM AUTO_INCREMENT=7 ; - - -INSERT INTO catalogue VALUES ('1', 'messages', '', '', '', '1103936017', ''); -INSERT INTO catalogue VALUES ('2', 'messages.en', '', '', '', '1103936017', ''); -INSERT INTO catalogue VALUES ('3', 'messages.en_AU', '', '', '', '1105250301', ''); -INSERT INTO catalogue VALUES ('4', 'tests', '', '', '', '1103936017', ''); -INSERT INTO catalogue VALUES ('5', 'tests.en', '', '', '', '1103936017', ''); -INSERT INTO catalogue VALUES ('6', 'tests.en_AU', '', '', '', '1103936017', ''); - -# -------------------------------------------------------- - -# -# Table structure for table `trans_unit` -# - -DROP TABLE IF EXISTS trans_unit; -CREATE TABLE trans_unit ( - msg_id int(11) NOT NULL auto_increment, - cat_id int(11) NOT NULL default '1', - id varchar(255) NOT NULL default '', - source text NOT NULL, - target text NOT NULL, - comments text NOT NULL, - date_added int(11) NOT NULL default '0', - date_modified int(11) NOT NULL default '0', - author varchar(255) NOT NULL default '', - translated tinyint(1) NOT NULL default '0', - PRIMARY KEY (msg_id) -) TYPE=MyISAM AUTO_INCREMENT=19 ; - -INSERT INTO trans_unit VALUES ('1', '1', '1', 'Hello', 'Hello World', '', '', '', '', '1'); -INSERT INTO trans_unit VALUES ('2', '2', '1', 'Hello', 'Hello :)', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('3', '1', '1', 'Welcome', 'Welcome!', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('4', '3', '1', 'Hello', 'G''day Mate!', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('5', '3', '2', 'Welcome', 'Welcome Mate!', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('13', '4', '1', 'Goodbye', 'Aloha!', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('14', '4', '2', 'Welcome', 'Ho Ho!', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('15', '5', '1', 'Hello', 'hello', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('16', '5', '2', 'Goodbye', 'Sayonara', '', '', '', '', '0'); -INSERT INTO trans_unit VALUES ('17', '6', '1', 'Hello', 'Howdy!', '', '', '', '', '0'); \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/messages/tests.en_AU.po b/tests/UnitTests/framework/I18N/messages/tests.en_AU.po deleted file mode 100644 index fda7021d..00000000 --- a/tests/UnitTests/framework/I18N/messages/tests.en_AU.po +++ /dev/null @@ -1,7 +0,0 @@ -msgid "" -msgstr "" -"PO-Revision-Date: 2005-01-09 14:17:13\n" - -msgid "Testing123" -msgstr "" - diff --git a/tests/UnitTests/framework/I18N/messages/tests.mo b/tests/UnitTests/framework/I18N/messages/tests.mo deleted file mode 100644 index 394b6196..00000000 Binary files a/tests/UnitTests/framework/I18N/messages/tests.mo and /dev/null differ diff --git a/tests/UnitTests/framework/I18N/messages/tests.po b/tests/UnitTests/framework/I18N/messages/tests.po deleted file mode 100644 index 4f5f3fbc..00000000 --- a/tests/UnitTests/framework/I18N/messages/tests.po +++ /dev/null @@ -1,18 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: I18N Tests\n" -"POT-Creation-Date: \n" -"PO-Revision-Date: 2005-01-09 14:07+1000\n" -"Last-Translator: \n" -"Language-Team: Wei Zhuo\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=utf-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Poedit-Basepath: F:\\www\\prado\\framework\\I18N\\tests\n" - -msgid "Goodbye" -msgstr "Aloha!" - -msgid "Welcome" -msgstr "Ho Ho!" - diff --git a/tests/UnitTests/framework/I18N/messages/tests.xml b/tests/UnitTests/framework/I18N/messages/tests.xml deleted file mode 100644 index 73f404b1..00000000 --- a/tests/UnitTests/framework/I18N/messages/tests.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - Goodbye - Aloha! - - - Welcome - Ho Ho! - - - - diff --git a/tests/UnitTests/framework/I18N/testChoiceFormat.php b/tests/UnitTests/framework/I18N/testChoiceFormat.php deleted file mode 100644 index 8cc3f1d3..00000000 --- a/tests/UnitTests/framework/I18N/testChoiceFormat.php +++ /dev/null @@ -1,34 +0,0 @@ -UnitTestCase(); - } - - function testChoices() - { - $choice = new ChoiceFormat(); - $string = '[0] are no files |[1] is one file |(1,Inf] are {number} files'; - - $want = 'are no files'; - $this->assertEqual($want, $choice->format($string, 0)); - - $want = 'is one file'; - $this->assertEqual($want, $choice->format($string, 1)); - - $want = 'are {number} files'; - $this->assertEqual($want, $choice->format($string, 5)); - - $this->assertFalse($choice->format($string, -1)); - - $string = '{1,2} one two |{3,4} three four |[2,5] two to five inclusive'; - $this->assertEqual($choice->format($string,1),'one two'); - $this->assertEqual($choice->format($string,2.1),'two to five inclusive'); - $this->assertEqual($choice->format($string,3),'three four'); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testCultureInfo.php b/tests/UnitTests/framework/I18N/testCultureInfo.php deleted file mode 100644 index 7e204ede..00000000 --- a/tests/UnitTests/framework/I18N/testCultureInfo.php +++ /dev/null @@ -1,94 +0,0 @@ -UnitTestCase(); - } - - function setUp() - { - $this->culture = CultureInfo::getInvariantCulture(); - } - - function testCultureName() - { - $name = 'en'; - - $this->assertEqual($name, $this->culture->Name); - - //the default/invariant culture should be neutral - $this->assertTrue($this->culture->IsNeutralCulture); - } - - function testCultureList() - { - $allCultures = CultureInfo::getCultures(); - $neutralCultures = CultureInfo::getCultures(CultureInfo::NEUTRAL); - $specificCultures = CultureInfo::getCultures(CultureInfo::SPECIFIC); - - //there should be 246 cultures all together. - $this->assertEqual(count($allCultures),246); - $this->assertEqual(count($neutralCultures),76); - $this->assertEqual(count($specificCultures),170); - - } - - function testParentCultures() - { - $zh_CN = new CultureInfo('zh_CN'); - $parent = $zh_CN->Parent; - $grandparent = $parent->Parent; - - $this->assertEqual($zh_CN->Name, 'zh_CN'); - $this->assertEqual($parent->Name, 'zh'); - $this->assertEqual($grandparent->Name, 'en'); - $this->assertEqual($grandparent->Parent->Name, 'en'); - } - - function testCountryNames() - { - $culture = new CultureInfo('fr_FR'); - $this->assertEqual($culture->Countries['AE'], '脡mirats arabes unis'); - } - - function testCurrencies() - { - $culture = new CultureInfo('en_AU'); - $au = array('$', 'Australian Dollar'); - $this->assertEqual($au, $culture->Currencies['AUD']); - } - - function testLanguages() - { - $culture = new CultureInfo('fr_BE'); - $this->assertEqual($culture->Languages['fr'], 'fran莽ais'); - } - - function testScripts() - { - $culture = new CultureInfo('fr'); - $this->assertEqual($culture->Scripts['Armn'], 'arm茅nien'); - } - - function testTimeZones() - { - $culture = new CultureInfo('fi'); - $zone = array( - "America/Los_Angeles", - "Tyynenmeren normaaliaika", - "PST", - "Tyynenmeren kes盲aika", - "PDT", - "Los Angeles"); - $this->assertEqual($culture->TimeZones[1],$zone); - } - -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testDateFormat.php b/tests/UnitTests/framework/I18N/testDateFormat.php deleted file mode 100644 index 7e4259d6..00000000 --- a/tests/UnitTests/framework/I18N/testDateFormat.php +++ /dev/null @@ -1,99 +0,0 @@ -UnitTestCase(); - } - - function testStandardPatterns() - { - $dateFormatter = new DateFormat(); - - $time = @mktime(9, 9, 9, 9, 1, 2004); - $zone = @date('T', $time); - //var_dump(date('c',$time)); - //for ShortDatePattern "M/d/yy" - $this->assertEqual('9/1/04', $dateFormatter->format($time, 'd')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'d')))); - - //for LongDatePattern "MMMM d, yyyy" - $wants = 'September 1, 2004'; - $this->assertEqual($wants, $dateFormatter->format($time, 'D')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'D')))); - - //for Full date and time "MMMM d, yyyy h:mm a" - $wants = 'September 1, 2004 9:09 AM'; - $this->assertEqual($wants, $dateFormatter->format($time, 'f')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'f')))); - - //for FullDateTimePattern "MMMM d, yyyy h:mm:ss a z" - $wants = 'September 1, 2004 9:09:09 AM '.$zone; - $this->assertEqual($wants, $dateFormatter->format($time, 'F')); - - //for General "M/d/yy h:mm a" - $wants = '9/1/04 9:09 AM'; - $this->assertEqual($wants, $dateFormatter->format($time, 'g')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'g')))); - - //for General "M/d/yy h:mm:ss a z" - $wants = '9/1/04 9:09:09 AM '.$zone; - $this->assertEqual($wants, $dateFormatter->format($time, 'G')); - - //for MonthDayPattern "MMMM dd" (invariant) - $wants = 'September 01'; - $this->assertEqual($wants, $dateFormatter->format($time, 'm')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'m')))); - - //for RFC1123Pattern "EEE, dd MMM yyyy HH:mm:ss" (invariant) - $wants = 'Wed, 01 Sep 2004 09:09:09'; - $this->assertEqual($wants, $dateFormatter->format($time, 'r')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'r')))); - - //for SortableDateTimePattern "yyyy-MM-ddTHH:mm:ss" (invariant) - $wants = '2004-09-01T09:09:09'; - $this->assertEqual($wants, $dateFormatter->format($time, 's')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'s')))); - - //for ShortTimePattern "H:mm a" - $wants = '9:09 AM'; - $this->assertEqual($wants, $dateFormatter->format($time, 't')); - //(date('c',strtotime($dateFormatter->format($time,'t')))); - - //for LongTimePattern "H:mm:ss a z" - $wants = '9:09:09 AM '.$zone; - $this->assertEqual($wants, $dateFormatter->format($time, 'T')); - - //for UniversalSortableDateTimePattern "yyyy-MM-dd HH:mm:ss z" - //(invariant) - $wants = '2004-09-01 09:09:09 '.$zone; - $this->assertEqual($wants, $dateFormatter->format($time, 'u')); - - //for Full date and time "EEEE dd MMMM yyyy HH:mm:ss" (invariant) - $wants = 'Wednesday 01 September 2004 09:09:09'; - $this->assertEqual($wants, $dateFormatter->format($time, 'U')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'U')))); - - //for YearMonthPattern "yyyy MMMM" (invariant) - $wants = '2004 September'; - $this->assertEqual($wants, $dateFormatter->format($time, 'y')); - //var_dump(date('c',strtotime($dateFormatter->format($time,'y')))); - } - - function testCustomPatterns() - { - $dateFormatter = new DateFormat(); - - $time = @mktime(9, 9, 9, 9, 1, 2004); - - $pattern = "'Hello' EEEE, 'it should be' MMM yyyy HH:mm:ss!!!"; - $wants = 'Hello Wednesday, it should be Sep 2004 09:09:09!!!'; - $this->assertEqual($wants, $dateFormatter->format($time, $pattern)); - - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testMessageFormat.php b/tests/UnitTests/framework/I18N/testMessageFormat.php deleted file mode 100644 index 74b6f23f..00000000 --- a/tests/UnitTests/framework/I18N/testMessageFormat.php +++ /dev/null @@ -1,13 +0,0 @@ -UnitTestCase(); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testMessageFormat_SQLite.php b/tests/UnitTests/framework/I18N/testMessageFormat_SQLite.php deleted file mode 100644 index 5b75a0a7..00000000 --- a/tests/UnitTests/framework/I18N/testMessageFormat_SQLite.php +++ /dev/null @@ -1,142 +0,0 @@ -UnitTestCase(); - $this->dir = dirname(__FILE__); - $this->tmp = $this->dir.'/tmp/'; - $this->source = "sqlite:///{$this->dir}/messages/messages.db"; - - } - - function test1() - { - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - $this->assertEqual($formatter->format('Hello'),'G\'day Mate!'); - - $this->assertEqual($formatter->format('Goodbye'), 'Goodbye'); - - $formatter->setUntranslatedPS(array('[T]','[/T]')); - $this->assertEqual($formatter->format('Hi'), '[T]Hi[/T]'); - - $source->getCache()->clear(); - - //save the untranslated - - } - - function getAllContents($file) - { - $db = sqlite_open($file); - $rs = sqlite_query('SELECT * FROM trans_unit',$db); - $result = ''; - while($row = sqlite_fetch_array($rs,SQLITE_NUM)) - { - $result .= implode(', ',$row)."\n"; - } - sqlite_close($db); - return $result; - } - - function testSaveUpdateDelete() - { - $backup = $this->dir.'/messages/messages.db.bak'; - $dbfile = $this->dir.'/messages/messages.db'; - - //restore using the back file - copy($backup,$dbfile); - - //test that the back file doesn't contain the 'Testing123' string. - $contents = $this->getAllContents($dbfile); - $this->assertNoUnwantedPattern('/Testing123/',$contents); - - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - - $formatter->setUntranslatedPS(array('[t]','[/t]')); - - //add a untranslated string - $this->assertEqual($formatter->format('Testing123'), '[t]Testing123[/t]'); - - //save it - $this->assertTrue($formatter->getSource()->save()); - - //check the contents - $contents = $this->getAllContents($dbfile); - $this->assertWantedPattern('/Testing123/',$contents); - - //testing for update. - $this->assertTrue($formatter->getSource()->update( - 'Testing123', '123Test', 'update comments')); - - $contents = $this->getAllContents($dbfile); - $this->assertWantedPattern('/123Test/',$contents); - $this->assertWantedPattern('/update comments/',$contents); - - //var_dump(htmlspecialchars($contents)); - - //now doing some delete - //doesn't detect missing source - $this->assertTrue($formatter->getSource()->delete('Test123')); - $this->assertTrue($formatter->getSource()->delete('Testing123')); - - $contents = $this->getAllContents($dbfile); - $this->assertNoUnwantedPattern('/Testing123/',$contents); - - //restore using the backup file. - copy($backup,$dbfile); - $source->getCache()->clear(); - } - - function testCatalogueList() - { - $source = MessageSource::factory($this->type, $this->source); - $result[] = array('messages',NULL); - $result[] = array('messages', 'en'); - $result[] = array('messages','en_AU'); - $result[] = array('tests',NULL); - $result[] = array('tests','en'); - $result[] = array('tests','en_AU'); - - $this->assertEqual($result, $source->catalogues()); - } - - function testAltCatalogue() - { - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - $formatter->Catalogue = 'tests'; - - //from a different catalogue - $this->assertEqual($formatter->format('Hello'), 'Howdy!'); - $this->assertEqual($formatter->format('Welcome'), 'Ho Ho!'); - $this->assertEqual($formatter->format('Goodbye'), 'Sayonara'); - - //switch to 'messages' catalogue - $this->assertEqual($formatter->format('Hello',null,'messages'),'G\'day Mate!'); - - $source->getCache()->clear(); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testMessageFormat_XLIFF.php b/tests/UnitTests/framework/I18N/testMessageFormat_XLIFF.php deleted file mode 100644 index 4072c4ce..00000000 --- a/tests/UnitTests/framework/I18N/testMessageFormat_XLIFF.php +++ /dev/null @@ -1,174 +0,0 @@ -UnitTestCase(); - $this->dir = dirname(__FILE__); - $this->tmp = $this->dir.'/tmp/'; - $this->source = $this->dir.'/messages'; - - } - - function test1() - { - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - $this->assertEqual($formatter->format('Hello'),'G\'day Mate!'); - - $this->assertEqual($formatter->format('Goodbye'), 'Goodbye'); - - $formatter->setUntranslatedPS(array('[T]','[/T]')); - $this->assertEqual($formatter->format('Hi'), '[T]Hi[/T]'); - - //clear cache - $source->getCache()->clear(); - - } - - function testSaveUpdateDelete() - { - $backup = $this->dir.'/messages/messages.en_AU.xml.bak'; - $xmlfile = $this->dir.'/messages/messages.en_AU.xml'; - - //restore using the back file - copy($backup,$xmlfile); - - //test that the back file doesn't contain the 'Testing123' string. - $contents = file_get_contents($xmlfile); - $this->assertNoUnwantedPattern('/Testing123/',$contents); - - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - - //add a untranslated string - $this->assertEqual($formatter->format('Testing123'), 'Testing123'); - - //save it - $this->assertTrue($formatter->getSource()->save()); - - //check the contents - $contents = file_get_contents($xmlfile); - $this->assertWantedPattern('/Testing123/',$contents); - - //testing for update. - $this->assertTrue($formatter->getSource()->update( - 'Testing123', '123Test', 'update comments')); - - $contents = file_get_contents($xmlfile); - $this->assertWantedPattern('/123Test/',$contents); - $this->assertWantedPattern('/update comments/',$contents); - - //var_dump(htmlspecialchars($contents)); - - //now doing some delete - $this->assertFalse($formatter->getSource()->delete('Test123')); - $this->assertTrue($formatter->getSource()->delete('Testing123')); - - $contents = file_get_contents($xmlfile); - $this->assertNoUnwantedPattern('/Testing123/',$contents); - - //restore using the backup file. - copy($backup,$xmlfile); - - $source->getCache()->clear(); - } - - function testCatalogueList() - { - $source = MessageSource::factory($this->type, $this->source); - $result[] = array('messages',NULL); - $result[] = array('messages', 'en'); - $result[] = array('messages','en_AU'); - $result[] = array('tests',NULL); - $result[] = array('tests','en'); - $result[] = array('tests','en_AU'); - - $this->assertEqual($result, $source->catalogues()); - } - - function testAltCatalogue() - { - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - $formatter->Catalogue = 'tests'; - - //from a different catalogue - $this->assertEqual($formatter->format('Hello'), 'Howdy!'); - $this->assertEqual($formatter->format('Welcome'), 'Ho Ho!'); - $this->assertEqual($formatter->format('Goodbye'), 'Sayonara'); - - //switch to 'messages' catalogue - $this->assertEqual($formatter->format('Hello',null,'messages'),'G\'day Mate!'); - - $source->getCache()->clear(); - } - - function testDirectoryTypeSaveUpdateDelete() - { - $backup = $this->dir.'/messages/en_AU/tests.xml.bak'; - $xmlfile = $this->dir.'/messages/en_AU/tests.xml'; - - //restore using the back file - copy($backup,$xmlfile); - - //test that the back file doesn't contain the 'Testing123' string. - $contents = file_get_contents($xmlfile); - $this->assertNoUnwantedPattern('/Testing123/',$contents); - - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - - //add a untranslated string, note, doesn't matter which catalogue - $this->assertEqual($formatter->format('Testing123'), 'Testing123'); - - //save it to the 'tests' catalgoue - $this->assertTrue($formatter->getSource()->save('tests')); - - //check the contents - $contents = file_get_contents($xmlfile); - $this->assertWantedPattern('/Testing123/',$contents); - - //testing for update. Update it to the 'tests' catalogue - $this->assertTrue($formatter->getSource()->update( - 'Testing123', '123Test', 'update comments','tests')); - - $contents = file_get_contents($xmlfile); - $this->assertWantedPattern('/123Test/',$contents); - $this->assertWantedPattern('/update comments/',$contents); - - //now doing some delete from the 'tests' catalogue - $this->assertFalse($formatter->getSource()->delete('Test123','tests')); - $this->assertTrue($formatter->getSource()->delete('Testing123','tests')); - - $contents = file_get_contents($xmlfile); - $this->assertNoUnwantedPattern('/Testing123/',$contents); - - //restore using the backup file. - copy($backup,$xmlfile); - - $source->getCache()->clear(); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testMessageFormat_gettext.php b/tests/UnitTests/framework/I18N/testMessageFormat_gettext.php deleted file mode 100644 index 6fa00e80..00000000 --- a/tests/UnitTests/framework/I18N/testMessageFormat_gettext.php +++ /dev/null @@ -1,176 +0,0 @@ -UnitTestCase(); - $this->dir = dirname(__FILE__); - $this->tmp = $this->dir.'/tmp/'; - $this->source = $this->dir.'/messages'; - } - - function test1() - { - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - $this->assertEqual($formatter->format('Hello'),'G\'day Mate!'); - - $this->assertEqual($formatter->format('Goodbye'), 'Goodbye'); - - $formatter->setUntranslatedPS(array('[T]','[/T]')); - $this->assertEqual($formatter->format('Hi'), '[T]Hi[/T]'); - - $source->getCache()->clear(); - } - - function testSaveUpdateDelete() - { - $MObackup = $this->dir.'/messages/messages.en_AU.mo.bak'; - $MOfile = $this->dir.'/messages/messages.en_AU.mo'; - $PObackup = $this->dir.'/messages/messages.en_AU.po.bak'; - $POfile = $this->dir.'/messages/messages.en_AU.po'; - - //restore using the back file - copy($MObackup,$MOfile); - copy($PObackup,$POfile); - - //test that the back file doesn't contain the 'Testing123' string. - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($MOfile)); - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($POfile)); - - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - - //add a untranslated string - $this->assertEqual($formatter->format('Testing123'), 'Testing123'); - - //save it - $this->assertTrue($formatter->getSource()->save()); - - //check the contents - //$this->assertWantedPattern('/Testing123/',file_get_contents($MOfile)); - $this->assertWantedPattern('/Testing123/',file_get_contents($POfile)); - - //testing for update. - $this->assertTrue($formatter->getSource()->update( - 'Testing123', '123Test', 'update comments')); - - $this->assertWantedPattern('/123Test/',file_get_contents($MOfile)); - - - //var_dump(htmlspecialchars($contents)); - - //now doing some delete - $this->assertFalse($formatter->getSource()->delete('Test123')); - $this->assertTrue($formatter->getSource()->delete('Testing123')); - - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($MOfile)); - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($POfile)); - - //restore using the backup file. - copy($MObackup,$MOfile); - copy($PObackup,$POfile); - - $source->getCache()->clear(); - } - - function testCatalogueList() - { - $source = MessageSource::factory($this->type, $this->source); - $result[] = array('messages',NULL); - $result[] = array('messages', 'en'); - $result[] = array('messages','en_AU'); - $result[] = array('tests',NULL); - $result[] = array('tests','en'); - $result[] = array('tests','en_AU'); - - $this->assertEqual($result, $source->catalogues()); - } - - function testAltCatalogue() - { - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - $formatter->Catalogue = 'tests'; - - //from a different catalogue - $this->assertEqual($formatter->format('Hello'), 'Howdy!'); - $this->assertEqual($formatter->format('Welcome'), 'Ho Ho!'); - $this->assertEqual($formatter->format('Goodbye'), 'Sayonara'); - - //switch to 'messages' catalogue - $this->assertEqual($formatter->format('Hello',null,'messages'),'G\'day Mate!'); - - $source->getCache()->clear(); - } - - function testDirectoryTypeSaveUpdateDelete() - { - $MObackup = $this->dir.'/messages/en_AU/tests.mo.bak'; - $MOfile = $this->dir.'/messages/en_AU/tests.mo'; - $PObackup = $this->dir.'/messages/en_AU/tests.po.bak'; - $POfile = $this->dir.'/messages/en_AU/tests.po'; - - //restore using the back file - copy($MObackup,$MOfile); - copy($PObackup,$POfile); - - //test that the back file doesn't contain the 'Testing123' string. - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($MOfile)); - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($POfile)); - - $source = MessageSource::factory($this->type, $this->source); - $source->setCulture('en_AU'); - $source->setCache(new MessageCache($this->tmp)); - - $formatter = new MessageFormat($source); - - //add a untranslated string, note, doesn't matter which catalogue - $this->assertEqual($formatter->format('Testing123'), 'Testing123'); - - //save it to the 'tests' catalgoue - $this->assertTrue($formatter->getSource()->save('tests')); - - //check the contents - //$this->assertWantedPattern('/Testing123/',file_get_contents($MOfile)); - $this->assertWantedPattern('/Testing123/',file_get_contents($POfile)); - - //testing for update. Update it to the 'tests' catalogue - $this->assertTrue($formatter->getSource()->update( - 'Testing123', '123Test', 'update comments','tests')); - - $this->assertWantedPattern('/123Test/',file_get_contents($MOfile)); - - //now doing some delete from the 'tests' catalogue - $this->assertFalse($formatter->getSource()->delete('Test123','tests')); - $this->assertTrue($formatter->getSource()->delete('Testing123','tests')); - - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($MOfile)); - $this->assertNoUnwantedPattern('/Testing123/',file_get_contents($POfile)); - - //restore using the backup file. - copy($MObackup,$MOfile); - copy($PObackup,$POfile); - - $source->getCache()->clear(); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testNumberFormat.php b/tests/UnitTests/framework/I18N/testNumberFormat.php deleted file mode 100644 index 48342d9c..00000000 --- a/tests/UnitTests/framework/I18N/testNumberFormat.php +++ /dev/null @@ -1,113 +0,0 @@ -UnitTestCase(); - } - - function testDefaultFormats() - { - $formatter = new NumberFormat(); - $number = '123456789.125156'; - $wanted = '123,456,789.125156'; - $this->assertEqual($wanted, $formatter->format($number)); - - //currency - $wanted = 'US$123,456,789.13'; - $this->assertEqual($wanted, $formatter->format($number,'c')); - } - - function testLocalizedCurrencyFormats() - { - $fr = new NumberFormat('fr'); - $de = new NumberFormat('de'); - $ja = new NumberFormat('ja_JP'); - - $number = '123456789.125156'; - - //french - $wanted = '123聽456聽789,13 F'; - $this->assertEqual($wanted, $fr->format($number,'c','FRF')); - - //german - $wanted = 'DES 123.456.789,13'; - $this->assertEqual($wanted, $de->format($number,'c','DES')); - - //japanese - $wanted = '锟123,456,789'; - $this->assertEqual($wanted, $ja->format($number,'c','JPY')); - - //custom/unkown currency - $wanted = 'DLL123,456,789'; - $this->assertEqual($wanted, $ja->format($number,'c','DLL')); - } - - function testCustomFormat() - { - $formatter = new NumberFormat(); - $number = '123456789.125156'; - - //primay and secondary grouping test - $pattern = '#,###,##.###'; - $wanted = '1,234,567,89.125156'; - $this->assertEqual($wanted, $formatter->format($number, $pattern)); - - //4 digits grouping test - $pattern = '#,####.###'; - $wanted = '1,2345,6789.125156'; - $this->assertEqual($wanted, $formatter->format($number, $pattern)); - - //custom percentage - $pattern = '#,###.00%'; - $wanted = '123,456,789.13%'; - $this->assertEqual($wanted, $formatter->format($number, $pattern)); - } - - function testPercentageFormat() - { - $formatter = new NumberFormat(); - $number = '0.125156'; - $wanted = '12%'; - $this->assertEqual($wanted, $formatter->format($number, 'p')); - } - - function testQuotes() - { - $formatter = new NumberFormat(); - $number = '123456789.125156'; - - $pattern = "# o'clock"; - $wanted = "123456789 o'clock"; - $this->assertEqual($wanted, $formatter->format($number, $pattern)); - - } - - function testPadding() - { - $formatter = new NumberFormat(); - $number = '5'; - - $pattern = '0000'; - $wanted = '0005'; - - //this should fail!!! - $this->assertEqual($wanted, $formatter->format($number, $pattern)); - } - - function testNegativeValue() - { - $formatter = new NumberFormat(); - $number = "-1.2"; - - $wanted = "-1.2"; - $this->assertEqual($wanted, $formatter->format($number)); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/testNumberFormatInfo.php b/tests/UnitTests/framework/I18N/testNumberFormatInfo.php deleted file mode 100644 index 0b0a3140..00000000 --- a/tests/UnitTests/framework/I18N/testNumberFormatInfo.php +++ /dev/null @@ -1,105 +0,0 @@ -UnitTestCase(); - } - - function testCurrencyPatterns() - { - $numberInfo = NumberFormatInfo::getCurrencyInstance(); - - //there should be 2 decimal places. - $this->assertEqual($numberInfo->DecimalDigits,2); - - $this->assertEqual($numberInfo->DecimalSeparator,'.'); - - $this->assertEqual($numberInfo->GroupSeparator,','); - - //there should be only 1 grouping of size 3 - $groupsize = array(3,false); - $this->assertEqual($numberInfo->GroupSizes, $groupsize); - - //the default negative pattern prefix and postfix - $negPattern = array('-陇',''); - $this->assertEqual($numberInfo->NegativePattern, $negPattern); - - //the default positive pattern prefix and postfix - $negPattern = array('陇',''); - $this->assertEqual($numberInfo->PositivePattern, $negPattern); - - //the default currency symbol - $this->assertEqual($numberInfo->CurrencySymbol, 'US$'); - - $this->assertEqual($numberInfo->getCurrencySymbol('JPY'), '楼'); - - $this->assertEqual($numberInfo->NegativeInfinitySymbol, '-鈭'); - - $this->assertEqual($numberInfo->PositiveInfinitySymbol, '+鈭'); - - $this->assertEqual($numberInfo->NegativeSign, '-'); - - $this->assertEqual($numberInfo->PositiveSign, '+'); - - $this->assertEqual($numberInfo->NaNSymbol, '锟'); - - $this->assertEqual($numberInfo->PercentSymbol, '%'); - - $this->assertEqual($numberInfo->PerMilleSymbol, '鈥'); - - } - - function testPatternsSet() - { - $numberInfo = NumberFormatInfo::getInstance(); - - $numberInfo->DecimalDigits = 0; - $this->assertEqual($numberInfo->DecimalDigits,0); - - $numberInfo->DecimalSeparator = ','; - $this->assertEqual($numberInfo->DecimalSeparator,','); - - $numberInfo->GroupSeparator = ' '; - $this->assertEqual($numberInfo->GroupSeparator,' '); - - $numberInfo->GroupSizes = array(2,3); - $groupsize = array(2,3); - $this->assertEqual($numberInfo->GroupSizes, $groupsize); - - $numberInfo->NegativePattern = array('-$$','.'); - $negPattern = array('-$$','.'); - $this->assertEqual($numberInfo->NegativePattern, $negPattern); - - $numberInfo->PositivePattern = array('YY','.'); - $negPattern = array('YY','.'); - $this->assertEqual($numberInfo->PositivePattern, $negPattern); - - //the default CurrencySymbol symbol - $numberInfo->CurrencySymbol = '$$$'; - $this->assertEqual($numberInfo->CurrencySymbol, '$$$'); - } - - function testLocalizedPatterns() - { - $fr = NumberFormatInfo::getInstance('fr'); - $de = NumberFormatInfo::getInstance('de'); - $en = NumberFormatInfo::getInstance('en_US'); - - $this->assertEqual($fr->DecimalSeparator, ','); - $this->assertEqual($de->DecimalSeparator, ','); - $this->assertEqual($en->DecimalSeparator, '.'); - - $this->assertEqual($fr->GroupSeparator, '聽'); - $this->assertEqual($de->GroupSeparator, '.'); - $this->assertEqual($en->GroupSeparator, ','); - } - -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/I18N/tmp/cache.txt b/tests/UnitTests/framework/I18N/tmp/cache.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/tests/UnitTests/framework/TestSystem/protected/application.xml b/tests/UnitTests/framework/TestSystem/protected/application.xml deleted file mode 100644 index 38bfff9e..00000000 --- a/tests/UnitTests/framework/TestSystem/protected/application.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - value 1 - - - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/TestSystem/protected/data/test.db b/tests/UnitTests/framework/TestSystem/protected/data/test.db deleted file mode 100644 index 9bc20c39..00000000 Binary files a/tests/UnitTests/framework/TestSystem/protected/data/test.db and /dev/null differ diff --git a/tests/UnitTests/framework/TestSystem/protected/pages/config.xml b/tests/UnitTests/framework/TestSystem/protected/pages/config.xml deleted file mode 100644 index 6a49df82..00000000 --- a/tests/UnitTests/framework/TestSystem/protected/pages/config.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - value 1 - - - - - \ No newline at end of file diff --git a/tests/UnitTests/framework/Web/UI/utControl.php b/tests/UnitTests/framework/Web/UI/utControl.php deleted file mode 100644 index ed2ddd22..00000000 --- a/tests/UnitTests/framework/Web/UI/utControl.php +++ /dev/null @@ -1,416 +0,0 @@ -setPage($this); - $this->_context=$context; - } - - public function getContext() - { - return $this->_context; - } - - public function clicked($sender,$param) - { - $this->eventRaised=true; - } - - public function getContainsTheme() - { - return false; - } - - public function runTo($lifecycle) - { - switch($lifecycle) - { - case 'init': - $this->initRecursive(null); - break; - case 'load': - $this->initRecursive(null); - $this->loadRecursive(); - break; - case 'prerender': - $this->initRecursive(null); - $this->loadRecursive(); - $this->preRenderRecursive(); - break; - } - } -} - -class WebControl extends TControl -{ - public function getText() - { - return $this->getViewState('Text',''); - } - - public function setText($value) - { - return $this->setViewState('Text',$value,''); - } - - public function getData() - { - return $this->getControlState('Data',''); - } - - public function setData($value) - { - $this->setControlState('Data',$value,''); - } - - public function onClick($param) - { - $this->raiseEvent('OnClick',$this,$param); - } -} - -class utControl extends UnitTestCase -{ - private $context; - private $button1; - private $button2; - private $page; - private $form; - private $panel; - - public function setUp() - { - // we mock up a page consisting of a form which encloses a panel. - // in the panel there are two buttons, button1 and button2 - // The panel is a naming container - $this->context=new TContext; - $this->page=new PageControl($this->context); - $this->form=new WebControl; - $this->panel=new ContainerControl; - $this->button1=new WebControl; - $this->button2=new WebControl; - $this->form->setTemplateControl($this->page); - $this->panel->setTemplateControl($this->page); - $this->button1->setTemplateControl($this->page); - $this->button2->setTemplateControl($this->page); - $this->page->getControls()->add($this->form); - $this->form->getControls()->add($this->panel); - $this->panel->getControls()->add($this->button1); - $this->panel->getControls()->add($this->button2); - $this->button1->setID('button1'); - $this->page->declareObject('button1',$this->button1); - } - - public function tearDown() - { - $this->page=null; - $this->form=null; - $this->panel=null; - $this->button1=null; - $this->button2=null; - $this->context=null; - TContext::$_instance=null; - } - - public function testOverload() - { - $this->assertEqual($this->page->button1,$this->button1); - try - { - $button=$this->page->button2; - $this->fail('non exception raised when accessing non-declared control'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testParent() - { - $this->assertEqual(null,$this->page->getParent()); - $this->assertEqual($this->page,$this->form->getParent()); - } - - public function testNamingContainer() - { - $this->assertEqual(null,$this->page->getNamingContainer()); - $this->assertEqual($this->page,$this->panel->getNamingContainer()); - $this->assertEqual($this->panel,$this->button1->getNamingContainer()); - } - - public function testPage() - { - $this->assertEqual($this->page,$this->page->getPage()); - $this->assertEqual($this->page,$this->panel->getPage()); - $this->assertEqual($this->page,$this->button1->getPage()); - } - - public function testTemplateControl() - { - $this->assertEqual(null,$this->page->getTemplateControl()); - $this->assertEqual($this->page,$this->panel->getTemplateControl()); - $this->assertEqual($this->page,$this->button1->getTemplateControl()); - } - - public function testContext() - { - $this->assertEqual($this->context,$this->button1->getContext()); - } - - public function testSkinID() - { - $this->assertEqual('',$this->button1->getSkinID()); - $this->button1->setSkinID('buttonSkin'); - $this->assertEqual('buttonSkin',$this->button1->getSkinID()); - $this->page->runTo('init'); - try - { - $this->button1->setSkinID('buttonSkin2'); - $this->fail('no exception raised when SkinID is set after PreInit'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testID() - { - $this->assertEqual('button1',$this->button1->getID()); - $this->assertEqual('',$this->button2->getID()); - $this->assertEqual('ctl1',$this->button2->getID(false)); - $this->button2->setID('button2'); - $this->assertEqual('button2',$this->button2->getID()); - try - { - $this->button2->setID('123'); - $this->fail('exception not raised when control is set with an invalid ID'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - } - - public function testUniqueID() - { - $sep=TControl::ID_SEPARATOR; - $this->assertEqual('ctl0',$this->form->getUniqueID()); - $this->assertEqual('ctl1',$this->panel->getUniqueID()); - $this->assertEqual('ctl1'.$sep.'button1',$this->button1->getUniqueID()); - $this->assertEqual('ctl1'.$sep.'ctl1',$this->button2->getUniqueID()); - $this->button2->setID('button2'); - $this->assertEqual('ctl1'.$sep.'button2',$this->button2->getUniqueID()); - $this->panel->setID('panel'); - $this->assertEqual('panel'.$sep.'button2',$this->button2->getUniqueID()); - } - - public function testEnableTheming() - { - $this->assertEqual(true,$this->button1->getEnableTheming()); - $this->page->setEnableTheming(false); - $this->assertEqual(false,$this->button1->getEnableTheming()); - $this->page->setEnableTheming(true); - $this->assertEqual(true,$this->button1->getEnableTheming()); - $this->button1->setEnableTheming(false); - $this->assertEqual(false,$this->button1->getEnableTheming()); - - $this->page->runTo('init'); - try - { - $this->button1->setEnableTheming(true); - $this->fail('no exception raised when EnableTheming is set after PreInit'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testHasControls() - { - $this->assertEqual(true,$this->page->getHasControls()); - $this->assertEqual(false,$this->button1->getHasControls()); - } - - public function testControls() - { - $this->assertEqual(1,$this->page->getControls()->getCount()); - $control=new WebControl; - $this->panel->getControls()->add($control); - $this->assertEqual(3,$this->panel->getControls()->getCount()); - $this->panel->getControls()->remove($this->button1); - $this->assertEqual(2,$this->panel->getControls()->getCount()); - } - - public function testVisible() - { - $this->assertEqual(true,$this->button1->getVisible()); - $this->page->setVisible(false); - $this->assertEqual(false,$this->button1->getVisible()); - $this->page->setVisible(true); - $this->assertEqual(true,$this->button1->getVisible()); - $this->button1->setVisible(false); - $this->assertEqual(false,$this->button1->getVisible()); - } - - public function testEnabled() - { - $this->assertEqual(true,$this->button1->getEnabled()); - $this->page->setEnabled(false); - $this->assertEqual(true,$this->button1->getEnabled()); - $this->assertEqual(false,$this->button1->getEnabled(true)); - $this->page->setEnabled(true); - $this->assertEqual(true,$this->button1->getEnabled(true)); - $this->button1->setEnabled(false); - $this->assertEqual(false,$this->button1->getEnabled(true)); - $this->assertEqual(false,$this->button1->getEnabled()); - } - - public function testHasAttributes() - { - $this->assertEqual(false,$this->button1->getHasAttributes()); - $this->button1->getAttributes()->add('name','value'); - $this->assertEqual(true,$this->button1->getHasAttributes()); - $this->button1->getAttributes()->clear(); - $this->assertEqual(false,$this->button1->getHasAttributes()); - } - - public function testAttributes() - { - $this->assertEqual(0,$this->button1->getAttributes()->getCount()); - $this->button1->getAttributes()->add('name1','value1'); - $this->button1->getAttributes()->add('name2','value2'); - $this->assertEqual(2,$this->button1->getAttributes()->getCount()); - $this->button1->getAttributes()->remove('name1'); - $this->assertEqual(1,$this->button1->getAttributes()->getCount()); - } - - public function testEnableViewState() - { - $this->assertEqual(true,$this->button1->getEnableViewState()); - $this->button1->setEnableViewState(false); - $this->assertEqual(false,$this->button1->getEnableViewState()); - - } - - public function testViewState() - { - $this->assertEqual('',$this->button1->getText()); - $this->button1->setText('abc'); - $this->assertEqual('abc',$this->button1->getText()); - } - - public function testControlState() - { - $this->assertEqual('',$this->button1->getData()); - $this->button1->setData('abc'); - $this->assertEqual('abc',$this->button1->getData()); - } - - public function testEventScheme() - { - $this->assertEqual(true,$this->button1->hasEvent('OnClick')); - $this->assertEqual(false,$this->button1->hasEvent('Click')); - $this->button1->attachEventHandler('OnClick','Page.clicked'); - $this->assertEqual(false,$this->page->eventRaised); - $this->button1->raiseEvent('OnClick',$this,null); - $this->assertEqual(true,$this->page->eventRaised); - $this->button1->getEventHandlers('OnClick')->clear(); - try - { - $this->button1->attachEventHandler('OnClick','clicked'); - $this->fail('no exception raised when undefined event is raised'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - $this->assertEqual(0,$this->button1->getEventHandlers('OnClick')->getCount()); - $this->button1->attachEventHandler('OnClick','Pages.clicked'); - try - { - $this->button1->raiseEvent('OnClick',$this,null); - $this->fail('no exception raised when undefined event handler is invoked'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testDataBindingScheme() - { - $this->button1->bindProperty('Text','"abc"."def"'); - $this->button1->dataBind(); - $this->assertEqual('abcdef',$this->button1->getText()); - $this->button2->bindProperty('Text','"abc"."def"'); - $this->button2->unbindProperty('Text'); - $this->button2->dataBind(); - $this->assertEqual('',$this->button2->getText()); - $this->button1->bindProperty('Texts','"abc"."def"'); - try - { - $this->button1->dataBind(); - $this->fail('no exception raised for invalid databinding'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testFindControl() - { - $this->assertEqual($this->button1,$this->panel->findControl('button1')); - $this->assertEqual(null,$this->panel->findControl('button2')); - $this->assertEqual($this->button1,$this->page->findControl($this->panel->getID(false).TControl::ID_SEPARATOR.'button1')); - $this->button1->setID('button3'); - $this->assertEqual($this->button1,$this->panel->findControl('button3')); - } - - public function testAddRemoveControl() - { - - } -} - - -if(!defined('RUN_ALL_TESTS')) -{ - $className=basename(__FILE__,'.php'); - $test = new $className; - $test->run(new HtmlReporter()); -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Web/UI/utJavascriptSerializer.php b/tests/UnitTests/framework/Web/UI/utJavascriptSerializer.php deleted file mode 100644 index 89a54820..00000000 --- a/tests/UnitTests/framework/Web/UI/utJavascriptSerializer.php +++ /dev/null @@ -1,181 +0,0 @@ -assertEqual($expect, $js->toJavascript()); - - $string = ""; - $expect = "''"; - $js = new TJavascriptSerializer($string); - $this->assertEqual($expect, $js->toJavascript()); - } - - function testInteger() - { - $int = 10; - $expect = "10"; - $js = new TJavascriptSerializer($int); - $this->assertEqual($expect, $js->toJavascript()); - } - - function testFloat() - { - $float = 10.2; - $expect = "10.2"; - $js = new TJavascriptSerializer($float); - $this->assertEqual($expect, $js->toJavascript()); - - $float = INF; - $expect = "Number.POSITIVE_INFINITY"; - $js = new TJavascriptSerializer($float); - $this->assertEqual($expect, $js->toJavascript()); - - $expect = "Number.NEGATIVE_INFINITY"; - $js = new TJavascriptSerializer(-$float); - $this->assertEqual($expect, $js->toJavascript()); - } - - function testBoolean() - { - $bool = false; - $expect = "false"; - $js = new TJavascriptSerializer($bool); - $this->assertEqual($expect, $js->toJavascript()); - - $expect = "true"; - $js = new TJavascriptSerializer(!$bool); - $this->assertEqual($expect, $js->toJavascript()); - } - - function testNull() - { - $null = null; - $expect = "null"; - $js = new TJavascriptSerializer($null); - $this->assertEqual($expect, $js->toJavascript()); - } - - function testArray() - { - $data[0] = 1; - $data[1] = "hello"; - $data[2] = 1.20; - $data[3] = true; - $data[4] = false; - $data[5] = null; - $data[6] = array("one"); - - $expect = "[1,'hello',1.2,true,false,null,['one']]"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toJavascript()); - - $data = array(); - $expect = "[]"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toJavascript(true)); - } - - function testMap() - { - $data['hello'] = 'world'; - $data['more'] = array('yes' => 'yah!'); - $expect = "{'hello':'world','more':{'yes':'yah!'}}"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toMap()); - } - - function testObject() - { - $data = new testSerializerObject; - $expect = "{'public':'public data'}"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toJavascript()); - } - - //should not serialize components! - function testComponent() - { - $data = new testComponentObject; - $expect = "{'public':'public data','Data':'component data'}"; - $js = new TJavascriptSerializer($data); - try - { - $js->toJavascript(); - $this->fail(); - } - catch(TException $e) - { - $this->pass(); - } - } - - function testComplexStrings() - { - $data[] = "\"It's slash \/ wonderful\""; - $expect = "['\\\"It\'s slash \\\\/ wonderful\\\"']"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toJavascript()); - } - - - function testArrayString() - { - $data[] = "['hello', 1]"; - $data[] = "{'asd':'asdasd'}"; - $data[] = "[hasdkj}"; - $expect = "[['hello', 1],{'asd':'asdasd'},'[hasdkj}']"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toJavascript()); - } - - function testArrayComplex() - { - $data = array("hello", 1, 2.12, array("world", null, "", array())); - $expect = "['hello',1,2.12,['world',null]]"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toJavascript()); - - $expect = "['hello',1,2.12,['world',null,'',[]]]"; - $this->assertEqual($expect, $js->toJavascript(true)); - } - - function testListComplex() - { - $data = array("hello"=>"world", 1, 2.12); - $data["more"] = array("the" => "world", null, "good"=>"", array()); - $expect = "{'hello':'world','0':1,'1':2.12,'more':{'the':'world','0':null}}"; - $js = new TJavascriptSerializer($data); - $this->assertEqual($expect, $js->toMap()); - - $expect = "{'hello':'world','0':1,'1':2.12,'more':{'the':'world','0':null,'good':'','1':{}}}"; - $this->assertEqual($expect, $js->toMap(true)); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/Web/utHttpRequest.php b/tests/UnitTests/framework/Web/utHttpRequest.php deleted file mode 100644 index 3da58a69..00000000 --- a/tests/UnitTests/framework/Web/utHttpRequest.php +++ /dev/null @@ -1,268 +0,0 @@ -request =& new THttpRequest(); - $this->module =& $this->request; // $this->module is used automatically by the underlying class - $this->initModule($this->defaultConfig); - } - - public function tearDown() { - $this->request = null; - parent::tearDown(); - } - - public function testInit($application,$config) { - // Configuration case 1... - $_SERVER = array( - "REQUEST_URI" => "/foo.php?bar", - "SCRIPT_NAME" => "/foo.php", - "QUEST_STRING" => "bar", - "PATH_INFO" => "/foo.php", - "PHP_SELF" => "/foo.php", - ); - $this->mockApplication->expectOnce("setRequest"); - $this->initModule(); - $this->mockApplication->tally(); - $this->assertIsA($this->request->getItems(), "TMap"); - - $this->assertEqual($this->request->getRequestUri(), "/foo.php?bar"); - $this->assertEqual($this->request->getPathInfo(), "/foo.php"); - - $_SERVER = array( - "REQUEST_URI" => "/aaa/bbb/ccc/foo.php?bar", - "SCRIPT_NAME" => "", - "QUEST_STRING" => "", - "PATH_INFO" => "/aaa/bbb/ccc/foo.php", - "PHP_SELF" => "/aaa/bbb/ccc/foo.php", - ); - $this->initModule(); - $this->assertEqual($this->request->getRequestUri(), "/aaa/bbb/ccc/foo.php?bar"); - $this->assertEqual($this->request->getPathInfo(), "/aaa/bbb/ccc/foo.php"); - - $_SERVER = array( - "SCRIPT_NAME" => "/foo.php", - "QUEST_STRING" => "bar", - "PATH_INFO" => "", - "PHP_SELF" => "/foo.php", - ); - $this->initModule(); - $this->assertEqual($this->request->getRequestUri(), "/foo.php?bar"); - $this->assertEqual($this->request->getPathInfo(), "/foo.php"); - - $_SERVER = array( - "REQUEST_URI" => "/foo.php?bar", - "PATH_INFO" => "/foo.php?bar", - ); - $this->initModule(); - $this->assertEqual($this->request->getRequestUri(), "/foo.php?bar"); - $this->assertEqual($this->request->getPathInfo(), "/foo.php"); - } - - /*public function testGetUrl() { - if($this->_url===null) - { - $secure=$this->getIsSecureConnection(); - $url=$secure?'https://':'http://'; - if(empty($_SERVER['HTTP_HOST'])) - { - $url.=$_SERVER['SERVER_NAME']; - $port=$_SERVER['SERVER_PORT']; - if(($port!=80 && !$secure) || ($port!=443 && $secure)) - $url.=':'.$port; - } - else - $url.=$_SERVER['HTTP_HOST']; - $url.=$this->getRequestUri(); - $this->_url=new TUri($url); - } - return $this->_url; - }*/ - - public function testGetRequestType() { - $_SERVER = array("REQUEST_METHOD" => "GET"); - $this->assertEqual($this->request->getRequestType(), "GET"); - } - - public function testGetIsSecureConnection() { - $_SERVER = array("HTTPS" => "true"); - $this->assertTrue($this->request->getIsSecureConnection()); - $_SERVER = array("HTTPS" => ""); - $this->assertFalse($this->request->getIsSecureConnection()); - $_SERVER = array(); - $this->assertFalse($this->request->getIsSecureConnection()); - } - - public function testGetQueryString() { - $_SERVER = array("QUERY_STRING" => "foo=bar"); - $this->assertEqual($this->request->getQueryString(), "foo=bar"); - $_SERVER = array("QUERY_STRING" => ""); - $this->assertEqual($this->request->getQueryString(), ""); - $_SERVER = array(); - $this->assertEqual($this->request->getQueryString(), ""); - } - - public function testGetApplicationPath() { - $_SERVER = array("SCRIPT_NAME" => "/foo/bar.php"); - $this->assertEqual($this->request->getApplicationPath(), "/foo/bar.php"); - } - - public function testGetPhysicalApplicationPath() { - $_SERVER = array("SCRIPT_FILENAME" => "/var/www/foo.php"); - $this->assertEqual($this->request->getPhysicalApplicationPath(), "/var/www/foo.php"); - $_SERVER = array("SCRIPT_FILENAME" => "C:\\web\\foo.php"); - $this->assertEqual($this->request->getPhysicalApplicationPath(), "/web/foo.php"); - } - - public function testGetServerName() { - $_SERVER = array("SERVER_NAME" => "foobar"); - $this->assertEqual($this->request->getApplicationPath(), "foobar"); - } - - public function testGetServerPort() { - $_SERVER = array("SERVER_PORT" => "80"); - $this->assertEqual($this->request->getApplicationPath(), 80); - } - - public function testGetUrlReferrer() { - $_SERVER = array("HTTP_REFERRER" => "http://www.google.com/"); - $this->assertEqual($this->request->getPhysicalApplicationPath(), "http://www.google.com/"); - $_SERVER = array(); - $this->assertNull($this->request->getPhysicalApplicationPath()); - } - - /*public function testGetBrowser() { - return get_browser(); - }*/ - - public function testGetUserAgent() { - $_SERVER = array("HTTP_USER_AGENT" => "foo"); - $this->assertEqual($this->request->getUserAgent(), "foo"); - } - - public function testGetUserHostAddress() { - $_SERVER = array("REMOTE_ADDR" => "121.212.121.212"); - $this->assertEqual($this->request->getUserHostAddress(), "121.212.121.212"); - } - - public function testGetUserHost() { - $_SERVER = array("REMOTE_ADDR" => "foo"); - $this->assertEqual($this->request->getUserHostAddress(), "foo"); - $_SERVER = array(); - $this->assertNull($this->request->getUserHostAddress()); - } - - public function testGetAcceptTypes() { - $_SERVER = array("REMOTE_ADDR" => "foo bar"); - $this->assertEqual($this->request->getAcceptTypes(), "foo bar"); - } - - public function testGetUserLanguages() { - $_SERVER = array("HTTP_ACCEPT_LANGUAGE" => "foo"); - $this->assertEqual($this->request->getUserLanguages(), "foo"); - } - - public function testGetCookies() { - $_COOKIES = array("foo" => "bar", "xxx" => "yyy"); - - // Repeat this twice. The first time tests the parsing logic for $_COOKIES. - // The second time tests the internal caching logic. - for ($i = 0; $i < 2; $i++) { - $cookies = $this->request->getCookies(); - $this->assertIsA($cookies, "THttpCookieCollection"); - $this->asserEqual($cookies->getCount(), 2); - $first = $cookies->itemAt(0); - $this->assertEqual($first->getName(), "foo"); - $this->assertEqual($first->getName(), "bar"); - $second = $cookies->itemAt(0); - $this->assertEqual($second->getName(), "xxx"); - $this->assertEqual($second->getName(), "yyy"); - } - } - - /*public function testGetUploadedFiles() { - if($this->_files===null) - $this->_files=new TMap($_FILES); - return $this->_files; - } - - public function testGetServerVariables() { - if($this->_server===null) - $this->_server=new TMap($_SERVER); - return $this->_server; - } - - public function testGetEnvironmentVariables() { - if($this->_env===null) - $this->_env=new TMap($_ENV); - return $this->_env; - }*/ - - public function testConstructUrl($serviceID,$serviceParam,$getItems=null) { - $_SERVER = array("SCRIPT_NAME" => "/foo/bar.php"); - $sv = THttpRequest::SERVICE_VAR; - - // Note: we can't undefine SID so we can't ensure that the case when SID is not present will be tested. - // Therefore, we define it here so we can be sure that it *is* defined. If it was already defined before - // entering this function then this define() will be ignored. This doesn't matter as immediately after defining - // SID we read it into $sid. - define("SID", "123"); - $sid = SID; - - $this->assertEqual($this->request->constructUrl("page", ""), "/foo/bar.php?$sv=page&$sid"); - $this->assertEqual($this->request->constructUrl("page", null), "/foo/bar.php?$sv=page&$sid"); - $this->assertEqual($this->request->constructUrl("page", "myPage"), "/foo/bar.php?$sv=page.myPage&$sid"); - $this->assertEqual($this->request->constructUrl("page", "myPage", array("aaa"=>"aaa")), "/foo/bar.php?$sv=page.myPage&aaa=aaa&$sid"); - $this->assertEqual($this->request->constructUrl("page", "myPage", array("aaa"=>"aaa","bbb"=>"bbb")), "/foo/bar.php?$sv=page.myPage&aaa=aaa&bbb=bbb&$sid"); - $this->assertEqual($this->request->constructUrl("page", "myPage", new TList(array("aaa"=>"aaa"))), "/foo/bar.php?$sv=page.myPage&aaa=aaa&$sid"); - } - - protected function testResolveRequest() { - $sv = THttpRequest::SERVICE_VAR; - - $_POST = array($sv => "page"); - $this->initModule(); - $this->request->resolveRequest(); - $this->assertEqual($this->request->getServiceID(), "page"); - $this->assertEqual($this->request->getServiceParameter(), ""); - - $_POST = array($sv => "page.xxx"); - $this->initModule(); - $this->request->resolveRequest(); - $this->assertEqual($this->request->getServiceID(), "page"); - $this->assertEqual($this->request->getServiceParameter(), "xxx"); - - $_GET = array($sv => "page.xxx"); - $this->initModule(); - $this->request->resolveRequest(); - $this->assertEqual($this->request->getServiceID(), "page"); - $this->assertEqual($this->request->getServiceParameter(), "xxx"); - - $_POST = array($sv => "page"); - $this->initModule(); - $this->request->resolveRequest(); - $this->assertEqual($this->request->getServiceID(), "page"); - $this->assertEqual($this->request->getServiceParameter(), ""); - } - - public function testGetSetServiceID() { - $this->request->setServiceID("foo"); - $this->assertEqual($this->request->getServiceID(), "foo"); - } - - public function testGetSetServiceParameterD() { - $this->request->setServiceParameter("foo"); - $this->assertEqual($this->request->getServiceParameter(), "foo"); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/common.php b/tests/UnitTests/framework/common.php deleted file mode 100644 index 059dd142..00000000 --- a/tests/UnitTests/framework/common.php +++ /dev/null @@ -1,99 +0,0 @@ - - */ -class PradoUnitTestCase extends UnitTestCase { - - /** - * Tests whether the given code results in an appropriate exception being raised. - * @param string the PHP code to execute. must end with a semi-colon. - * @param string the type of exception that should be raised. - * @return boolean true - */ - public function assertException(string $code, string $exceptionType) { - $ex = null; - eval("try { $code } catch ($exceptionType \$e) { \$ex = \$e; }"); - $this->assertIsA($ex, $exceptionType); - } -} - - - -/** - * Generate a class called MockTApplication to mock the TApplication class - * for the purpose of testing IModule objects. - */ -__autoload("TApplication"); -Mock::generate("TApplication"); - -/** - * ModuleTestCase class. - * - * Provides functionality designed to support testing of objects implementing the IModule - * interface. - * - * Also provides some specific tests for IModule objects. - * - * @author Alex Flint - */ - -class ModuleTestCase extends PradoUnitTestCase { - - protected $module = null; - protected $mockApplication = null; - - public function __construct() { - $file = ""; - $tihs->mockApplication = new MockTApplication($file); - } - - public function testGetSetID() { - if ($this->module instanceof IModule) { - $this->module->setId(123); - $this->assertEqual($this->module->getId(123)); - } - } - - /** - * Initializes $this->module by calling the init() method with the provided configuration. - * If no application object is provided then a mock application object $this->mockApplication. - * @param array optional. The configuration array to provide to the module. If none provided then - * an empty array will be used. - * @param TApplication optional. The TApplication to pass to the init() function of the module. - * If none provided then $this->mockApplication will be used. - */ - public function initModule($config=array(), $application=null) { - if ($this->module instanceof IModule) { - if (is_null($application)) { - $application =& $this->mockApplication; - } - $this->module->init($config, $application); - } - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/index.php b/tests/UnitTests/framework/index.php deleted file mode 100644 index 33c953f8..00000000 --- a/tests/UnitTests/framework/index.php +++ /dev/null @@ -1,103 +0,0 @@ -url="$rootUri/index.php?target=".strtr(substr($path,strlen($rootPath)+1),"\\",'/'); - $this->name=basename($path); - $dir=opendir($path); - while(($entry=readdir($dir))!==false) - { - $fullpath="$path/$entry"; - if($entry!=='.' && $entry!=='..' && $entry!=='.svn' && is_dir($fullpath)) - { - $folder=new TestFolder($fullpath,$rootPath,$rootUri); - if(!empty($folder->subFolders) || !empty($folder->testFiles)) - $this->subFolders[]=$folder; - } - else if(is_file($fullpath) && (strncmp($entry,'ut',2)===0 - || preg_match('/test.*\.php/', strtolower($entry)))) - { - $this->testFiles[$entry]="$rootUri/index.php?target=".strtr(substr($fullpath,strlen($rootPath)+1),"\\",'/'); - } - } - closedir($dir); - } - - public function getHtml($level=0) - { - $str=str_repeat(' ',$level*4)."[ url}\">{$this->name} ]
\n"; - foreach($this->subFolders as $folder) - $str.=$folder->getHtml($level+1); - foreach($this->testFiles as $name=>$url) - $str.=str_repeat(' ',($level+1)*4)."$name
\n"; - return $str; - } -} - - -function addTests($test,$path,$recursive) -{ - $dir=opendir($path); - while(($entry=readdir($dir))!==false) - { - if(is_file($path.'/'.$entry) && (strncmp($entry,'ut',2)===0||preg_match('/test.*\.php/', strtolower($entry)))) - $test->addTestFile($path.'/'.$entry); - else if($entry!=='.' && $entry!=='..' && $entry!=='.svn' && is_dir($path.'/'.$entry) && $recursive) - addTests($test,$path.'/'.$entry,$recursive); - } - closedir($dir); -} - - -$rootPath=realpath(dirname(__FILE__)); -$rootUri=dirname($_SERVER['PHP_SELF']); - -if(isset($_GET['target'])) -{ - $target=$_GET['target']; - $recursive=true; - $fullpath=realpath("$rootPath/$target"); - if($fullpath===false || strpos($fullpath,$rootPath)!==0) - die('invalid test target'); - include_once($rootPath.'/common.php'); - - if(is_dir($fullpath)) - { - - $test=new GroupTest(basename($rootPath)."/$target"); - addTests($test,$fullpath,$recursive); - $test->run(new HtmlReporter()); - //$test->run(new HtmlReporterWithCoverage('index.php',$rootPath)); - } - else - { - $testClass=basename($fullpath,'.php'); - include_once($fullpath); - $test=new $testClass(basename($rootPath)."/$target"); - - $test->run(new HtmlReporter()); - } -} -else -{ - echo " - -Prado Framework Unit Tests - - - -

Prado Framework Unit Tests

-"; - $root=new TestFolder($rootPath,$rootPath,$rootUri); - echo $root->getHtml(); - echo "\n"; -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/utApplication.php b/tests/UnitTests/framework/utApplication.php deleted file mode 100644 index 603f9fc3..00000000 --- a/tests/UnitTests/framework/utApplication.php +++ /dev/null @@ -1,25 +0,0 @@ -pass(); - } - chdir($dir); - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/utComponent.php b/tests/UnitTests/framework/utComponent.php deleted file mode 100644 index cfd40ce8..00000000 --- a/tests/UnitTests/framework/utComponent.php +++ /dev/null @@ -1,329 +0,0 @@ -_text; - } - - public function setText($value) - { - $this->_text=$value; - } - - public function getObject() - { - if(!$this->_object) - { - $this->_object=new NewComponent; - $this->_object->_text='object text'; - } - return $this->_object; - } - - public function onMyEvent($param) - { - $this->raiseEvent('OnMyEvent',$this,$param); - } - - public function myEventHandler($sender,$param) - { - $this->_eventHandled=true; - } - - public function isEventHandled() - { - return $this->_eventHandled; - } -} - -class utComponent extends UnitTestCase -{ - protected $component; - - public function setUp() - { - $this->component=new NewComponent; - } - - public function tearDown() - { - $this->component=null; - } - - public function testHasProperty() - { - $this->assertTrue($this->component->hasProperty('Text')); - $this->assertTrue($this->component->hasProperty('text')); - $this->assertFalse($this->component->hasProperty('Caption')); - } - - public function testCanGetProperty() - { - $this->assertTrue($this->component->canGetProperty('Text')); - $this->assertTrue($this->component->canGetProperty('text')); - $this->assertFalse($this->component->canGetProperty('Caption')); - } - - public function testCanSetProperty() - { - $this->assertTrue($this->component->canSetProperty('Text')); - $this->assertTrue($this->component->canSetProperty('text')); - $this->assertFalse($this->component->canSetProperty('Caption')); - } - - public function testGetProperty() - { - $this->assertTrue('default'===$this->component->Text); - try - { - $value2=$this->component->Caption; - $this->fail('exception not raised when getting undefined property'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testSetProperty() - { - $value='new value'; - $this->component->Text=$value; - $text=$this->component->Text; - $this->assertTrue($value===$this->component->Text); - try - { - $this->component->NewMember=$value; - $this->fail('exception not raised when setting undefined property'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testGetSubProperty() - { - $this->assertTrue('object text'===$this->component->getSubProperty('Object.Text')); - } - - public function testSetSubProperty() - { - $this->component->setSubProperty('Object.Text','new object text'); - $this->assertEqual('new object text',$this->component->getSubProperty('Object.Text')); - } - - public function testHasEvent() - { - $this->assertTrue($this->component->hasEvent('OnMyEvent')); - $this->assertTrue($this->component->hasEvent('onmyevent')); - $this->assertFalse($this->component->hasEvent('onYourEvent')); - } - - public function testHasEventHandler() - { - $this->assertFalse($this->component->hasEventHandler('OnMyEvent')); - $this->component->attachEventHandler('OnMyEvent','foo'); - $this->assertTrue($this->component->hasEventHandler('OnMyEvent')); - } - - public function testGetEventHandlers() - { - $list=$this->component->getEventHandlers('OnMyEvent'); - $this->assertTrue(($list instanceof TList) && ($list->getCount()===0)); - $this->component->attachEventHandler('OnMyEvent','foo'); - $this->assertTrue(($list instanceof TList) && ($list->getCount()===1)); - try - { - $list=$this->component->getEventHandlers('YourEvent'); - $this->fail('exception not raised when getting event handlers for undefined event'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - } - - public function testAttachEventHandler() - { - $this->component->attachEventHandler('OnMyEvent','foo'); - $this->assertTrue($this->component->getEventHandlers('OnMyEvent')->getCount()===1); - try - { - $this->component->attachEventHandler('YourEvent','foo'); - $this->fail('exception not raised when attaching event handlers for undefined event'); - } - catch(TInvalidOperationException $e) - { - $this->pass(); - } - /*$this->component->MyEvent[]='foo2'; - $this->assertTrue($this->component->getEventHandlers('MyEvent')->getCount()===2); - $this->component->getEventHandlers('MyEvent')->add('foo3'); - $this->assertTrue($this->component->getEventHandlers('MyEvent')->getCount()===3); - $this->component->MyEvent[0]='foo4'; - $this->assertTrue($this->component->getEventHandlers('MyEvent')->getCount()===3); - $this->component->getEventHandlers('MyEvent')->insert(0,'foo5'); - $this->assertTrue($this->component->MyEvent->Count===4 && $this->component->MyEvent[0]==='foo5'); - $this->component->MyEvent='foo6'; - $this->assertTrue($this->component->MyEvent->Count===5 && $this->component->MyEvent[4]==='foo6');*/ - } - - public function testRaiseEvent() - { - $this->component->attachEventHandler('OnMyEvent',array($this->component,'myEventHandler')); - $this->assertFalse($this->component->isEventHandled()); - $this->component->raiseEvent('OnMyEvent',$this,null); - $this->assertTrue($this->component->isEventHandled()); - $this->component->attachEventHandler('OnMyEvent',array($this->component,'Object.myEventHandler')); - $this->assertFalse($this->component->Object->isEventHandled()); - $this->component->raiseEvent('OnMyEvent',$this,null); - $this->assertTrue($this->component->Object->isEventHandled()); - } - - public function testEvaluateExpression() - { - $expression="1+2"; - $this->assertTrue(3===$this->component->evaluateExpression($expression)); - try - { - $button=$this->component->evaluateExpression('$this->button'); - $this->fail('exception not raised when evaluating an invalid exception'); - } - catch(Exception $e) - { - $this->pass(); - } - } - - public function testEvaluateStatements() - { - $statements='$a="test string"; echo $a;'; - $this->assertEqual('test string',$this->component->evaluateStatements($statements)); - try - { - $statements='$a=new NewComponent; echo $a->button;'; - $button=$this->component->evaluateStatements($statements); - $this->fail('exception not raised when evaluating an invalid statement'); - } - catch(Exception $e) - { - $this->pass(); - } - } - - - /** - * Tests the TPropertyValue::ensureBoolean function - */ - public function testEnsureBoolean() - { - // Note: we must use assertEqual not assertTrue or assertFalse because then we can check that the return value is strictly of type boolean - $this->assertEqual(TPropertyValue::ensureBoolean('false'), false); - $this->assertEqual(TPropertyValue::ensureBoolean('False'), false); - $this->assertEqual(TPropertyValue::ensureBoolean(false), false); - $this->assertEqual(TPropertyValue::ensureBoolean(0), false); - $this->assertEqual(TPropertyValue::ensureBoolean(0.0), false); - $this->assertEqual(TPropertyValue::ensureBoolean(""), false); - $this->assertEqual(TPropertyValue::ensureBoolean("0"), false); - $this->assertEqual(TPropertyValue::ensureBoolean(array()), false); - $this->assertEqual(TPropertyValue::ensureBoolean(null), false); - - $this->assertEqual(TPropertyValue::ensureBoolean('true'), true); - $this->assertEqual(TPropertyValue::ensureBoolean('True'), true); - $this->assertEqual(TPropertyValue::ensureBoolean(1), true); - $this->assertEqual(TPropertyValue::ensureBoolean("1"), true); - $this->assertEqual(TPropertyValue::ensureBoolean("-1"), true); - $this->assertEqual(TPropertyValue::ensureBoolean(array("foboar")), true); - } - - /** - * Tests the TPropertyValue::ensureString function - */ - public function testEnsureString() - { - $this->assertEqual(TPropertyValue::ensureString("foobar"), "foobar"); - $this->assertEqual(TPropertyValue::ensureString(true), "true"); - $this->assertEqual(TPropertyValue::ensureString(false), "false"); - $this->assertEqual(TPropertyValue::ensureString(array("foo","bar")), (string)array("foo","bar")); - } - - /** - * Tests the TPropertyValue::ensureInteger function - */ - public function testEnsureInteger() - { - $this->assertEqual(TPropertyValue::ensureInteger(123), 123); - $this->assertEqual(TPropertyValue::ensureInteger("123"), 123); - $this->assertEqual(TPropertyValue::ensureInteger(""), 0); - } - - /** - * Tests the TPropertyValue::ensureFloat function - */ - public function testEnsureFloat() - { - $this->assertEqual(TPropertyValue::ensureFloat(123.123), 123.123); - $this->assertEqual(TPropertyValue::ensureFloat("123.123"), 123.123); - $this->assertEqual(TPropertyValue::ensureFloat(""), 0.0); - } - - /** - * Tests the TPropertyValue::ensureArray function - */ - public function testEnsureArray() - { - $this->assertEqual(TPropertyValue::ensureArray(array()), array()); - $this->assertEqual(TPropertyValue::ensureArray(array(1,2,3)), array(1,2,3)); - $this->assertEqual(TPropertyValue::ensureArray("(1,2,3)"), array(1,2,3)); - $this->assertEqual(TPropertyValue::ensureArray(""), array()); - } - - /** - * Tests the TPropertyValue::ensureObject function - */ - public function testEnsureObject() - { - $this->assertEqual(TPropertyValue::ensureObject($this->component), $this->component); - } - - /** - * Tests the TPropertyValue::ensureEnum function - */ - public function testEnsureEnum() - { - $this->assertEqual(TPropertyValue::ensureEnum("foo", array("foo", "bar", "BAR")), "foo"); - $this->assertEqual(TPropertyValue::ensureEnum("bar", array("foo", "bar", "BAR")), "bar"); - $this->assertEqual(TPropertyValue::ensureEnum("BAR", array("foo", "bar", "BAR")), "BAR"); - $pass = false; - try { - $this->assertEqual(TPropertyValue::ensureEnum("xxx", array("foo", "bar", "BAR")), "BAR"); - } catch (TInvalidDataValueException $e) { - $this->pass(); - $pass = true; - } - if (!$pass) { - $this->fail("ensureEnun didn't raise a TInvalidDataValueException when it should have"); - } - $pass = false; - try { - $this->assertEqual(TPropertyValue::ensureEnum("FOO", array("foo", "bar", "BAR")), "BAR"); - } catch (TInvalidDataValueException $e) { - $this->pass(); - $pass = true; - } - if (!$pass) { - $this->fail("ensureEnun didn't raise a TInvalidDataValueException when it should have"); - } - } -} - -?> \ No newline at end of file diff --git a/tests/UnitTests/framework/utPradoBase.php b/tests/UnitTests/framework/utPradoBase.php deleted file mode 100644 index a53c17dd..00000000 --- a/tests/UnitTests/framework/utPradoBase.php +++ /dev/null @@ -1,110 +0,0 @@ -data=$data; - } -} - -class utPradoBase extends UnitTestCase -{ - public function testFrameworkPath() - { - $this->assertTrue(FRAMEWORK_DIR===Prado::getFrameworkPath()); - } - - public function testSerialization() - { - $object=new TComponent; - $number=12345.123; - $string='12345\'"'; - $array=array('123'=>123,'abc'=>'def'); - $this->assertFalse($object===Prado::unserialize(Prado::serialize($object))); - $this->assertTrue(Prado::unserialize(Prado::serialize($object)) instanceof TComponent); - $this->assertTrue($number===Prado::unserialize(Prado::serialize($number))); - $this->assertTrue($string===Prado::unserialize(Prado::serialize($string))); - $this->assertTrue($array===Prado::unserialize(Prado::serialize($array))); - - // test complex object reference structure grandparent <-> parent <-> child - $grandp=new testNode('grandp'); - $parent=new testNode('parent'); - $child=new testNode('child'); - $grandp->child=$parent; - $parent->child=$child; - $child->parent=$parent; - $parent->parent=$grandp; - - $newGrandp=Prado::unserialize(Prado::serialize($grandp)); - $this->assertTrue($newGrandp!==$grandp); - $this->assertTrue($newGrandp instanceof testNode); - $this->assertTrue($newGrandp->parent===null); - $this->assertTrue($newGrandp->data==='grandp'); - - $newParent=$newGrandp->child; - $this->assertTrue($newParent!==$parent); - $this->assertTrue($newParent instanceof testNode); - $this->assertTrue($newParent->parent===$newGrandp); - $this->assertTrue($newParent->data==='parent'); - - $newChild=$newParent->child; - $this->assertTrue($newChild!==$child); - $this->assertTrue($newChild instanceof testNode); - $this->assertTrue($newChild->parent===$newParent); - $this->assertTrue($newChild->child===null); - $this->assertTrue($newChild->data==='child'); - } - - public function testCreateComponent() - { - $this->assertTrue(Prado::createComponent('TComponent') instanceof TComponent); - $this->assertTrue(Prado::createComponent('System.TComponent') instanceof TComponent); - try - { - Prado::createComponent('System.TComponent2'); - $this->fail('exception not raised when creating a nonexistent component'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - } - - public function testNamespace() - { - $this->assertTrue(FRAMEWORK_DIR===Prado::getPathOfAlias('System')); - $this->assertTrue(Prado::getPathOfAlias('System2')===null); - $testSystem=dirname(__FILE__).'/TestSystem'; - - Prado::setPathOfAlias('TestSystem',$testSystem); - $this->assertTrue(realpath($testSystem)===Prado::getPathOfAlias('TestSystem')); - - $this->assertTrue(Prado::getPathOfNamespace('TestSystem.*')===realpath($testSystem)); - $this->assertTrue(Prado::getPathOfNamespace('TestSystem.protected.*')===realpath($testSystem).'/protected'); - - // test repeatedly using the same namespaces - Prado::using('System.*'); - Prado::using('System.*'); - Prado::using('System.TComponent'); - Prado::using('System.TComponent'); - - try - { - Prado::using('System'); - $this->fail('no exception raised when using an invalid namespace for a directory'); - } - catch(TInvalidDataValueException $e) - { - $this->pass(); - } - // TODO: using new namespaces to see if classes can be automatically loaded or found - } -} - -?> \ No newline at end of file -- cgit v1.2.3