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/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 ---------- 13 files changed, 689 deletions(-) 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 (limited to 'tests/UnitTests/framework/Data') 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 -- cgit v1.2.3