Fixed bug #16778: Test failures in t3lib_tree_NodeTest if tests are in typo3_src...
authorSteffen Kamper <info@sk-typo3.de>
Mon, 20 Dec 2010 12:08:14 +0000 (12:08 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Mon, 20 Dec 2010 12:08:14 +0000 (12:08 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9860 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
tests/t3lib/tree/t3lib_tree_nodeTest.php

index bc3c057..c341459 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2010-12-20  Steffen Kamper  <steffen@typo3.org>
 
+       * Fixed bug #16778: Test failures in t3lib_tree_NodeTest if tests are in typo3_src/tests/ instead of tests/ (Thanks to Oliver Klee)
        * Follow-up to #16031: forgotten field recursive for plugins
        * Fixed bug #16780: PHP warning in any system BE module
 
index 3480399..98f1ae3 100644 (file)
  * @subpackage t3lib
  */
 class t3lib_tree_NodeTest extends tx_phpunit_testcase {
-       public function setUp() {
-       }
+       //////////////////////
+       // Utility functions
+       //////////////////////
+
+       /**
+        * Returns the absolute fixtures path for this testcase.
+        *
+        * @return string the absolute fixtures path for this testcase, will not be empty
+        */
+       private function determineFixturesPath() {
+               $possibleFixturesPath1 = PATH_site . 'tests/t3lib/tree/fixtures/';
+               $possibleFixturesPath2 = PATH_site . 'typo3_src/tests/t3lib/tree/fixtures/';
 
-       public function tearDown() {
+               if (file_exists($possibleFixturesPath1)) {
+                       $fixturesPath = $possibleFixturesPath1;
+               } elseif (file_exists($possibleFixturesPath2)) {
+                       $fixturesPath = $possibleFixturesPath2;
+               } else {
+                       $this->fail('The fixtures path could not be determined.');
+               }
+
+               return $fixturesPath;
        }
 
        protected function setUpNodeTestData() {
@@ -67,11 +85,16 @@ class t3lib_tree_NodeTest extends tx_phpunit_testcase {
                return $fixture;
        }
 
+
+       ///////////////
+       // Test cases
+       ///////////////
+
        /**
         * @test
         */
        public function serializeFixture() {
-               $expected = trim(file_get_contents(PATH_site . 'tests/t3lib/tree/fixtures/serialized.txt'));
+               $expected = trim(file_get_contents($this->determineFixturesPath() . 'serialized.txt'));
                $fixture = $this->setUpNodeTestData();
                $serializedString = trim($fixture->serialize());
                $this->assertSame($expected, $serializedString);
@@ -81,8 +104,8 @@ class t3lib_tree_NodeTest extends tx_phpunit_testcase {
         * @test
         */
        public function deserializeFixture() {
-               $source = trim(file_get_contents(PATH_site . 'tests/t3lib/tree/fixtures/serialized.txt'));
-               $node = new t3lib_tree_Node;
+               $source = trim(file_get_contents($this->determineFixturesPath() . 'serialized.txt'));
+               $node = new t3lib_tree_Node();
                $node->unserialize($source);
                $serializedString = $node->serialize();
                $this->assertSame($source, $serializedString);
@@ -105,4 +128,4 @@ class t3lib_tree_NodeTest extends tx_phpunit_testcase {
                $this->assertSame(0, $compareResult);
        }
 }
-?>
+?>
\ No newline at end of file