Author: Alexandru Stanoi Date: 2007-01-08 14:35:48 +0100 (Mon, 08 Jan 2007) New Revision: 4472
Log: - Added some more tests for ezcBaseFeatures. Modified: trunk/Base/src/features.php trunk/Base/tests/features_test.php Modified: trunk/Base/src/features.php =================================================================== --- trunk/Base/src/features.php 2007-01-08 13:08:24 UTC (rev 4471) +++ trunk/Base/src/features.php 2007-01-08 13:35:48 UTC (rev 4472) @@ -193,12 +193,11 @@ /** * Returns if a given class exists. * Checks for a given class name and returns if this class exists or not. - * Catches the ezcBaseAutoloadException and returns false, if it was - * throwen. + * Catches the ezcBaseAutoloadException and returns false, if it was thrown. * * @param string $className The class to check for. - * @param boolean $autoload True to use __autolaod(), otherwise false. - * @return boolean True if the class exists. Otherwise false. + * @param bool $autoload True to use __autoload(), otherwise false. + * @return bool True if the class exists. Otherwise false. */ public static function classExists( $className, $autoload = true ) { Modified: trunk/Base/tests/features_test.php =================================================================== --- trunk/Base/tests/features_test.php 2007-01-08 13:08:24 UTC (rev 4471) +++ trunk/Base/tests/features_test.php 2007-01-08 13:35:48 UTC (rev 4472) @@ -74,6 +74,34 @@ $this->assertEquals( true, ezcBaseFeatures::hasExtensionSupport( 'mysql' ) ); } + public function testHasExtensionSupportNotFound1() + { + $this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) ); + try + { + throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', null, 'This is just a test.' ); + } + catch ( ezcBaseExtensionNotFoundException $e ) + { + $this->assertEquals( "The extension 'non_existent_extension' could not be found. This is just a test.", + $e->getMessage() ); + } + } + + public function testHasExtensionSupportNotFound2() + { + $this->assertEquals( false, ezcBaseFeatures::hasExtensionSupport( 'non_existent_extension' ) ); + try + { + throw new ezcBaseExtensionNotFoundException( 'non_existent_extension', '1.2', 'This is just a test.' ); + } + catch ( ezcBaseExtensionNotFoundException $e ) + { + $this->assertEquals( "The extension 'non_existent_extension' with version '1.2' could not be found. This is just a test.", + $e->getMessage() ); + } + } + public function testHasFunction1() { $this->assertEquals( true, ezcBaseFeatures::hasFunction( 'function_exists' ) ); @@ -81,7 +109,7 @@ public function testHasFunction2() { - $this->assertEquals( false, ezcBaseFeatures::hasFunction( 'non_existant_funtion_in_php' ) ); + $this->assertEquals( false, ezcBaseFeatures::hasFunction( 'non_existent_function_in_php' ) ); } public function testHasExtensionSupport2() @@ -89,6 +117,26 @@ $this->assertEquals( true, ezcBaseFeatures::hasExtensionSupport( 'date', '5.1.0' ) ); } + public function testClassExists() + { + $this->assertEquals( true, ezcBaseFeatures::classExists( 'Exception', false ) ); + } + + public function testClassExistsAutoload() + { + $this->assertEquals( true, ezcBaseFeatures::classExists( 'ezcBaseFeatures' ) ); + } + + public function testClassExistsNotFound() + { + $this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass', false ) ); + } + + public function testClassExistsNotFoundAutoload() + { + $this->assertEquals( false, ezcBaseFeatures::classExists( 'ezcBaseNonExistingClass' ) ); + } + public static function suite() { return new PHPUnit_Framework_TestSuite("ezcBaseFeaturesTest"); -- svn-components mailing list svn-components@lists.ez.no http://lists.ez.no/mailman/listinfo/svn-components