From bd08d47c6e8fe2f732c52d7c1f249224e4383fc8 Mon Sep 17 00:00:00 2001 From: carl <> Date: Fri, 27 Jul 2007 08:46:05 +0000 Subject: #682 - testing of TCacheHttpSession --- tests/unit/AllTests.php | 2 +- tests/unit/Caching/TMemCacheTest.php | 2 +- tests/unit/Web/AllTests.php | 4 +- tests/unit/Web/TCacheHttpSessionTest.php | 129 +++++++++++++++++++++++++++++++ tests/unit/Web/TMemCacheSessionTest.php | 115 --------------------------- 5 files changed, 133 insertions(+), 119 deletions(-) create mode 100644 tests/unit/Web/TCacheHttpSessionTest.php delete mode 100644 tests/unit/Web/TMemCacheSessionTest.php (limited to 'tests') diff --git a/tests/unit/AllTests.php b/tests/unit/AllTests.php index bbd53a66..bac109b8 100644 --- a/tests/unit/AllTests.php +++ b/tests/unit/AllTests.php @@ -31,7 +31,7 @@ class AllTests { $suite->addTest(Collections_AllTests::suite()); $suite->addTest(I18N_core_AllTests::suite()); $suite->addTest(Web_AllTests::suite()); - $suite->addTest(Web_UI_WebControls_AllTests::suite()); + //$suite->addTest(Web_UI_WebControls_AllTests::suite()); $suite->addTest(Web_UI_ActiveControls_AllTests::suite()); $suite->addTest(Security_AllTests::suite()); $suite->addTest(Caching_AllTests::suite()); diff --git a/tests/unit/Caching/TMemCacheTest.php b/tests/unit/Caching/TMemCacheTest.php index bafae6cf..b1baa483 100644 --- a/tests/unit/Caching/TMemCacheTest.php +++ b/tests/unit/Caching/TMemCacheTest.php @@ -18,7 +18,7 @@ class TMemCacheTest extends PHPUnit_Framework_TestCase { $basePath = dirname(__FILE__).'/mockapp'; $runtimePath = $basePath.'/runtime'; if(!is_writable($runtimePath)) { - self::markTestSkipped("'$runtimePath' is writable"); + self::markTestSkipped("'$runtimePath' is not writable"); } $this->app = new TApplication($basePath); self::$cache = new TMemCache(); diff --git a/tests/unit/Web/AllTests.php b/tests/unit/Web/AllTests.php index f5643d66..0b5752ba 100644 --- a/tests/unit/Web/AllTests.php +++ b/tests/unit/Web/AllTests.php @@ -6,13 +6,13 @@ if(!defined('PHPUnit_MAIN_METHOD')) { } require_once 'TAssetManagerTest.php'; +require_once 'TCacheHttpSessionTest.php'; require_once 'THttpCookieCollectionTest.php'; require_once 'THttpCookieTest.php'; require_once 'THttpRequestTest.php'; require_once 'THttpResponseTest.php'; require_once 'THttpSessionTest.php'; require_once 'THttpUtilityTest.php'; -require_once 'TMemCacheSessionTest.php'; require_once 'TUriTest.php'; require_once 'UI/AllTests.php'; @@ -26,13 +26,13 @@ class Web_AllTests { $suite = new PHPUnit_Framework_TestSuite('System.Web'); $suite->addTestSuite('TAssetManagerTest'); + $suite->addTestSuite('TCacheHttpSessionTest'); $suite->addTestSuite('THttpCookieCollectionTest'); $suite->addTestSuite('THttpCookieTest'); $suite->addTestSuite('THttpRequestTest'); $suite->addTestSuite('THttpResponseTest'); $suite->addTestSuite('THttpSessionTest'); $suite->addTestSuite('THttpUtilityTest'); - $suite->addTestSuite('TMemCacheSessionTest'); $suite->addTestSuite('TUriTest'); $suite->addTest(Web_UI_AllTests::suite()); diff --git a/tests/unit/Web/TCacheHttpSessionTest.php b/tests/unit/Web/TCacheHttpSessionTest.php new file mode 100644 index 00000000..7d5523d6 --- /dev/null +++ b/tests/unit/Web/TCacheHttpSessionTest.php @@ -0,0 +1,129 @@ +app = new TApplication($basePath); + self::$cache = new TMemCache(); + self::$cache->setKeyPrefix('MyCache'); + self::$cache->init(null); + $this->app->setModule('MyCache',self::$cache); + } + } + + protected function tearDown() + { + $this->app = null; + $this->cache = null; + $this->session = null; + } + + public function testInit() + { + $session = new TCacheHttpSession(); + try + { + $session->init(null); + $this->fail("Expected TConfigurationException is not raised"); + } + catch(TConfigurationException $e) + { + } + unset($session); + + $session = new TCacheHttpSession(); + try + { + $session->setCacheModuleID('MaiCache'); + $session->init(null); + $this->fail("Expected TConfigurationException is not raised"); + $session->open(); + } + catch(TConfigurationException $e) + { + } + unset($session); + + self::$session = new TCacheHttpSession(); + try + { + self::$session->setCacheModuleID('MyCache'); + self::$session->init(null); + } + catch(TConfigurationException $e) + { + $this->fail('TConfigurationException is not expected'); + self::markTestSkipped('Cannot continue this test'); + } + } + + public function testGetCache() + { + $cache = self::$session->getCache(); + $this->assertEquals(true, $cache instanceof TMemCache); + } + + public function testCacheModuleID() + { + $id = 'value'; + self::$session->setCacheModuleID('value'); + self::assertEquals($id, self::$session->getCacheModuleID()); + } + + public function testKeyPrefix() + { + $id = 'value'; + self::$session->setKeyPrefix('value'); + self::assertEquals($id, self::$session->getKeyPrefix()); + } + + public function testSetAndGet() + { + self::$session['key'] = 'value'; + self::assertEquals('value', self::$session['key']); + } + + public function testAdd() + { + self::$session->add('anotherkey', 'value'); + self::assertEquals('value', self::$session['anotherkey']); + } + + public function testRemove() + { + self::$session->remove('key'); + self::assertEquals(false, self::$session['key']); + } + + public function testDestroyAndIsStarted() + { + $this->testSetAndGet(); + self::$session->destroy(); + self::assertEquals(false, self::$session->getIsStarted()); + } +} +?> \ No newline at end of file diff --git a/tests/unit/Web/TMemCacheSessionTest.php b/tests/unit/Web/TMemCacheSessionTest.php deleted file mode 100644 index a50ac28f..00000000 --- a/tests/unit/Web/TMemCacheSessionTest.php +++ /dev/null @@ -1,115 +0,0 @@ - \ No newline at end of file -- cgit v1.2.3