Fixed bug #17490: After introducing the locking in #17289 no CSRF token will ever...
[Packages/TYPO3.CMS.git] / tests / t3lib / t3lib_divTest.php
index 2ecc2a6..f3fec1a 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2009-2010 Ingo Renner <ingo@typo3.org>
+*  (c) 2009-2011 Ingo Renner <ingo@typo3.org>
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -22,7 +22,6 @@
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
 
-
 /**
  * Testcase for class t3lib_div
  *
  * @subpackage t3lib
  */
 class t3lib_divTest extends tx_phpunit_testcase {
+
+       /**
+        * Enable backup of global and system variables
+        *
+        * @var boolean
+        */
+       protected $backupGlobals = TRUE;
+
        /**
-        * backup of the global variables _GET, _POST, _SERVER
+        * Exclude TYPO3_DB from backup/ restore of $GLOBALS
+        * because resource types cannot be handled during serializing
         *
         * @var array
         */
-       private $backupGlobalVariables;
+       protected $backupGlobalsBlacklist = array('TYPO3_DB');
 
-       public function setUp() {
-               $this->backupGlobalVariables = array(
-                       '_GET' => $_GET,
-                       '_POST' => $_POST,
-                       '_SERVER' => $_SERVER,
-                       'TYPO3_CONF_VARS' =>  $GLOBALS['TYPO3_CONF_VARS'],
-               );
+       public function tearDown() {
+               t3lib_div::purgeInstances();
        }
 
-       public function tearDown() {
-               foreach ($this->backupGlobalVariables as $key => $data) {
-                       $GLOBALS[$key] = $data;
+
+       ///////////////////////////////
+       // Tests concerning gif_compress
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() test not available on Windows.');
+               }
+
+               if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] || !$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']) {
+                       $this->markTestSkipped('gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() test not available without imagemagick setup.');
+               }
+
+               $testFinder = t3lib_div::makeInstance('Tx_Phpunit_Service_TestFinder');
+               $fixtureGifFile = $testFinder->getAbsoluteCoreTestsPath() . 't3lib/fixtures/clear.gif';
+
+               $GLOBALS['TYPO3_CONF_VARS']['GFX']['gif_compress'] = TRUE;
+
+                       // Copy file to unique filename in typo3temp, set target permissions and run method
+               $testFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.gif';
+               @copy($fixtureGifFile, $testFilename);
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
+               t3lib_div::gif_compress($testFilename, 'IM');
+
+                       // Get actual permissions and clean up
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms($testFilename)), 2);
+               t3lib_div::unlink_tempfile($testFilename);
+
+               $this->assertEquals($resultFilePermissions, '0777');
+       }
+
+       /**
+        * @test
+        */
+       public function gifCompressFixesPermissionOfConvertedFileIfUsingGd() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('gifCompressFixesPermissionOfConvertedFileIfUsingImagemagick() test not available on Windows.');
+               }
+
+               $testFinder = t3lib_div::makeInstance('Tx_Phpunit_Service_TestFinder');
+               $fixtureGifFile = $testFinder->getAbsoluteCoreTestsPath() . 't3lib/fixtures/clear.gif';
+
+               $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'] = TRUE;
+               $GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib_png'] = FALSE;
+
+                       // Copy file to unique filename in typo3temp, set target permissions and run method
+               $testFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.gif';
+               @copy($fixtureGifFile, $testFilename);
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
+               t3lib_div::gif_compress($testFilename, 'GD');
+
+                       // Get actual permissions and clean up
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms($testFilename)), 2);
+               t3lib_div::unlink_tempfile($testFilename);
+
+               $this->assertEquals($resultFilePermissions, '0777');
+       }
+
+       ///////////////////////////////
+       // Tests concerning png_to_gif_by_imagemagick
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function pngToGifByImagemagickFixesPermissionsOfConvertedFile() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('pngToGifByImagemagickFixesPermissionsOfConvertedFile() test not available on Windows.');
+               }
+
+               if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] || !$GLOBALS['TYPO3_CONF_VARS']['GFX']['im_path_lzw']) {
+                       $this->markTestSkipped('pngToGifByImagemagickFixesPermissionsOfConvertedFile() test not available without imagemagick setup.');
                }
+
+               $testFinder = t3lib_div::makeInstance('Tx_Phpunit_Service_TestFinder');
+               $fixturePngFile = $testFinder->getAbsoluteCoreTestsPath() . 't3lib/fixtures/clear.png';
+
+               $GLOBALS['TYPO3_CONF_VARS']['FE']['png_to_gif'] = TRUE;
+
+                       // Copy file to unique filename in typo3temp, set target permissions and run method
+               $testFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.png';
+               @copy($fixturePngFile, $testFilename);
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
+               $newGifFile = t3lib_div::png_to_gif_by_imagemagick($testFilename);
+
+                       // Get actual permissions and clean up
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms($newGifFile)), 2);
+               t3lib_div::unlink_tempfile($newGifFile);
+
+               $this->assertEquals($resultFilePermissions, '0777');
        }
 
+       ///////////////////////////////
+       // Tests concerning read_png_gif
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function readPngGifFixesPermissionsOfConvertedFile() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('readPngGifFixesPermissionsOfConvertedFile() test not available on Windows.');
+               }
+
+               if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
+                       $this->markTestSkipped('readPngGifFixesPermissionsOfConvertedFile() test not available without imagemagick setup.');
+               }
+
+               $testFinder = t3lib_div::makeInstance('Tx_Phpunit_Service_TestFinder');
+               $testGifFile = $testFinder->getAbsoluteCoreTestsPath() . 't3lib/fixtures/clear.gif';
+
+                       // Set target permissions and run method
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
+               $newPngFile = t3lib_div::read_png_gif($testGifFile, TRUE);
+
+                       // Get actual permissions and clean up
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms($newPngFile)), 2);
+               t3lib_div::unlink_tempfile($newPngFile);
+
+               $this->assertEquals($resultFilePermissions, '0777');
+       }
 
        ///////////////////////////////
        // Tests concerning validIP
@@ -75,13 +201,10 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Checks if t3lib_div::validIP() returns true for valid IPs
-        *
         * @test
-        * @see t3lib_div::validIP()
         * @dataProvider validIpDataProvider
         */
-       public function checkValidIpReturnsTrueForValidIp($ip) {
+       public function validIpReturnsTrueForValidIp($ip) {
                $this->assertTrue(t3lib_div::validIP($ip));
        }
 
@@ -98,108 +221,304 @@ class t3lib_divTest extends tx_phpunit_testcase {
                        'string empty' => array(''),
                        'string null' => array('null'),
                        'out of bounds IPv4' => array('300.300.300.300'),
-                       'wrong dotted decimal notation with only two dots' => array('127.0.1'),
+                       'dotted decimal notation with only two dots' => array('127.0.1'),
                );
        }
 
        /**
-        * Checks if t3lib_div::validIP() returns false for invalid IPs
-        *
         * @test
-        * @see t3lib_div::validIP()
         * @dataProvider invalidIpDataProvider
         */
-       public function checkValidIpReturnsFalseForInvalidIp($ip) {
+       public function validIpReturnsFalseForInvalidIp($ip) {
                $this->assertFalse(t3lib_div::validIP($ip));
        }
 
 
        ///////////////////////////////
-       // Tests concerning splitCalc
+       // Tests concerning testInt
        ///////////////////////////////
 
        /**
+        * Data provider for testIntReturnsTrue
+        *
+        * @return array Data sets
+        */
+       public function functionTestIntValidDataProvider() {
+               return array(
+                       'int' => array(32425),
+                       'negative int' => array(-32425),
+                       'largest int' => array(PHP_INT_MAX),
+                       'int as string' => array('32425'),
+                       'negative int as string' => array('-32425'),
+                       'zero' => array(0),
+                       'zero as string' => array('0'),
+               );
+       }
+
+       /**
         * @test
+        * @dataProvider functionTestIntValidDataProvider
         */
-       public function splitCalcForEmptyStringReturnsEmptyArray() {
-               $this->assertEquals(
-                       array(),
-                       t3lib_div::splitCalc('', '+-*/')
+       public function testIntReturnsTrue($int) {
+               $this->assertTrue(t3lib_div::testInt($int));
+       }
+
+       /**
+        * Data provider for testIntReturnsFalse
+        *
+        * @return array Data sets
+        */
+       public function functionTestIntInvalidDataProvider() {
+               return array(
+                       'int as string with leading zero' => array('01234'),
+                       'positive int as string with plus modifier' => array('+1234'),
+                       'negative int as string with leading zero' => array('-01234'),
+                       'largest int plus one' => array(PHP_INT_MAX + 1),
+                       'string' => array('testInt'),
+                       'empty string' => array(''),
+                       'int in string' => array('5 times of testInt'),
+                       'int as string with space after' => array('5 '),
+                       'int as string with space before' => array(' 5'),
+                       'int as string with many spaces before' => array('     5'),
+                       'float' => array(3.14159),
+                       'float as string' => array('3.14159'),
+                       'float as string only a dot' => array('10.'),
+                       'float as string trailing zero would evaluate to int 10' => array('10.0'),
+                       'float as string trailing zeros  would evaluate to int 10' => array('10.00'),
+                       'null' => array(NULL),
+                       'empty array' => array(array()),
+                       'int in array' => array(array(32425)),
+                       'int as string in array' => array(array('32425')),
                );
        }
 
        /**
         * @test
+        * @dataProvider functionTestIntInvalidDataProvider
         */
-       public function splitCalcForNumberWithoutOperatorReturnsArrayWithPlusAndNumber() {
-               $this->assertEquals(
-                       array(array('+', 42)),
-                       t3lib_div::splitCalc('42', '+-*/')
+       public function testIntReturnsFalse($int) {
+               $this->assertFalse(t3lib_div::testInt($int));
+       }
+
+
+       ///////////////////////////////
+       // Tests concerning isFirstPartOfStr
+       ///////////////////////////////
+
+       /**
+        * Data provider for isFirstPartOfStrReturnsTrueForMatchingFirstParts
+        *
+        * @return array
+        */
+       public function isFirstPartOfStrReturnsTrueForMatchingFirstPartDataProvider() {
+               return array(
+                       'match first part of string' => array('hello world', 'hello'),
+                       'match whole string' => array('hello', 'hello'),
+                       'integer is part of string with same number' => array('24', 24),
+                       'string is part of integer with same number' => array(24, '24'),
+                       'integer is part of string starting with same number' => array('24 beer please', 24),
                );
        }
 
        /**
         * @test
+        * @dataProvider isFirstPartOfStrReturnsTrueForMatchingFirstPartDataProvider
         */
-       public function splitCalcForTwoNumbersWithAsterikReturnsFirstNumberWithPlusAndSecondNumberWithOperator() {
-               $this->assertEquals(
-                       array(
-                               array('+', 42),
-                               array('*', 31),
+       public function isFirstPartOfStrReturnsTrueForMatchingFirstPart($string, $part) {
+               $this->assertTrue(t3lib_div::isFirstPartOfStr($string, $part));
+       }
+
+       /**
+        * Data provider for checkIsFirstPartOfStrReturnsFalseForNotMatchingFirstParts
+        *
+        * @return array
+        */
+       public function isFirstPartOfStrReturnsFalseForNotMatchingFirstPartDataProvider() {
+               return array(
+                       'no string match' => array('hello', 'bye'),
+                       'no case sensitive string match' => array('hello world', 'Hello'),
+                       'array is not part of string' => array('string', array()),
+                       'string is not part of array' => array(array(), 'string'),
+                       'null is not part of string' => array('string', NULL),
+                       'string is not part of array' => array(NULL, 'string'),
+                       'null is not part of array' => array(array(), NULL),
+                       'array is not part of string' => array(NULL, array()),
+                       'empty string is not part of empty string' => array('', ''),
+                       'null is not part of empty string' => array('', NULL),
+                       'false is not part of empty string' => array('', FALSE),
+                       'empty string is not part of null' => array(NULL, ''),
+                       'empty string is not part of false' => array(FALSE, ''),
+                       'empty string is not part of zero integer' => array(0, ''),
+                       'zero integer is not part of null' => array(NULL, 0),
+                       'zero integer is not part of empty string' => array('', 0),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider isFirstPartOfStrReturnsFalseForNotMatchingFirstPartDataProvider
+        */
+       public function isFirstPartOfStrReturnsFalseForNotMatchingFirstPart($string, $part) {
+               $this->assertFalse(t3lib_div::isFirstPartOfStr($string, $part));
+       }
+
+
+       ///////////////////////////////
+       // Tests concerning splitCalc
+       ///////////////////////////////
+
+       /**
+        * Data provider for splitCalc
+        *
+        * @return array expected values, arithmetic expression
+        */
+       public function splitCalcDataProvider() {
+               return array(
+                       'empty string returns empty array' => array(
+                               array(),
+                               '',
+                       ),
+                       'number without operator returns array with plus and number' => array(
+                               array(array('+', 42)),
+                               '42',
+                       ),
+                       'two numbers with asterisk return first number with plus and second number with asterisk' => array(
+                               array(array('+', 42), array('*', 31)),
+                               '42 * 31',
                        ),
-                       t3lib_div::splitCalc('42 * 31', '+-*/')
                );
        }
 
+       /**
+        * @test
+        * @dataProvider splitCalcDataProvider
+        */
+       public function splitCalcCorrectlySplitsExpression($expected, $expression) {
+               $this->assertEquals($expected, t3lib_div::splitCalc($expression, '+-*/'));
+       }
+
 
        //////////////////////////////////
        // Tests concerning calcPriority
        //////////////////////////////////
 
        /**
-        * @see calcPriorityCalculatesBasicArithmeticOperation
+        * Data provider for calcPriority
+        *
+        * @return array expected values, arithmetic expression
         */
-       public function calcPriorityTwoOperandsDataProvider() {
+       public function calcPriorityDataProvider() {
                return array(
                        'add' => array(9, '6 + 3'),
-                       'substractWithPositiveResult' => array(3, '6 - 3'),
-                       'substractWithNegativeResult' => array(-3, '3 - 6'),
+                       'substract with positive result' => array(3, '6 - 3'),
+                       'substract with negative result' => array(-3, '3 - 6'),
                        'multiply' => array(6, '2 * 3'),
                        'divide' => array(2.5, '5 / 2'),
                        'modulus' => array(1, '5 % 2'),
                        'power' => array(8, '2 ^ 3'),
+                       'three operands with non integer result' => array(6.5, '5 + 3 / 2'),
+                       'three operands with power' => array(14, '5 + 3 ^ 2'),
+                       'three operads with modulus' => array(4, '5 % 2 + 3'),
+                       'four operands' => array(3, '2 + 6 / 2 - 2'),
                );
        }
 
        /**
         * @test
+        * @dataProvider calcPriorityDataProvider
+        */
+       public function calcPriorityCorrectlyCalculatesExpression($expected, $expression) {
+               $this->assertEquals($expected, t3lib_div::calcPriority($expression));
+       }
+
+
+       //////////////////////////////////
+       // Tests concerning calcPriority
+       //////////////////////////////////
+
+       /**
+        * Data provider for valid validEmail's
         *
-        * @dataProvider calcPriorityTwoOperandsDataProvider
+        * @return array Valid email addresses
+        */
+       public function validEmailValidDataProvider() {
+               return array(
+                       'short mail address' => array('a@b.c'),
+                       'simple mail address' => array('test@example.com'),
+                       'uppercase characters' => array('QWERTYUIOPASDFGHJKLZXCVBNM@QWERTYUIOPASDFGHJKLZXCVBNM.NET'),
+                               // Fix / change if TYPO3 php requirement changed: Address ok with 5.2.6 and 5.3.2 but fails with 5.3.0 on windows
+                       // 'equal sign in local part' => array('test=mail@example.com'),
+                       'dash in local part' => array('test-mail@example.com'),
+                       'plus in local part' => array('test+mail@example.com'),
+                               // Fix / change if TYPO3 php requirement changed: Address ok with 5.2.6 and 5.3.2 but fails with 5.3.0 on windows
+                       // 'question mark in local part' => array('test?mail@example.com'),
+                       'slash in local part' => array('foo/bar@example.com'),
+                       'hash in local part' => array('foo#bar@example.com'),
+                               // Fix / change if TYPO3 php requirement changed: Address ok with 5.2.6 and 5.3.2 but fails with 5.3.0 on windows
+                       // 'dot in local part' => array('firstname.lastname@employee.2something.com'),
+                               // Fix / change if TYPO3 php requirement changed: Address ok with 5.2.6, but not ok with 5.3.2
+                       // 'dash as local part' => array('-@foo.com'),
+               );
+       }
+
+       /**
+        * @test
+        * @dataProvider validEmailValidDataProvider
+        */
+       public function validEmailReturnsTrueForValidMailAddress($address) {
+               $this->assertTrue(t3lib_div::validEmail($address));
+       }
+
+       /**
+        * Data provider for invalid validEmail's
         *
-        * @param string $expected the expected value from calcPriority
-        * @param string $arithmeticExpression the string to feed to calcPriority
+        * @return array Invalid email addresses
         */
-       public function calcPriorityCalculatesBasicArithmeticOperation($expected, $arithmeticExpression) {
-               $this->assertEquals(
-                       $expected,
-                       t3lib_div::calcPriority($arithmeticExpression)
+       public function validEmailInvalidDataProvider() {
+               return array(
+                       '@ sign only' => array('@'),
+                       'duplicate @' => array('test@@example.com'),
+                       'duplicate @ combined with further special characters in local part' => array('test!.!@#$%^&*@example.com'),
+                       'opening parenthesis in local part' => array('foo(bar@example.com'),
+                       'closing parenthesis in local part' => array('foo)bar@example.com'),
+                       'opening square bracket in local part' => array('foo[bar@example.com'),
+                       'closing square bracket as local part' => array(']@example.com'),
+                               // Fix / change if TYPO3 php requirement changed: Address ok with 5.2.6, but not ok with 5.3.2
+                       // 'top level domain only' => array('test@com'),
+                       'dash as second level domain' => array('foo@-.com'),
+                       'domain part starting with dash' => array('foo@-foo.com'),
+                       'domain part ending with dash' => array('foo@foo-.com'),
+                       'number as top level domain' => array('foo@bar.123'),
+                               // Fix / change if TYPO3 php requirement changed: Address not ok with 5.2.6, but ok with 5.3.2 (?)
+                       // 'dash as top level domain' => array('foo@bar.-'),
+                       'dot at beginning of domain part' => array('test@.com'),
+                               // Fix / change if TYPO3 php requirement changed: Address ok with 5.2.6, but not ok with 5.3.2
+                       // 'local part ends with dot' => array('e.x.a.m.p.l.e.@example.com'),
+                       'trailing whitespace' => array('test@example.com '),
+                       'trailing carriage return' => array('test@example.com' . CR),
+                       'trailing linefeed' => array('test@example.com' . LF),
+                       'trailing carriage return linefeed' => array('test@example.com' . CRLF),
+                       'trailing tab' => array('test@example.com' . TAB),
                );
        }
 
        /**
         * @test
+        * @dataProvider validEmailInvalidDataProvider
         */
-       public function calcPriorityCalculatesArithmeticOperationWithMultipleOperands() {
-               $this->assertEquals(6.5, t3lib_div::calcPriority('5 + 3 / 2'));
-               $this->assertEquals(14, t3lib_div::calcPriority('5 + 3 ^ 2'));
-               $this->assertEquals(4, t3lib_div::calcPriority('5 % 2 + 3'));
-               $this->assertEquals(3, t3lib_div::calcPriority('2 + 6 / 2 - 2'));
+       public function validEmailReturnsFalseForInvalidMailAddress($address) {
+               $this->assertFalse(t3lib_div::validEmail($address));
        }
 
+
+       //////////////////////////////////
+       // Tests concerning intExplode
+       //////////////////////////////////
+
        /**
         * @test
         */
-       public function checkIntExplodeConvertsStringsToInteger() {
+       public function intExplodeConvertsStringsToInteger() {
                $testString = '1,foo,2';
                $expectedArray = array(1, 0, 2);
                $actualArray = t3lib_div::intExplode(',', $testString);
@@ -207,10 +526,15 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $this->assertEquals($expectedArray, $actualArray);
        }
 
+
+       //////////////////////////////////
+       // Tests concerning revExplode
+       //////////////////////////////////
+
        /**
         * @test
         */
-       public function checkRevExplodeCorrectlyExplodesString() {
+       public function revExplodeExplodesString() {
                $testString = 'my:words:here';
                $expectedArray = array('my:words', 'here');
                $actualArray = t3lib_div::revExplode(':', $testString, 2);
@@ -218,6 +542,11 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $this->assertEquals($expectedArray, $actualArray);
        }
 
+
+       //////////////////////////////////
+       // Tests concerning trimExplode
+       //////////////////////////////////
+
        /**
         * @test
         */
@@ -235,7 +564,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        public function checkTrimExplodeRemovesNewLines() {
                $testString = ' a , b , ' . LF . ' ,d ,,  e,f,';
                $expectedArray = array('a', 'b', 'd', 'e', 'f');
-               $actualArray = t3lib_div::trimExplode(',', $testString, true);
+               $actualArray = t3lib_div::trimExplode(',', $testString, TRUE);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -246,7 +575,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        public function checkTrimExplodeRemovesEmptyElements() {
                $testString = 'a , b , c , ,d ,, ,e,f,';
                $expectedArray = array('a', 'b', 'c', 'd', 'e', 'f');
-               $actualArray = t3lib_div::trimExplode(',', $testString, true);
+               $actualArray = t3lib_div::trimExplode(',', $testString, TRUE);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -256,8 +585,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
         */
        public function checkTrimExplodeKeepsRemainingResultsWithEmptyItemsAfterReachingLimitWithPositiveParameter() {
                $testString = ' a , b , c , , d,, ,e ';
-               $expectedArray = array('a', 'b', 'c,,d,,,e'); // limiting returns the rest of the string as the last element
-               $actualArray = t3lib_div::trimExplode(',', $testString, false, 3);
+               $expectedArray = array('a', 'b', 'c,,d,,,e');
+                       // Limiting returns the rest of the string as the last element
+               $actualArray = t3lib_div::trimExplode(',', $testString, FALSE, 3);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -267,8 +597,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
         */
        public function checkTrimExplodeKeepsRemainingResultsWithoutEmptyItemsAfterReachingLimitWithPositiveParameter() {
                $testString = ' a , b , c , , d,, ,e ';
-               $expectedArray = array('a', 'b', 'c,d,e'); // limiting returns the rest of the string as the last element
-               $actualArray = t3lib_div::trimExplode(',', $testString, true, 3);
+               $expectedArray = array('a', 'b', 'c,d,e');
+                       // Limiting returns the rest of the string as the last element
+               $actualArray = t3lib_div::trimExplode(',', $testString, TRUE, 3);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -278,8 +609,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
         */
        public function checkTrimExplodeKeepsRamainingResultsWithEmptyItemsAfterReachingLimitWithNegativeParameter() {
                $testString = ' a , b , c , d, ,e, f , , ';
-               $expectedArray = array('a', 'b', 'c', 'd', '', 'e'); // limiting returns the rest of the string as the last element
-               $actualArray = t3lib_div::trimExplode(',', $testString, false, -3);
+               $expectedArray = array('a', 'b', 'c', 'd', '', 'e');
+                       // limiting returns the rest of the string as the last element
+               $actualArray = t3lib_div::trimExplode(',', $testString, FALSE, -3);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -289,8 +621,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
         */
        public function checkTrimExplodeKeepsRamainingResultsWithoutEmptyItemsAfterReachingLimitWithNegativeParameter() {
                $testString = ' a , b , c , d, ,e, f , , ';
-               $expectedArray = array('a', 'b', 'c'); // limiting returns the rest of the string as the last element
-               $actualArray = t3lib_div::trimExplode(',', $testString, true, -3);
+               $expectedArray = array('a', 'b', 'c');
+                       // Limiting returns the rest of the string as the last element
+               $actualArray = t3lib_div::trimExplode(',', $testString, TRUE, -3);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -300,8 +633,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
         */
        public function checkTrimExplodeReturnsExactResultsWithoutReachingLimitWithPositiveParameter() {
                $testString = ' a , b , , c , , , ';
-               $expectedArray = array('a', 'b', 'c'); // limiting returns the rest of the string as the last element
-               $actualArray = t3lib_div::trimExplode(',', $testString, true, 4);
+               $expectedArray = array('a', 'b', 'c');
+                       // Limiting returns the rest of the string as the last element
+               $actualArray = t3lib_div::trimExplode(',', $testString, TRUE, 4);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
@@ -312,11 +646,16 @@ class t3lib_divTest extends tx_phpunit_testcase {
        public function checkTrimExplodeKeepsZeroAsString() {
                $testString = 'a , b , c , ,d ,, ,e,f, 0 ,';
                $expectedArray = array('a', 'b', 'c', 'd', 'e', 'f', '0');
-               $actualArray = t3lib_div::trimExplode(',', $testString, true);
+               $actualArray = t3lib_div::trimExplode(',', $testString, TRUE);
 
                $this->assertEquals($expectedArray, $actualArray);
        }
 
+
+       //////////////////////////////////
+       // Tests concerning removeArrayEntryByValue
+       //////////////////////////////////
+
        /**
         * @test
         */
@@ -374,360 +713,411 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $this->assertEquals($expectedResult, $actualResult);
        }
 
+       //////////////////////////////////
+       // Tests concerning getBytesFromSizeMeasurement
+       //////////////////////////////////
+
        /**
-        * Checks whether measurement strings like "100k" return the accordant
-        * byte representation like 102400 in this case.
+        * Data provider for getBytesFromSizeMeasurement
         *
-        * @test
+        * @return array expected value, input string
         */
-       public function checkGetBytesFromSizeMeasurement() {
-               $this->assertEquals(
-                       '102400',
-                       t3lib_div::getBytesFromSizeMeasurement('100k')
-               );
-
-               $this->assertEquals(
-                       '104857600',
-                       t3lib_div::getBytesFromSizeMeasurement('100m')
-               );
-
-               $this->assertEquals(
-                       '107374182400',
-                       t3lib_div::getBytesFromSizeMeasurement('100g')
+       public function getBytesFromSizeMeasurementDataProvider() {
+               return array(
+                       '100 kilo Bytes' => array('102400', '100k'),
+                       '100 mega Bytes' => array('104857600', '100m'),
+                       '100 giga Bytes' => array('107374182400', '100g'),
                );
        }
 
        /**
         * @test
+        * @dataProvider getBytesFromSizeMeasurementDataProvider
         */
-       public function checkIndpEnvTypo3SitePathNotEmpty() {
-               $actualEnv = t3lib_div::getIndpEnv('TYPO3_SITE_PATH');
-               $this->assertTrue(strlen($actualEnv) >= 1);
-               $this->assertEquals('/', $actualEnv{0});
-               $this->assertEquals('/', $actualEnv{strlen($actualEnv) - 1});
+       public function getBytesFromSizeMeasurementCalculatesCorrectByteValue($expected, $byteString) {
+               $this->assertEquals($expected, t3lib_div::getBytesFromSizeMeasurement($byteString));
        }
 
-       /**
-        * @test
-        * @see t3lib_div::underscoredToUpperCamelCase
-        */
-       public function canConvertFromUnderscoredToUpperCamelCase() {
-               $this->assertEquals('BlogExample', t3lib_div::underscoredToUpperCamelCase('blog_example'));
-               $this->assertEquals('Blogexample', t3lib_div::underscoredToUpperCamelCase('blogexample'));
-       }
+
+       //////////////////////////////////
+       // Tests concerning getIndpEnv
+       //////////////////////////////////
 
        /**
         * @test
-        * @see t3lib_div::underscoredToLowerCamelCase
         */
-       public function canConvertFromUnderscoredToLowerCamelCase() {
-               $this->assertEquals('minimalValue', t3lib_div::underscoredToLowerCamelCase('minimal_value'));
-               $this->assertEquals('minimalvalue', t3lib_div::underscoredToLowerCamelCase('minimalvalue'));
+       public function getIndpEnvTypo3SitePathReturnNonEmptyString() {
+               $this->assertTrue(strlen(t3lib_div::getIndpEnv('TYPO3_SITE_PATH')) >= 1);
        }
 
        /**
         * @test
-        * @see t3lib_div::camelCaseToLowerCaseUnderscored
         */
-       public function canConvertFromCamelCaseToLowerCaseUnderscored() {
-               $this->assertEquals('blog_example', t3lib_div::camelCaseToLowerCaseUnderscored('BlogExample'));
-               $this->assertEquals('blogexample', t3lib_div::camelCaseToLowerCaseUnderscored('Blogexample'));
-               $this->assertEquals('blogexample', t3lib_div::camelCaseToLowerCaseUnderscored('blogexample'));
-
-               $this->assertEquals('minimal_value', t3lib_div::camelCaseToLowerCaseUnderscored('minimalValue'));
+       public function getIndpEnvTypo3SitePathReturnsStringStartingWithSlash() {
+               $result = t3lib_div::getIndpEnv('TYPO3_SITE_PATH');
+               $this->assertEquals('/', $result[0]);
        }
 
        /**
         * @test
-        * @see t3lib_div::lcfirst
         */
-       public function canConvertFirstCharacterToBeLowerCase() {
-               $this->assertEquals('blogexample', t3lib_div::lcfirst('Blogexample'));
-               $this->assertEquals('blogExample', t3lib_div::lcfirst('BlogExample'));
-               $this->assertEquals('blogexample', t3lib_div::lcfirst('blogexample'));
+       public function getIndpEnvTypo3SitePathReturnsStringEndingWithSlash() {
+               $result = t3lib_div::getIndpEnv('TYPO3_SITE_PATH');
+               $this->assertEquals('/', $result[strlen($result) - 1]);
        }
 
        /**
-        * Tests whether whitespaces are encoded correctly in a quoted-printable mail header.
-        * @test
+        * @return array
         */
-       public function areWhitespacesEncodedInQuotedPrintableMailHeader() {
-               $this->assertEquals(
-                       '=?utf-8?Q?We_test_whether_the_copyright_character_=C2=A9_is_encoded_correctly?=',
-                       t3lib_div::encodeHeader(
-                               "We test whether the copyright character \xc2\xa9 is encoded correctly",
-                               'quoted-printable',
-                               'utf-8'
-                       )
+       public static function hostnameAndPortDataProvider() {
+               return array(
+                       'localhost ipv4 without port' => array('127.0.0.1', '127.0.0.1', ''),
+                       'localhost ipv4 with port' => array('127.0.0.1:81', '127.0.0.1', '81'),
+                       'localhost ipv6 without port' => array('[::1]', '[::1]', ''),
+                       'localhost ipv6 with port' => array('[::1]:81', '[::1]', '81'),
+                       'ipv6 without port' => array('[2001:DB8::1]', '[2001:DB8::1]', ''),
+                       'ipv6 with port' => array('[2001:DB8::1]:81', '[2001:DB8::1]', '81'),
+                       'hostname without port' => array('lolli.did.this', 'lolli.did.this', ''),
+                       'hostname with port' => array('lolli.did.this:42', 'lolli.did.this', '42'),
                );
        }
 
        /**
-        * Tests whether question marks are encoded correctly in a quoted-printable mail header.
         * @test
+        * @dataProvider hostnameAndPortDataProvider
         */
-       public function areQuestionMarksEncodedInQuotedPrintableMailHeader() {
-               $this->assertEquals(
-                       '=?utf-8?Q?Is_the_copyright_character_=C2=A9_really_encoded_correctly=3F_Really=3F?=',
-                       t3lib_div::encodeHeader(
-                               "Is the copyright character \xc2\xa9 really encoded correctly? Really?",
-                               'quoted-printable',
-                               'utf-8'
-                       )
-               );
+       public function getIndpEnvTypo3HostOnlyParsesHostnamesAndIpAdresses($httpHost, $expectedIp) {
+               $_SERVER['HTTP_HOST'] = $httpHost;
+               $this->assertEquals($expectedIp, t3lib_div::getIndpEnv('TYPO3_HOST_ONLY'));
        }
 
        /**
-        * Data provider for valid URLs, like PHP's source code test cases
+        * @test
+        * @dataProvider hostnameAndPortDataProvider
         */
-       public function validUrlDataProvider() {
-               return array(
-                       array('http://example.com/index.html'),
-                       array('http://www.example.com/index.php'),
-                       array('http://www.example/img/test.png'),
-                       array('http://www.example/img/dir/'),
-                       array('http://www.example/img/dir'),
-                       array('file:///tmp/test.c'),
-                       array('ftp://ftp.example.com/tmp/'),
-                       array('mailto:foo@bar.com'),
-                       array('news:news.php.net'),
-                       array('file://foo/bar'),
-                       array('http://qwe'),
-               );
+       public function getIndpEnvTypo3PortParsesHostnamesAndIpAdresses($httpHost, $dummy, $expectedPort) {
+               $_SERVER['HTTP_HOST'] = $httpHost;
+               $this->assertEquals($expectedPort, t3lib_div::getIndpEnv('TYPO3_PORT'));
        }
 
+
+       //////////////////////////////////
+       // Tests concerning underscoredToUpperCamelCase
+       //////////////////////////////////
+
        /**
-        * Data provider for invalid URLs, like PHP's source code test cases
+        * Data provider for underscoredToUpperCamelCase
+        *
+        * @return array expected, input string
         */
-       public function invalidUrlDataProvider() {
+       public function underscoredToUpperCamelCaseDataProvider() {
                return array(
-                       array('http//www.example/wrong/url/'),
-                       array('http:/www.example'),
-                       array('/tmp/test.c'),
-                       array('/'),
-                       array('http://'),
-                       array('http:/'),
-                       array('http:'),
-                       array('http'),
-                       array(''),
-                       array('-1'),
-                       array('array()'),
-                       array('qwe'),
+                       'single word' => array('Blogexample', 'blogexample'),
+                       'multiple words' => array('BlogExample', 'blog_example'),
                );
        }
 
        /**
         * @test
-        * @dataProvider validUrlDataProvider
-        * @see t3lib_div::isValidUrl()
+        * @dataProvider underscoredToUpperCamelCaseDataProvider
         */
-       public function checkisValidURL($url) {
-               $this->assertTrue(t3lib_div::isValidUrl($url));
+       public function underscoredToUpperCamelCase($expected, $inputString) {
+               $this->assertEquals($expected, t3lib_div::underscoredToUpperCamelCase($inputString));
        }
 
-       /**
-        * @test
-        * @dataProvider invalidUrlDataProvider
-        * @see t3lib_div::isValidUrl()
-        */
-       public function checkisInValidURL($url) {
-               $this->assertFalse(t3lib_div::isValidUrl($url));
-       }
+
+       //////////////////////////////////
+       // Tests concerning underscoredToLowerCamelCase
+       //////////////////////////////////
 
        /**
-        * @test
-        * @see t3lib_div::isValidUrl()
+        * Data provider for underscoredToLowerCamelCase
+        *
+        * @return array expected, input string
         */
-       public function checkisValidURLSucceedsWithWebRessource() {
-               $testUrl = 'http://www.example.org/';
-               $this->assertTrue(t3lib_div::isValidUrl($testUrl));
+       public function underscoredToLowerCamelCaseDataProvider() {
+               return array(
+                       'single word' => array('minimalvalue', 'minimalvalue'),
+                       'multiple words' => array('minimalValue', 'minimal_value'),
+               );
        }
 
        /**
         * @test
-        * @see t3lib_div::isValidUrl()
+        * @dataProvider underscoredToLowerCamelCaseDataProvider
         */
-       public function checkisValidURLSucceedsWithExtentedWebRessource() {
-               $testUrl = 'https://user:pw@www.example.org:80/path?arg=value#fragment';
-               $this->assertTrue(t3lib_div::isValidUrl($testUrl));
+       public function underscoredToLowerCamelCase($expected, $inputString) {
+               $this->assertEquals($expected, t3lib_div::underscoredToLowerCamelCase($inputString));
        }
 
+       //////////////////////////////////
+       // Tests concerning camelCaseToLowerCaseUnderscored
+       //////////////////////////////////
+
        /**
-        * @test
-        * @see t3lib_div::isValidUrl()
+        * Data provider for camelCaseToLowerCaseUnderscored
+        *
+        * @return array expected, input string
         */
-       public function checkisValidURLSucceedsWithTelnetRessource() {
-               $testUrl = 'telnet://192.0.2.16:80/';
-               $this->assertTrue(t3lib_div::isValidUrl($testUrl));
+       public function camelCaseToLowerCaseUnderscoredDataProvider() {
+               return array(
+                       'single word' => array('blogexample', 'blogexample'),
+                       'single word starting upper case' => array('blogexample', 'Blogexample'),
+                       'two words starting lower case' => array('minimal_value', 'minimalValue'),
+                       'two words starting upper case' => array('blog_example', 'BlogExample'),
+               );
        }
 
        /**
         * @test
+        * @dataProvider camelCaseToLowerCaseUnderscoredDataProvider
         */
-       public function checkisValidURLSucceedsWithLdapRessource() {
-               $testUrl = 'ldap://[2001:db8::7]/c=GB?objectClass?one';
-               $this->assertTrue(t3lib_div::isValidUrl($testUrl));
+       public function camelCaseToLowerCaseUnderscored($expected, $inputString) {
+               $this->assertEquals($expected, t3lib_div::camelCaseToLowerCaseUnderscored($inputString));
        }
 
+
+       //////////////////////////////////
+       // Tests concerning lcFirst
+       //////////////////////////////////
+
        /**
-        * @test
-        * @see t3lib_div::isValidUrl()
+        * Data provider for lcFirst
+        *
+        * @return array expected, input string
         */
-       public function checkisValidURLSucceedsWithFileRessource() {
-               $testUrl = 'file:///etc/passwd';
-               $this->assertTrue(t3lib_div::isValidUrl($testUrl));
+       public function lcfirstDataProvider() {
+               return array(
+                       'single word' => array('blogexample', 'blogexample'),
+                       'single Word starting upper case' => array('blogexample', 'Blogexample'),
+                       'two words' => array('blogExample', 'BlogExample'),
+               );
        }
 
        /**
         * @test
-        * @see t3lib_div::isValidUrl()
+        * @dataProvider lcfirstDataProvider
         */
-       public function checkisValidURLFailsWithHostnameOnly() {
-               $testUrl = 'www.example.org/';
-               $this->assertFalse(t3lib_div::isValidUrl($testUrl));
+       public function lcFirst($expected, $inputString) {
+               $this->assertEquals($expected, t3lib_div::lcfirst($inputString));
        }
 
+
+       //////////////////////////////////
+       // Tests concerning encodeHeader
+       //////////////////////////////////
+
        /**
         * @test
-        * @see t3lib_div::isOnCurrentHost()
         */
-       public function checkisOnCurrentHostFailsWithLocalhostIPOnly() {
-               $testUrl = '127.0.0.1';
-               $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
+       public function encodeHeaderEncodesWhitespacesInQuotedPrintableMailHeader() {
+               $this->assertEquals(
+                       '=?utf-8?Q?We_test_whether_the_copyright_character_=C2=A9_is_encoded_correctly?=',
+                       t3lib_div::encodeHeader(
+                               "We test whether the copyright character \xc2\xa9 is encoded correctly",
+                               'quoted-printable',
+                               'utf-8'
+                       )
+               );
        }
 
        /**
         * @test
-        * @see t3lib_div::isOnCurrentHost()
         */
-       public function checkisOnCurrentHostFailsWithPathsOnly() {
-               $testUrl = './relpath/file.txt';
-               $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
-               $testUrl = '/abspath/file.txt?arg=value';
-               $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
+       public function encodeHeaderEncodesQuestionmarksInQuotedPrintableMailHeader() {
+               $this->assertEquals(
+                       '=?utf-8?Q?Is_the_copyright_character_=C2=A9_really_encoded_correctly=3F_Really=3F?=',
+                       t3lib_div::encodeHeader(
+                               "Is the copyright character \xc2\xa9 really encoded correctly? Really?",
+                               'quoted-printable',
+                               'utf-8'
+                       )
+               );
        }
 
+
+       //////////////////////////////////
+       // Tests concerning isValidUrl
+       //////////////////////////////////
+
        /**
-        * @test
-        * @see t3lib_div::isOnCurrentHost()
+        * Data provider for valid isValidUrl's
+        *
+        * @return array Valid ressource
         */
-       public function checkisOnCurrentHostFailsWithArbitraryString() {
-               $testUrl = 'arbitrary string';
-               $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
+       public function validUrlValidRessourceDataProvider() {
+               return array(
+                       'http' => array('http://www.example.org/'),
+                       'http without trailing slash' => array('http://qwe'),
+                       'http directory with trailing slash' => array('http://www.example/img/dir/'),
+                       'http directory without trailing slash' => array('http://www.example/img/dir'),
+                       'http index.html' => array('http://example.com/index.html'),
+                       'http index.php' => array('http://www.example.com/index.php'),
+                       'http test.png' => array('http://www.example/img/test.png'),
+                       'http username password querystring and ancher' => array('https://user:pw@www.example.org:80/path?arg=value#fragment'),
+                       'file' => array('file:///tmp/test.c'),
+                       'file directory' => array('file://foo/bar'),
+                       'ftp directory' => array('ftp://ftp.example.com/tmp/'),
+                       'mailto' => array('mailto:foo@bar.com'),
+                       'news' => array('news:news.php.net'),
+                       'telnet'=> array('telnet://192.0.2.16:80/'),
+                       'ldap' => array('ldap://[2001:db8::7]/c=GB?objectClass?one'),
+               );
        }
 
        /**
         * @test
-        * @see t3lib_div::isOnCurrentHost()
+        * @dataProvider validUrlValidRessourceDataProvider
         */
-       public function checkisOnCurrentHostFailsWithEmptyUrl() {
-               $testUrl = '';
-               $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
+       public function validURLReturnsTrueForValidRessource($url) {
+               $this->assertTrue(t3lib_div::isValidUrl($url));
+       }
+
+       /**
+        * Data provider for invalid isValidUrl's
+        *
+        * @return array Invalid ressource
+        */
+       public function isValidUrlInvalidRessourceDataProvider() {
+               return array(
+                       'http missing colon' => array('http//www.example/wrong/url/'),
+                       'http missing slash' => array('http:/www.example'),
+                       'hostname only' => array('www.example.org/'),
+                       'file missing protocol specification' => array('/tmp/test.c'),
+                       'slash only' => array('/'),
+                       'string http://' => array('http://'),
+                       'string http:/' => array('http:/'),
+                       'string http:' => array('http:'),
+                       'string http' => array('http'),
+                       'empty string' => array(''),
+                       'string -1' => array('-1'),
+                       'string array()' => array('array()'),
+                       'random string' => array('qwe'),
+               );
        }
 
        /**
         * @test
-        * @see t3lib_div::isOnCurrentHost()
+        * @dataProvider isValidUrlInvalidRessourceDataProvider
         */
-       public function checkisOnCurrentHostFailsWithDifferentHost() {
-               $testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org';
-               $this->assertFalse(t3lib_div::isOnCurrentHost($testUrl));
+       public function validURLReturnsFalseForInvalidRessoure($url) {
+               $this->assertFalse(t3lib_div::isValidUrl($url));
        }
 
+
+       //////////////////////////////////
+       // Tests concerning isOnCurrentHost
+       //////////////////////////////////
+
        /**
         * @test
-        * @see t3lib_div::isOnCurrentHost()
         */
-       public function checkisOnCurrentHostSucceedsWithCurrentHost() {
+       public function isOnCurrentHostReturnsTrueWithCurrentHost() {
                $testUrl = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL');
                $this->assertTrue(t3lib_div::isOnCurrentHost($testUrl));
        }
 
-
-       ////////////////////////////////////////
-       // Tests concerning sanitizeLocalUrl
-       ////////////////////////////////////////
-
        /**
-        * Data provider for valid URLs.
-        * @see sanitizeLocalUrlAcceptsValidUrls
+        * Data provider for invalid isOnCurrentHost's
+        *
+        * @return array Invalid Hosts
         */
-       public function validLocalUrlDataProvider() {
+       public function checkisOnCurrentHostInvalidHosts() {
                return array(
-                       array('alt_intro.php'),
-                       array('alt_intro.php?foo=1&bar=2'),
-                       array('/typo3/alt_intro.php'),
-                       array('/index.php'),
-                       array('../index.php'),
-                       array('../typo3/alt_intro.php'),
-                       array('../~userDirectory/index.php'),
-                       array('../typo3/mod.php?var1=test-case&var2=~user'),
-                       array(PATH_site . 'typo3/alt_intro.php'),
-                       array(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . 'typo3/alt_intro.php'),
-                       array(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '/index.php'),
+                       'empty string' => array(''),
+                       'arbitrary string' => array('arbitrary string'),
+                       'localhost IP' => array('127.0.0.1'),
+                       'relative path' => array('./relpath/file.txt'),
+                       'absolute path' => array('/abspath/file.txt?arg=value'),
+                       'differnt host' => array(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST') . '.example.org'),
                );
        }
 
+
+       ////////////////////////////////////////
+       // Tests concerning sanitizeLocalUrl
+       ////////////////////////////////////////
+
        /**
-        * Data provider for invalid URLs.
-        * @see sanitizeLocalUrlDeniesInvalidUrls
+        * Data provider for valid sanitizeLocalUrl's
+        *
+        * @return array Valid url
         */
-       public function invalidLocalUrlDataProvider() {
+       public function sanitizeLocalUrlValidUrlDataProvider() {
+               $subDirectory = t3lib_div::getIndpEnv('TYPO3_SITE_PATH');
+               $typo3SiteUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
+               $typo3RequestHost = t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST');
+
                return array(
-                       array(''),
-                       array('http://www.google.de/'),
-                       array('https://www.google.de/'),
-                       array('../typo3/whatever.php?argument=javascript:alert(0)'),
+                       'alt_intro.php' => array('alt_intro.php'),
+                       'alt_intro.php?foo=1&bar=2' => array('alt_intro.php?foo=1&bar=2'),
+                       $subDirectory . 'typo3/alt_intro.php' => array($subDirectory . 'typo3/alt_intro.php'),
+                       $subDirectory . 'index.php' => array($subDirectory . 'index.php'),
+                       '../index.php' => array('../index.php'),
+                       '../typo3/alt_intro.php' => array('../typo3/alt_intro.php'),
+                       '../~userDirectory/index.php' => array('../~userDirectory/index.php'),
+                       '../typo3/mod.php?var1=test-case&var2=~user' => array('../typo3/mod.php?var1=test-case&var2=~user'),
+                       PATH_site . 'typo3/alt_intro.php' => array(PATH_site . 'typo3/alt_intro.php'),
+                       $typo3SiteUrl . 'typo3/alt_intro.php' => array($typo3SiteUrl . 'typo3/alt_intro.php'),
+                       $typo3RequestHost . $subDirectory . '/index.php' => array($typo3RequestHost . $subDirectory . '/index.php'),
                );
        }
 
        /**
-        * Tests whether valid local URLs are handled correctly.
-        * @dataProvider        validLocalUrlDataProvider
         * @test
+        * @dataProvider sanitizeLocalUrlValidUrlDataProvider
         */
-       public function sanitizeLocalUrlAcceptsPlainValidUrls($url) {
+       public function sanitizeLocalUrlAcceptsNotEncodedValidUrls($url) {
                $this->assertEquals($url, t3lib_div::sanitizeLocalUrl($url));
        }
 
        /**
-        * Tests whether valid local URLs are handled correctly.
-        * @dataProvider        validLocalUrlDataProvider
         * @test
+        * @dataProvider sanitizeLocalUrlValidUrlDataProvider
         */
        public function sanitizeLocalUrlAcceptsEncodedValidUrls($url) {
                $this->assertEquals(rawurlencode($url), t3lib_div::sanitizeLocalUrl(rawurlencode($url)));
        }
 
        /**
-        * Tests whether valid local URLs are handled correctly.
-        * @dataProvider        invalidLocalUrlDataProvider
+        * Data provider for invalid sanitizeLocalUrl's
+        *
+        * @return array Valid url
+        */
+       public function sanitizeLocalUrlInvalidDataProvider() {
+               return array(
+                       'empty string' => array(''),
+                       'http domain' => array('http://www.google.de/'),
+                       'https domain' => array('https://www.google.de/'),
+                       'relative path with XSS' => array('../typo3/whatever.php?argument=javascript:alert(0)'),
+               );
+       }
+
+       /**
         * @test
+        * @dataProvider sanitizeLocalUrlInvalidDataProvider
         */
        public function sanitizeLocalUrlDeniesPlainInvalidUrls($url) {
                $this->assertEquals('', t3lib_div::sanitizeLocalUrl($url));
        }
 
        /**
-        * Tests whether valid local URLs are handled correctly.
-        * @dataProvider        invalidLocalUrlDataProvider
         * @test
+        * @dataProvider sanitizeLocalUrlInvalidDataProvider
         */
        public function sanitizeLocalUrlDeniesEncodedInvalidUrls($url) {
                $this->assertEquals('', t3lib_div::sanitizeLocalUrl(rawurlencode($url)));
        }
 
+
        //////////////////////////////////////
        // Tests concerning arrayDiffAssocRecursive
        //////////////////////////////////////
 
        /**
-        * Test if a one dimensional array is correctly diffed.
-        *
         * @test
-        * @see t3lib_div::arrayDiffAssocRecursive
         */
-       public function doesArrayDiffAssocRecursiveCorrectlyHandleOneDimensionalArrays() {
+       public function arrayDiffAssocRecursiveHandlesOneDimensionalArrays() {
                $array1 = array(
                        'key1' => 'value1',
                        'key2' => 'value2',
@@ -745,12 +1135,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Test if a three dimensional array is correctly diffed.
-        *
         * @test
-        * @see t3lib_div::arrayDiffAssocRecursive
         */
-       public function doesArrayDiffAssocRecursiveCorrectlyHandleMultiDimensionalArrays() {
+       public function arrayDiffAssocRecursiveHandlesMultiDimensionalArrays() {
                $array1 = array(
                        'key1' => 'value1',
                        'key2' => array(
@@ -784,12 +1171,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Test if arrays are correctly diffed if types are different.
-        *
         * @test
-        * @see t3lib_div::arrayDiffAssocRecursive
         */
-       public function doesArrayDiffAssocRecursiveCorrectlyHandleMixedArrays() {
+       public function arrayDiffAssocRecursiveHandlesMixedArrays() {
                $array1 = array(
                        'key1' => array(
                                'key11' => 'value11',
@@ -811,16 +1195,15 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $this->assertEquals($expectedResult, $actualResult);
        }
 
+
        //////////////////////////////////////
        // Tests concerning removeDotsFromTS
        //////////////////////////////////////
 
        /**
-        * Tests whether removeDotsFromTS() behaves correctly.
         * @test
-        * @see t3lib_div::removeDotsFromTS()
         */
-       public function doesRemoveDotsFromTypoScriptSucceed() {
+       public function removeDotsFromTypoScriptSucceedsWithDottedArray() {
                $typoScript = array(
                        'propertyA.' => array(
                                'keyA.' => array(
@@ -845,11 +1228,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Tests whether removeDotsFromTS() behaves correctly.
         * @test
-        * @see t3lib_div::removeDotsFromTS()
         */
-       public function doesRemoveDotsFromTypoScriptCorrectlyOverrideWithArray() {
+       public function removeDotsFromTypoScriptOverridesSubArray() {
                $typoScript = array(
                        'propertyA.' => array(
                                'keyA' => 'getsOverridden',
@@ -875,11 +1256,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Tests whether removeDotsFromTS() behaves correctly.
         * @test
-        * @see t3lib_div::removeDotsFromTS()
         */
-       public function doesRemoveDotsFromTypoScriptCorrectlyOverrideWithScalar() {
+       public function removeDotsFromTypoScriptOverridesWithScalar() {
                $typoScript = array(
                        'propertyA.' => array(
                                'keyA.' => array(
@@ -902,12 +1281,15 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $this->assertEquals($expectedResult, t3lib_div::removeDotsFromTS($typoScript));
        }
 
+
+       //////////////////////////////////////
+       // Tests concerning get_dirs
+       //////////////////////////////////////
+
        /**
-        * Tests whether getDirs() returns an array of diretories from a given path
         * @test
-        * @see t3lib_div::getDirs($path)
         */
-       public function checkGetDirsReturnsArrayOfDirectoriesFromGivenDirectory() {
+       public function getDirsReturnsArrayOfDirectoriesFromGivenDirectory() {
                $path = PATH_t3lib;
                $directories = t3lib_div::get_dirs($path);
 
@@ -915,11 +1297,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Tests whether getDirs() returns the string 'error' in case of problems reading from the given path
         * @test
-        * @see t3lib_div::getDirs($path)
         */
-       public function checkGetDirsReturnsStringErrorOnPathFailure() {
+       public function getDirsReturnsStringErrorOnPathFailure() {
                $path = 'foo';
                $result = t3lib_div::get_dirs($path);
                $expectedResult = 'error';
@@ -953,7 +1333,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function hmacReturnsNotEqualHashesForNotEqualInput() {
+       public function hmacReturnsNoEqualHashesForNonEqualInput() {
                $msg0 = 'message0';
                $msg1 = 'message1';
                $this->assertNotEquals(t3lib_div::hmac($msg0), t3lib_div::hmac($msg1));
@@ -1084,11 +1464,14 @@ class t3lib_divTest extends tx_phpunit_testcase {
                );
        }
 
+       //////////////////////////////////
+       // Tests concerning readLLfile
+       //////////////////////////////////
+
        /**
-        * Tests the locallangXMLOverride feature of readLLfile()
         * @test
         */
-       public function readLLfileLocallangXMLOverride() {
+       public function readLLfileHandlesLocallangXMLOverride() {
                $unique = uniqid('locallangXMLOverrideTest');
 
                $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
@@ -1103,20 +1486,21 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $file = PATH_site . 'typo3temp/' . $unique . '.xml';
                t3lib_div::writeFileToTypo3tempDir($file, $xml);
 
-                       // get default value
+                       // Get default value
                $defaultLL = t3lib_div::readLLfile('EXT:lang/locallang_core.xml', 'default');
 
-                       // set override file
+                       // Set override file
                $GLOBALS['TYPO3_CONF_VARS']['SYS']['locallangXMLOverride']['EXT:lang/locallang_core.xml'][$unique] = $file;
 
-                       // get override value
+                       // Get override value
                $overrideLL = t3lib_div::readLLfile('EXT:lang/locallang_core.xml', 'default');
 
+                       // Clean up again
+               unlink($file);
+
                $this->assertNotEquals($overrideLL['default']['buttons.logout'], '');
                $this->assertNotEquals($defaultLL['default']['buttons.logout'], $overrideLL['default']['buttons.logout']);
                $this->assertEquals($overrideLL['default']['buttons.logout'], 'EXIT');
-
-               unlink($file);
        }
 
 
@@ -1127,19 +1511,25 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function getSetCanSetWholeArray() {
+       public function getSetWritesArrayToGetSystemVariable() {
                $_GET = array();
                $GLOBALS['HTTP_GET_VARS'] = array();
-               t3lib_div::_GETset(array('oneKey' => 'oneValue'));
 
-               $this->assertEquals(
-                       array('oneKey' => 'oneValue'),
-                       $_GET
-               );
-               $this->assertEquals(
-                       array('oneKey' => 'oneValue'),
-                       $GLOBALS['HTTP_GET_VARS']
-               );
+               $getParameters = array('foo' => 'bar');
+               t3lib_div::_GETset($getParameters);
+               $this->assertSame($getParameters, $_GET);
+       }
+
+       /**
+        * @test
+        */
+       public function getSetWritesArrayToGlobalsHttpGetVars() {
+               $_GET = array();
+               $GLOBALS['HTTP_GET_VARS'] = array();
+
+               $getParameters = array('foo' => 'bar');
+               t3lib_div::_GETset($getParameters);
+               $this->assertSame($getParameters, $GLOBALS['HTTP_GET_VARS']);
        }
 
        /**
@@ -1150,14 +1540,11 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $GLOBALS['HTTP_GET_VARS'] = array();
 
                t3lib_div::_GETset(array('foo' => 'bar'));
+
                t3lib_div::_GETset(array('oneKey' => 'oneValue'));
 
                $this->assertEquals(
                        array('oneKey' => 'oneValue'),
-                       $_GET
-               );
-               $this->assertEquals(
-                       array('oneKey' => 'oneValue'),
                        $GLOBALS['HTTP_GET_VARS']
                );
        }
@@ -1165,7 +1552,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function getSetCanAssignOneValueToOneKey() {
+       public function getSetAssignsOneValueToOneKey() {
                $_GET = array();
                $GLOBALS['HTTP_GET_VARS'] = array();
 
@@ -1173,10 +1560,6 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                $this->assertEquals(
                        'oneValue',
-                       $_GET['oneKey']
-               );
-               $this->assertEquals(
-                       'oneValue',
                        $GLOBALS['HTTP_GET_VARS']['oneKey']
                );
        }
@@ -1184,7 +1567,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function getSetForOneValueNotDropsExistingValues() {
+       public function getSetForOneValueDoesNotDropUnrelatedValues() {
                $_GET = array();
                $GLOBALS['HTTP_GET_VARS'] = array();
 
@@ -1193,10 +1576,6 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                $this->assertEquals(
                        array('foo' => 'bar', 'oneKey' => 'oneValue'),
-                       $_GET
-               );
-               $this->assertEquals(
-                       array('foo' => 'bar', 'oneKey' => 'oneValue'),
                        $GLOBALS['HTTP_GET_VARS']
                );
        }
@@ -1204,7 +1583,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function getSetCanAssignAnArrayToSpecificArrayElement() {
+       public function getSetCanAssignsAnArrayToASpecificArrayElement() {
                $_GET = array();
                $GLOBALS['HTTP_GET_VARS'] = array();
 
@@ -1212,10 +1591,6 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                $this->assertEquals(
                        array('parentKey' => array('childKey' => 'oneValue')),
-                       $_GET
-               );
-               $this->assertEquals(
-                       array('parentKey' => array('childKey' => 'oneValue')),
                        $GLOBALS['HTTP_GET_VARS']
                );
        }
@@ -1223,7 +1598,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function getSetCanAssignAValueToSpecificArrayChildElement() {
+       public function getSetCanAssignAStringValueToASpecificArrayChildElement() {
                $_GET = array();
                $GLOBALS['HTTP_GET_VARS'] = array();
 
@@ -1231,10 +1606,6 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                $this->assertEquals(
                        array('parentKey' => array('childKey' => 'oneValue')),
-                       $_GET
-               );
-               $this->assertEquals(
-                       array('parentKey' => array('childKey' => 'oneValue')),
                        $GLOBALS['HTTP_GET_VARS']
                );
        }
@@ -1242,7 +1613,7 @@ class t3lib_divTest extends tx_phpunit_testcase {
        /**
         * @test
         */
-       public function getSetCanAssignAnArrayToSpecificArrayChildElement() {
+       public function getSetCanAssignAnArrayToASpecificArrayChildElement() {
                $_GET = array();
                $GLOBALS['HTTP_GET_VARS'] = array();
 
@@ -1257,27 +1628,45 @@ class t3lib_divTest extends tx_phpunit_testcase {
                                        'childKey' => array('key1' => 'value1', 'key2' => 'value2')
                                )
                        ),
-                       $_GET
-               );
-               $this->assertEquals(
-                       array(
-                               'parentKey' => array(
-                                       'childKey' => array('key1' => 'value1', 'key2' => 'value2')
-                               )
-                       ),
                        $GLOBALS['HTTP_GET_VARS']
                );
        }
 
+
+       ///////////////////////////////
+       // Tests concerning fixPermissions
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function fixPermissionsCorrectlySetsGroup() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('fixPermissionsCorrectlySetsGroupOwnerOfFile() tests not available on Windows');
+               }
+               if (!function_exists('posix_getegid')) {
+                       $this->markTestSkipped('Function posix_getegid() not available, fixPermissionsCorrectlySetsGroupOwnerOfFile() tests skipped');
+               }
+
+                       // Create and prepare test file
+               $filename = PATH_site . 'typo3temp/' . uniqid('test_');
+               t3lib_div::writeFileToTypo3tempDir($filename, '42');
+
+                       // Set target group and run method
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
+               $fixPermissionsResult = t3lib_div::fixPermissions($filename);
+
+               clearstatcache();
+               $resultFileGroup = filegroup($filename);
+               unlink($filename);
+
+               $this->assertEquals($resultFileGroup, posix_getegid());
+       }
+
        /**
-        * Checks if t3lib_div::fixPermissions() correctly sets permissions to single file
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        * This test is not available on windows OS
-        *
         * @test
-        * @see t3lib_div::fixPermissions()
         */
-       public function checkFixPermissionsCorrectlySetsPermissionsToFile() {
+       public function fixPermissionsCorrectlySetsPermissionsToFile() {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('fixPermissions() tests not available on Windows');
                }
@@ -1289,30 +1678,22 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($filename);
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
-               $resultFileGroup = filegroup($filename);
                unlink($filename);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultFilePermissions, '0660');
-               $this->assertEquals($resultFileGroup, posix_getegid());
        }
 
        /**
-        * Checks if t3lib_div::fixPermissions() correctly sets permissions to hidden file
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        * This test is not available on windows OS
-        *
         * @test
-        * @see t3lib_div::fixPermissions()
         */
-       public function checkFixPermissionsCorrectlySetsPermissionsToHiddenFile() {
+       public function fixPermissionsCorrectlySetsPermissionsToHiddenFile() {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('fixPermissions() tests not available on Windows');
                }
@@ -1324,30 +1705,22 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($filename);
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultFilePermissions = substr(decoct(fileperms($filename)), 2);
-               $resultFileGroup = filegroup($filename);
                unlink($filename);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultFilePermissions, '0660');
-               $this->assertEquals($resultFileGroup, posix_getegid());
        }
 
        /**
-        * Checks if t3lib_div::fixPermissions() correctly sets permissions to directory with trailing slash
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        * This test is not available on windows OS
-        *
         * @test
-        * @see t3lib_div::fixPermissions()
         */
-       public function checkFixPermissionsCorrectlySetsPermissionsToDirectory() {
+       public function fixPermissionsCorrectlySetsPermissionsToDirectory() {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('fixPermissions() tests not available on Windows');
                }
@@ -1359,30 +1732,22 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($directory . '/');
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
-               $resultDirectoryGroup = filegroup($directory);
                t3lib_div::rmdir($directory);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultDirectoryPermissions, '0770');
-               $this->assertEquals($resultDirectoryGroup, posix_getegid());
        }
 
        /**
-        * Checks if t3lib_div::fixPermissions() correctly sets permissions to hidden directory
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        * This test is not available on windows OS
-        *
         * @test
-        * @see t3lib_div::fixPermissions()
         */
-       public function checkFixPermissionsCorrectlySetsPermissionsToHiddenDirectory() {
+       public function fixPermissionsCorrectlySetsPermissionsToHiddenDirectory() {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('fixPermissions() tests not available on Windows');
                }
@@ -1394,30 +1759,22 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($directory);
 
                        // Get actual permissions and clean up
                clearstatcache();
                $resultDirectoryPermissions = substr(decoct(fileperms($directory)), 1);
-               $resultDirectoryGroup = filegroup($directory);
                t3lib_div::rmdir($directory);
 
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultDirectoryPermissions, '0770');
-               $this->assertEquals($resultDirectoryGroup, posix_getegid());
        }
 
        /**
-        * Checks if t3lib_div::fixPermissions() correctly sets permissions recursivly
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        * This test is not available on windows OS
-        *
         * @test
-        * @see t3lib_div::fixPermissions()
         */
-       public function checkFixPermissionsCorrectlySetsPermissionsRecursive() {
+       public function fixPermissionsCorrectlySetsPermissionsRecursive() {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('fixPermissions() tests not available on Windows');
                }
@@ -1445,25 +1802,17 @@ class t3lib_divTest extends tx_phpunit_testcase {
                        // Set target permissions and run method
                $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
                $GLOBALS['TYPO3_CONF_VARS']['BE']['folderCreateMask'] = '0770';
-               $GLOBALS['TYPO3_CONF_VARS']['BE']['createGroup'] = posix_getegid();
                $fixPermissionsResult = t3lib_div::fixPermissions($baseDirectory, TRUE);
 
                        // Get actual permissions
                clearstatcache();
                $resultBaseDirectoryPermissions = substr(decoct(fileperms($baseDirectory)), 1);
-               $resultBaseDirectoryGroup = filegroup($baseDirectory);
                $resultBaseFilePermissions = substr(decoct(fileperms($baseDirectory . '/file')), 2);
-               $resultBaseFileGroup = filegroup($baseDirectory . '/file');
                $resultFooDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/foo')), 1);
-               $resultFooDirectoryGroup = filegroup($baseDirectory . '/foo');
                $resultFooFilePermissions = substr(decoct(fileperms($baseDirectory . '/foo/file')), 2);
-               $resultFooFileGroup = filegroup($baseDirectory . '/foo/file');
                $resultBarDirectoryPermissions = substr(decoct(fileperms($baseDirectory . '/.bar')), 1);
-               $resultBarDirectoryGroup = filegroup($baseDirectory . '/.bar');
                $resultBarFilePermissions = substr(decoct(fileperms($baseDirectory . '/.bar/.file')), 2);
-               $resultBarFileGroup = filegroup($baseDirectory . '/.bar/.file');
                $resultBarFile2Permissions = substr(decoct(fileperms($baseDirectory . '/.bar/..file2')), 2);
-               $resultBarFile2Group = filegroup($baseDirectory . '/.bar/..file2');
 
                        // Clean up
                unlink($baseDirectory . '/file');
@@ -1477,30 +1826,18 @@ class t3lib_divTest extends tx_phpunit_testcase {
                        // Test if everything was ok
                $this->assertTrue($fixPermissionsResult);
                $this->assertEquals($resultBaseDirectoryPermissions, '0770');
-               $this->assertEquals($resultBaseDirectoryGroup, posix_getegid());
                $this->assertEquals($resultBaseFilePermissions, '0660');
-               $this->assertEquals($resultBaseFileGroup, posix_getegid());
                $this->assertEquals($resultFooDirectoryPermissions, '0770');
-               $this->assertEquals($resultFooDirectoryGroup, posix_getegid());
                $this->assertEquals($resultFooFilePermissions, '0660');
-               $this->assertEquals($resultFooFileGroup, posix_getegid());
                $this->assertEquals($resultBarDirectoryPermissions, '0770');
-               $this->assertEquals($resultBarDirectoryGroup, posix_getegid());
                $this->assertEquals($resultBarFilePermissions, '0660');
-               $this->assertEquals($resultBarFileGroup, posix_getegid());
                $this->assertEquals($resultBarFile2Permissions, '0660');
-               $this->assertEquals($resultBarFile2Group, posix_getegid());
        }
 
        /**
-        * Checks if t3lib_div::fixPermissions() does not fix permissions on not allowed path
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        * This test is not available on windows OS
-        *
         * @test
-        * @see t3lib_div::fixPermissions()
         */
-       public function checkFixPermissionsDoesNotSetPermissionsToNotAllowedPath() {
+       public function fixPermissionsDoesNotSetPermissionsToNotAllowedPath() {
                if (TYPO3_OS == 'WIN') {
                        $this->markTestSkipped('fixPermissions() tests not available on Windows');
                }
@@ -1521,17 +1858,43 @@ class t3lib_divTest extends tx_phpunit_testcase {
 
                        // Test if everything was ok
                $this->assertFalse($fixPermissionsResult);
-               $this->assertEquals($resultFilePermissions, '0742');
        }
 
        /**
-        * Checks if t3lib_div::mkdir() correctly creates a directory
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        *
         * @test
-        * @see t3lib_div::mkdir()
         */
-       public function checkMkdirCorrectlyCreatesDirectory() {
+       public function fixPermissionsSetsPermissionsWithRelativeFileReference() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('fixPermissions() tests not available on Windows');
+               }
+
+               $filename = 'typo3temp/' . uniqid('test_');
+               t3lib_div::writeFileToTypo3tempDir(PATH_site . $filename, '42');
+               chmod($filename, 0742);
+
+                       // Set target permissions and run method
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0660';
+               $fixPermissionsResult = t3lib_div::fixPermissions($filename);
+
+                       // Get actual permissions and clean up
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms(PATH_site . $filename)), 2);
+               unlink(PATH_site . $filename);
+
+                       // Test if everything was ok
+               $this->assertTrue($fixPermissionsResult);
+               $this->assertEquals($resultFilePermissions, '0660');
+       }
+
+
+       ///////////////////////////////
+       // Tests concerning mkdir
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function mkdirCorrectlyCreatesDirectory() {
                $directory = PATH_site . 'typo3temp/' . uniqid('test_');
                $mkdirResult = t3lib_div::mkdir($directory);
                $directoryCreated = is_dir($directory);
@@ -1541,13 +1904,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Checks if t3lib_div::mkdir() correctly creates a hidden directory
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        *
         * @test
-        * @see t3lib_div::mkdir()
         */
-       public function checkMkdirCorrectlyCreatesHiddenDirectory() {
+       public function mkdirCorrectlyCreatesHiddenDirectory() {
                $directory = PATH_site . 'typo3temp/' . uniqid('.test_');
                $mkdirResult = t3lib_div::mkdir($directory);
                $directoryCreated = is_dir($directory);
@@ -1557,13 +1916,9 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Checks if t3lib_div::mkdir() correctly creates a directory with trailing slash
-        * This test assumes directory 'PATH_site'/typo3temp exists
-        *
         * @test
-        * @see t3lib_div::mkdir()
         */
-       public function checkMkdirCorrectlyCreatesDirectoryWithTrailingSlash() {
+       public function mkdirCorrectlyCreatesDirectoryWithTrailingSlash() {
                $directory = PATH_site . 'typo3temp/' . uniqid('test_');
                $mkdirResult = t3lib_div::mkdir($directory);
                $directoryCreated = is_dir($directory);
@@ -1573,14 +1928,184 @@ class t3lib_divTest extends tx_phpunit_testcase {
        }
 
        /**
-        * Checks if t3lib_div::split_fileref() return NO file extension if incomming $fileref is a folder
-        * This test avoid bug #0014845: Filelist module reports "type" of files also for directories
-        * This test assumes directory 'PATH_site'/typo3temp exists
+        * Data provider for ImageMagick shell commands
+        * @see explodeAndUnquoteImageMagickCommands
+        */
+       public function imageMagickCommandsDataProvider() {
+               return array(
+                       // Some theoretical tests first
+                       array(
+                               'aa bb "cc" "dd"',
+                               array('aa', 'bb', '"cc"', '"dd"'),
+                               array('aa', 'bb', 'cc', 'dd'),
+                       ),
+                       array(
+                               'aa bb "cc dd"',
+                               array('aa', 'bb', '"cc dd"'),
+                               array('aa', 'bb', 'cc dd'),
+                       ),
+                       array(
+                               '\'aa bb\' "cc dd"',
+                               array('\'aa bb\'', '"cc dd"'),
+                               array('aa bb', 'cc dd'),
+                       ),
+                       array(
+                               '\'aa bb\' cc "dd"',
+                               array('\'aa bb\'', 'cc', '"dd"'),
+                               array('aa bb', 'cc', 'dd'),
+                       ),
+                       // Now test against some real world examples
+                       array(
+                               '/opt/local/bin/gm.exe convert +profile \'*\' -geometry 170x136!  -negate "C:/Users/Someuser.Domain/Documents/Htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]" "C:/Users/Someuser.Domain/Documents/Htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"',
+                               array(
+                                       '/opt/local/bin/gm.exe',
+                                       'convert',
+                                       '+profile',
+                                       '\'*\'',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '"C:/Users/Someuser.Domain/Documents/Htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]"',
+                                       '"C:/Users/Someuser.Domain/Documents/Htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"'
+                               ),
+                               array(
+                                       '/opt/local/bin/gm.exe',
+                                       'convert',
+                                       '+profile',
+                                       '*',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       'C:/Users/Someuser.Domain/Documents/Htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]',
+                                       'C:/Users/Someuser.Domain/Documents/Htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif'
+                               ),
+                       ),
+                       array(
+                               'C:/opt/local/bin/gm.exe convert +profile \'*\' -geometry 170x136!  -negate "C:/Program Files/Apache2/htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]" "C:/Program Files/Apache2/htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"',
+                               array(
+                                       'C:/opt/local/bin/gm.exe',
+                                       'convert',
+                                       '+profile',
+                                       '\'*\'',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '"C:/Program Files/Apache2/htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]"',
+                                       '"C:/Program Files/Apache2/htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"'
+                               ),
+                               array(
+                                       'C:/opt/local/bin/gm.exe',
+                                       'convert',
+                                       '+profile',
+                                       '*',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       'C:/Program Files/Apache2/htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]',
+                                       'C:/Program Files/Apache2/htdocs/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif'
+                               ),
+                       ),
+                       array(
+                               '/usr/bin/gm convert +profile \'*\' -geometry 170x136!  -negate "/Shared Items/Data/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]" "/Shared Items/Data/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"',
+                               array(
+                                       '/usr/bin/gm',
+                                       'convert',
+                                       '+profile',
+                                       '\'*\'',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '"/Shared Items/Data/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]"',
+                                       '"/Shared Items/Data/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"'
+                               ),
+                               array(
+                                       '/usr/bin/gm',
+                                       'convert',
+                                       '+profile',
+                                       '*',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '/Shared Items/Data/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]',
+                                       '/Shared Items/Data/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif'
+                               ),
+                       ),
+                       array(
+                               '/usr/bin/gm convert +profile \'*\' -geometry 170x136!  -negate "/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]" "/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"',
+                               array(
+                                       '/usr/bin/gm',
+                                       'convert',
+                                       '+profile',
+                                       '\'*\'',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '"/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]"',
+                                       '"/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif"'
+                               ),
+                               array(
+                                       '/usr/bin/gm',
+                                       'convert',
+                                       '+profile',
+                                       '*',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]',
+                                       '/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif'
+                               ),
+                       ),
+                       array(
+                               '/usr/bin/gm convert +profile \'*\' -geometry 170x136!  -negate \'/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]\' \'/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif\'',
+                               array(
+                                       '/usr/bin/gm',
+                                       'convert',
+                                       '+profile',
+                                       '\'*\'',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '\'/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]\'',
+                                       '\'/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif\''
+                               ),
+                               array(
+                                       '/usr/bin/gm',
+                                       'convert',
+                                       '+profile',
+                                       '*',
+                                       '-geometry',
+                                       '170x136!',
+                                       '-negate',
+                                       '/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif[0]',
+                                       '/Network/Servers/server01.internal/Projects/typo3temp/temp/61401f5c16c63d58e1d92e8a2449f2fe_maskNT.gif'
+                               ),
+                       ),
+               );
+       }
+
+       /**
+        * Tests if the commands are exploded and unquoted correctly
         *
+        * @dataProvider        imageMagickCommandsDataProvider
         * @test
-        * @see t3lib_div::split_fileref()
         */
-       public function checkIfSplitFileRefReturnsFileTypeNotForFolders(){
+       public function explodeAndUnquoteImageMagickCommands($source, $expectedQuoted, $expectedUnquoted) {
+               $actualQuoted   = t3lib_div::unQuoteFilenames($source);
+               $acutalUnquoted = t3lib_div::unQuoteFilenames($source, TRUE);
+
+               $this->assertEquals($expectedQuoted, $actualQuoted, 'The exploded command does not match the expected');
+               $this->assertEquals($expectedUnquoted, $acutalUnquoted, 'The exploded and unquoted command does not match the expected');
+       }
+
+
+       ///////////////////////////////
+       // Tests concerning split_fileref
+       ///////////////////////////////
+
+       /**
+        * @test
+        */
+       public function splitFileRefReturnsFileTypeNotForFolders(){
                $directoryName = uniqid('test_') . '.com';
                $directoryPath = PATH_site . 'typo3temp/';
                $directory = $directoryPath . $directoryName;
@@ -1589,23 +2114,21 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $fileInfo = t3lib_div::split_fileref($directory);
 
                $directoryCreated = is_dir($directory);
-               $this->assertTrue($directoryCreated);
+               rmdir($directory);
 
+               $this->assertTrue($directoryCreated);
                $this->assertType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $fileInfo);
                $this->assertEquals($directoryPath, $fileInfo['path']);
                $this->assertEquals($directoryName, $fileInfo['file']);
                $this->assertEquals($directoryName, $fileInfo['filebody']);
                $this->assertEquals('', $fileInfo['fileext']);
                $this->assertArrayNotHasKey('realFileext', $fileInfo);
-
-               rmdir($directory);
        }
 
        /**
         * @test
-        * @see t3lib_div::split_fileref()
         */
-       public function checkIfSplitFileRefReturnsFileTypeForFilesWithoutPathSite() {
+       public function splitFileRefReturnsFileTypeForFilesWithoutPathSite() {
                $testFile = 'fileadmin/media/someFile.png';
 
                $fileInfo = t3lib_div::split_fileref($testFile);
@@ -1615,5 +2138,380 @@ class t3lib_divTest extends tx_phpunit_testcase {
                $this->assertEquals('someFile', $fileInfo['filebody']);
                $this->assertEquals('png', $fileInfo['fileext']);
        }
+
+
+       /////////////////////////////
+       // Tests concerning dirname
+       /////////////////////////////
+
+       /**
+        * @see dirnameWithDataProvider
+        *
+        * @return array<array>
+        */
+       public function dirnameDataProvider() {
+               return array(
+                       'absolute path with multiple part and file' => array('/dir1/dir2/script.php', '/dir1/dir2'),
+                       'absolute path with one part' => array('/dir1/', '/dir1'),
+                       'absolute path to file without extension' => array('/dir1/something', '/dir1'),
+                       'relative path with one part and file' => array('dir1/script.php', 'dir1'),
+                       'relative one-character path with one part and file' => array('d/script.php', 'd'),
+                       'absolute zero-part path with file' => array('/script.php', ''),
+                       'empty string' => array('', ''),
+               );
+       }
+
+       /**
+        * @test
+        *
+        * @dataProvider dirnameDataProvider
+        *
+        * @param string $input the input for dirname
+        * @param string $expectedValue the expected return value expected from dirname
+        */
+       public function dirnameWithDataProvider($input, $expectedValue) {
+               $this->assertEquals(
+                       $expectedValue,
+                       t3lib_div::dirname($input)
+               );
+       }
+
+
+       /////////////////////////////////////////////////////////////////////////////////////
+       // Tests concerning makeInstance, setSingletonInstance, addInstance, purgeInstances
+       /////////////////////////////////////////////////////////////////////////////////////
+
+       /**
+        * @test
+        *
+        * @expectedException InvalidArgumentException
+        */
+       public function makeInstanceWithEmptyClassNameThrowsException() {
+               t3lib_div::makeInstance('');
+       }
+
+       /**
+        * @test
+        */
+       public function makeInstanceReturnsClassInstance() {
+               $className = get_class($this->getMock('foo'));
+
+               $this->assertTrue(
+                       t3lib_div::makeInstance($className) instanceof $className
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function makeInstancePassesParametersToConstructor() {
+               $className = 'testingClass' . uniqid();
+               if (!class_exists($className, FALSE)) {
+                       eval(
+                               'class ' . $className . ' {' .
+                               '  public $constructorParameter1;' .
+                               '  public $constructorParameter2;' .
+                               '  public function __construct($parameter1, $parameter2) {' .
+                               '    $this->constructorParameter1 = $parameter1;' .
+                               '    $this->constructorParameter2 = $parameter2;' .
+                               '  }' .
+                               '}'
+                       );
+               }
+
+               $instance = t3lib_div::makeInstance($className, 'one parameter', 'another parameter');
+
+               $this->assertEquals(
+                       'one parameter',
+                       $instance->constructorParameter1,
+                       'The first constructor parameter has not been set.'
+               );
+               $this->assertEquals(
+                       'another parameter',
+                       $instance->constructorParameter2,
+                       'The second constructor parameter has not been set.'
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function makeInstanceCalledTwoTimesForNonSingletonClassReturnsDifferentInstances() {
+               $className = get_class($this->getMock('foo'));
+
+               $this->assertNotSame(
+                       t3lib_div::makeInstance($className),
+                       t3lib_div::makeInstance($className)
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function makeInstanceCalledTwoTimesForSingletonClassReturnsSameInstance() {
+               $className = get_class($this->getMock('t3lib_Singleton'));
+
+               $this->assertSame(
+                       t3lib_div::makeInstance($className),
+                       t3lib_div::makeInstance($className)
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function makeInstanceCalledTwoTimesForSingletonClassWithPurgeInstancesInbetweenReturnsDifferentInstances() {
+               $className = get_class($this->getMock('t3lib_Singleton'));
+
+               $instance = t3lib_div::makeInstance($className);
+               t3lib_div::purgeInstances();
+
+               $this->assertNotSame(
+                       $instance,
+                       t3lib_div::makeInstance($className)
+               );
+       }
+
+       /**
+        * @test
+        * @expectedException InvalidArgumentException
+        */
+       public function setSingletonInstanceForEmptyClassNameThrowsException() {
+               $instance = $this->getMock('t3lib_Singleton');
+
+               t3lib_div::setSingletonInstance('', $instance);
+       }
+
+       /**
+        * @test
+        * @expectedException InvalidArgumentException
+        */
+       public function setSingletonInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException() {
+               $instance = $this->getMock('t3lib_Singleton', array('foo'));
+               $singletonClassName = get_class($this->getMock('t3lib_Singleton'));
+
+               t3lib_div::setSingletonInstance($singletonClassName, $instance);
+       }
+
+       /**
+        * @test
+        */
+       public function setSingletonInstanceMakesMakeInstanceReturnThatInstance() {
+               $instance = $this->getMock('t3lib_Singleton');
+               $singletonClassName = get_class($instance);
+
+               t3lib_div::setSingletonInstance($singletonClassName, $instance);
+
+               $this->assertSame(
+                       $instance,
+                       t3lib_div::makeInstance($singletonClassName)
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function setSingletonInstanceCalledTwoTimesMakesMakeInstanceReturnLastSetInstance() {
+               $instance1 = $this->getMock('t3lib_Singleton');
+               $singletonClassName = get_class($instance1);
+               $instance2 = new $singletonClassName();
+
+               t3lib_div::setSingletonInstance($singletonClassName, $instance1);
+               t3lib_div::setSingletonInstance($singletonClassName, $instance2);
+
+               $this->assertSame(
+                       $instance2,
+                       t3lib_div::makeInstance($singletonClassName)
+               );
+       }
+
+       /**
+        * @test
+        * @expectedException InvalidArgumentException
+        */
+       public function addInstanceForEmptyClassNameThrowsException() {
+               $instance = $this->getMock('foo');
+
+               t3lib_div::addInstance('', $instance);
+       }
+
+       /**
+        * @test
+        * @expectedException InvalidArgumentException
+        */
+       public function addInstanceForClassThatIsNoSubclassOfProvidedClassThrowsException() {
+               $instance = $this->getMock('foo', array('bar'));
+               $singletonClassName = get_class($this->getMock('foo'));
+
+               t3lib_div::addInstance($singletonClassName, $instance);
+       }
+
+       /**
+        * @test
+        * @expectedException InvalidArgumentException
+        */
+       public function addInstanceWithSingletonInstanceThrowsException() {
+               $instance = $this->getMock('t3lib_Singleton');
+
+               t3lib_div::addInstance(get_class($instance), $instance);
+       }
+
+       /**
+        * @test
+        */
+       public function addInstanceMakesMakeInstanceReturnThatInstance() {
+               $instance = $this->getMock('foo');
+               $className = get_class($instance);
+
+               t3lib_div::addInstance($className, $instance);
+
+               $this->assertSame(
+                       $instance,
+                       t3lib_div::makeInstance($className)
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function makeInstanceCalledTwoTimesAfterAddInstanceReturnTwoDifferentInstances() {
+               $instance = $this->getMock('foo');
+               $className = get_class($instance);
+
+               t3lib_div::addInstance($className, $instance);
+
+               $this->assertNotSame(
+                       t3lib_div::makeInstance($className),
+                       t3lib_div::makeInstance($className)
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function addInstanceCalledTwoTimesMakesMakeInstanceReturnBothInstancesInAddingOrder() {
+               $instance1 = $this->getMock('foo');
+               $className = get_class($instance1);
+               t3lib_div::addInstance($className, $instance1);
+
+               $instance2 = new $className();
+               t3lib_div::addInstance($className, $instance2);
+
+               $this->assertSame(
+                       $instance1,
+                       t3lib_div::makeInstance($className),
+                       'The first returned instance does not match the first added instance.'
+               );
+               $this->assertSame(
+                       $instance2,
+                       t3lib_div::makeInstance($className),
+                       'The second returned instance does not match the second added instance.'
+               );
+       }
+
+       /**
+        * @test
+        */
+       public function purgeInstancesDropsAddedInstance() {
+               $instance = $this->getMock('foo');
+               $className = get_class($instance);
+
+               t3lib_div::addInstance($className, $instance);
+               t3lib_div::purgeInstances();
+
+               $this->assertNotSame(
+                       $instance,
+                       t3lib_div::makeInstance($className)
+               );
+       }
+
+       /**
+        * Data provider for validPathStrDetectsInvalidCharacters.
+        *
+        * @return array
+        */
+       public function validPathStrInvalidCharactersDataProvider() {
+               return array(
+                       'double slash in path' => array('path//path'),
+                       'backslash in path' => array('path\\path'),
+                       'directory up in path' => array('path/../path'),
+                       'directory up at the beginning' => array('../path'),
+                       'NUL character in path' => array("path\x00path"),
+                       'BS character in path' => array("path\x08path"),
+               );
+       }
+
+       /**
+        * Tests whether invalid characters are detected.
+        *
+        * @param string $path
+        * @dataProvider validPathStrInvalidCharactersDataProvider
+        * @test
+        */
+       public function validPathStrDetectsInvalidCharacters($path) {
+               $this->assertNull(t3lib_div::validPathStr($path));
+       }
+
+       /**
+        * Tests whether verifyFilenameAgainstDenyPattern detects the null character.
+        *
+        * @test
+        */
+       public function verifyFilenameAgainstDenyPatternDetectsNullCharacter() {
+               $this->assertFalse(t3lib_div::verifyFilenameAgainstDenyPattern("image\x00.gif"));
+       }
+
+
+       /////////////////////////////////////////////////////////////////////////////////////
+       // Tests concerning sysLog
+       /////////////////////////////////////////////////////////////////////////////////////
+
+       /**
+        * @test
+        */
+       public function syslogFixesPermissionsOnFileIfUsingFileLogging() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('syslogFixesPermissionsOnFileIfUsingFileLogging() test not available on Windows.');
+               }
+
+                       // Fake all required settings
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel'] = 0;
+               $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit'] = TRUE;
+               unset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']);
+               $testLogFilename = PATH_site . 'typo3temp/' . uniqid('test_') . '.txt';
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'] = 'file,' . $testLogFilename . ',0';
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
+
+                       // Call method, get actual permissions and clean up
+               t3lib_div::syslog('testLog', 'test', 1);
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms($testLogFilename)), 2);
+               t3lib_div::unlink_tempfile($testLogFilename);
+
+               $this->assertEquals($resultFilePermissions, '0777');
+       }
+
+       /**
+        * @test
+        */
+       public function deprecationLogFixesPermissionsOnLogFile() {
+               if (TYPO3_OS == 'WIN') {
+                       $this->markTestSkipped('deprecationLogFixesPermissionsOnLogFile() test not available on Windows.');
+               }
+
+                       // Fake all required settings and get an unique logfilename
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = uniqid('test_');
+               $deprecationLogFilename = t3lib_div::getDeprecationLogFileName();
+               $GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog'] = TRUE;
+               $GLOBALS['TYPO3_CONF_VARS']['BE']['fileCreateMask'] = '0777';
+
+                       // Call method, get actual permissions and clean up
+               t3lib_div::deprecationLog('foo');
+               clearstatcache();
+               $resultFilePermissions = substr(decoct(fileperms($deprecationLogFilename)), 2);
+               @unlink($deprecationLogFilename);
+
+               $this->assertEquals($resultFilePermissions, '0777');
+       }
 }
-?>
\ No newline at end of file
+?>