diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/unit/Caching/TAPCCacheTest.php | 2 | ||||
| -rw-r--r-- | tests/unit/Security/TSecurityManagerTest.php | 29 | ||||
| -rw-r--r-- | tests/unit/Web/THttpRequestTest.php | 4 | 
3 files changed, 23 insertions, 12 deletions
| 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; $i<strlen($testText); $i++) +		{ +			$sec->setEncryptionKey ('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'))); | 
