[TASK] Unit tests for extMgm::extPath()
authorChristian Kuhn <lolli@schwarzbu.ch>
Sat, 9 Jul 2011 07:58:51 +0000 (09:58 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 9 Jul 2011 08:26:01 +0000 (10:26 +0200)
Change-Id: I42ecefc082f98d899dfa712e9addea9ba2bade17
Resolves: #28011
Reviewed-on: http://review.typo3.org/3167
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
tests/t3lib/class.t3lib_extmgmTest.php

index 261a8b1..73da8aa 100644 (file)
  * @subpackage t3lib
  */
 class t3lib_extmgmTest extends tx_phpunit_testcase {
+
        /**
-        * backup of defined GLOBALS
+        * Enable backup of global and system variables
         *
-        * @var array
+        * @var boolean
         */
-       protected $globals = array();
+       protected $backupGlobals = TRUE;
 
-       public function setUp() {
-               $this->globals = array(
-                       'TYPO3_CONF_VARS' => serialize($GLOBALS['TYPO3_CONF_VARS']),
-                       'TYPO3_LOADED_EXT' => serialize($GLOBALS['TYPO3_LOADED_EXT']),
-                       'TCA' => serialize($GLOBALS['TCA']),
-               );
-       }
+       /**
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
+        *
+        * @var array
+        */
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
 
        public function tearDown() {
                t3lib_extMgm::clearExtensionKeyMap();
+       }
 
-               foreach ($this->globals as $key => $value) {
-                       $GLOBALS[$key] = unserialize($value);
-               }
+       ///////////////////////////////
+       // Tests concerning extPath
+       ///////////////////////////////
+
+       /**
+        * @test
+        * @expectedException BadFunctionCallException
+        */
+       public function extPathThrowsExceptionIfExtensionIsNotLoaded() {
+               $GLOBALS['TYPO3_LOADED_EXT']['foo'] = array();
+               t3lib_extMgm::extPath('bar');
        }
 
+       /**
+        * @test
+        */
+       public function extPathAppendsScriptNameToPath() {
+               $GLOBALS['TYPO3_LOADED_EXT']['foo']['siteRelPath'] = 'foo/';
+               $this->assertSame(PATH_site . 'foo/bar.txt', t3lib_extMgm::extPath('foo', 'bar.txt'));
+       }
 
        //////////////////////
        // Utility functions