Fixed bug #15874: Provide unit tests for t3lib_div::dirname (Thanks to Oliver Klee)
authorSteffen Gebert <steffen.gebert@typo3.org>
Tue, 5 Oct 2010 21:06:08 +0000 (21:06 +0000)
committerSteffen Gebert <steffen.gebert@typo3.org>
Tue, 5 Oct 2010 21:06:08 +0000 (21:06 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@8950 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/t3lib_divTest.php

index 3885879..d066e87 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-05  Steffen Gebert  <steffen@steffen-gebert.de>
+
+       * Fixed bug #15874: Provide unit tests for t3lib_div::dirname (Thanks to Oliver Klee)
+
 2010-10-05  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Follow-up to bug #15858: htlmArea RTE: Stylesheet access error in Google Chrome 7
index ddc492d..5497fc6 100644 (file)
@@ -1778,5 +1778,42 @@ 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 with directory without file' => 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)
+               );
+       }
 }
 ?>
\ No newline at end of file