From 348bd9d3987c42b9204519b22b7238e8dc19e514 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Sun, 17 Jul 2011 23:12:50 +0000 Subject: TSecurityManager: remove additional right padding added by mcrypt_decrypt TSecurityManagerTest: loop through different string length to take account of mcrypt's block cipher padding TAPCCacheTest: fixed static member usage THttpRequestTest: fixed testRequestWithUrlMapping test --- tests/unit/Caching/TAPCCacheTest.php | 2 +- tests/unit/Security/TSecurityManagerTest.php | 29 ++++++++++++++++++---------- tests/unit/Web/THttpRequestTest.php | 4 +++- 3 files changed, 23 insertions(+), 12 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/Caching/TAPCCacheTest.php b/tests/unit/Caching/TAPCCacheTest.php index 84ff02ca..5c6779f0 100644 --- a/tests/unit/Caching/TAPCCacheTest.php +++ b/tests/unit/Caching/TAPCCacheTest.php @@ -33,7 +33,7 @@ class TAPCCacheTest extends PHPUnit_Framework_TestCase { protected function tearDown() { $this->app = null; - $this->cache = null; + self::$cache = null; } public function testInit() { diff --git a/tests/unit/Security/TSecurityManagerTest.php b/tests/unit/Security/TSecurityManagerTest.php index 731547c9..2daf6ede 100644 --- a/tests/unit/Security/TSecurityManagerTest.php +++ b/tests/unit/Security/TSecurityManagerTest.php @@ -83,17 +83,26 @@ class TSecurityManagerTest extends PHPUnit_Framework_TestCase { public function testEncryptDecrypt() { $sec=new TSecurityManager (); $sec->init (null); - $sec->setEncryptionKey ('aKey'); - try { - $encrypted = $sec->encrypt('a text'); - } catch (TNotSupportedException $e) { - self::markTestSkipped('mcrypt extension not loaded'); - return; + // loop through different string size + $testText = md5('a text (not) full of entrophy'); + for($i=1; $isetEncryptionKey ('aKey'); + $plainText = substr($testText, 0, $i); + try { + $encrypted = $sec->encrypt($plainText); + } catch (TNotSupportedException $e) { + self::markTestSkipped('mcrypt extension not loaded'); + return; + } + $decrypted = $sec->decrypt($encrypted); + + self::assertEquals($plainText,$decrypted); + + // try change key + $sec->setEncryptionKey ('anotherKey'); + self::assertNotEquals($plainText, $sec->decrypt($encrypted)); } - self::assertEquals('a text', $sec->decrypt($encrypted)); - // try change key - $sec->setEncryptionKey ('anotherKey'); - self::assertNotEquals('a text', $sec->decrypt($encrypted)); } diff --git a/tests/unit/Web/THttpRequestTest.php b/tests/unit/Web/THttpRequestTest.php index f33bac60..6af8cd78 100644 --- a/tests/unit/Web/THttpRequestTest.php +++ b/tests/unit/Web/THttpRequestTest.php @@ -483,10 +483,12 @@ class THttpRequestTest extends PHPUnit_Framework_TestCase { if (isset ($_GET['page'])) unset ($_GET['page']); // Remove service from a previous test ! $_SERVER['REQUEST_URI'] = '/index.php/test/value2'; $_SERVER['SCRIPT_NAME'] = '/index.php'; - $_SERVER['PHP_SELF'] = '/index.php'; + $_SERVER['PHP_SELF'] = '/index.php/test/value2'; $_SERVER['QUERY_STRING'] = ''; + $_SERVER['PATH_INFO'] = '/test/value2'; $request = new THttpRequest(); $request->setUrlManager('friendly-url'); + $request->setUrlFormat(THttpRequestUrlFormat::Path); $request->init(null); $module->init ($config); self::assertEquals('testService', $request->resolveRequest(array ('page', 'testService'))); -- cgit v1.2.3