summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/AllTests.php2
-rw-r--r--tests/unit/Caching/TMemCacheTest.php2
-rw-r--r--tests/unit/Web/AllTests.php4
-rw-r--r--tests/unit/Web/TCacheHttpSessionTest.php129
-rw-r--r--tests/unit/Web/TMemCacheSessionTest.php115
5 files changed, 133 insertions, 119 deletions
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 @@
+<?php
+require_once dirname(__FILE__).'/../phpunit.php';
+
+Prado::using('System.Web.TCacheHttpSession');
+Prado::using('System.Caching.TMemCache');
+
+/**
+ * @package System.Web
+ */
+class TCacheHttpSessionTest extends PHPUnit_Framework_TestCase
+{
+ protected $app = null;
+ protected static $cache = null;
+ protected static $session = null;
+
+ protected function setUp()
+ {
+ if(!extension_loaded('memcache'))
+ {
+ self::markTestSkipped('The memcache extension is not available');
+ }
+ else
+ {
+ $basePath = dirname(__FILE__).'/app';
+ $runtimePath = $basePath.'/runtime';
+ if(!is_writable($runtimePath))
+ {
+ self::markTestSkipped("'$runtimePath' is not writable");
+ }
+ $this->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 @@
-<?php
-require_once dirname(__FILE__).'/../phpunit.php';
-
-Prado::using('System.Web.TMemCacheSession');
-
-/**
- * @package System.Web
- */
-class TMemCacheSessionTest extends PHPUnit_Framework_TestCase {
-
- public function testInit() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testOpen() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testClose() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testDestroy() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testGetIsStarted() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetSessionID() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetSessionName() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetSavePath() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetUseCustomStorage() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetCookieMode() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetAutoStart() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetGProbability() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetUseTransparentSessionID() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testSetTimeout() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testGetIterator() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testGetCount() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testGetKeys() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testItemAt() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testAdd() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testRemove() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testContains() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testToArray() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testOffsetExists() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testOffsetGet() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testOffsetSet() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-
- public function testOffsetUnset() {
- throw new PHPUnit_Framework_IncompleteTestError();
- }
-}
-?> \ No newline at end of file