[BUGFIX] Do not append a "/" to the folder identifier 71/39371/11
authorSascha Egerer <sascha@sascha-egerer.de>
Fri, 8 May 2015 19:09:50 +0000 (21:09 +0200)
committerJigal van Hemert <jigal.van.hemert@typo3.org>
Mon, 18 Apr 2016 12:46:10 +0000 (14:46 +0200)
When creating a folder object the identifier is suffixed with a '/'
automatically which does not make sense when using a non hierarchical
filesystem.
The identifier must not be modified by the Folder constructor.

Resolves: #66861
Related: #65305
Releases: master, 7.6
Change-Id: I9b02767d124a7502f4170cb39a7df3dcff27fe3c
Reviewed-on: https://review.typo3.org/39371
Reviewed-by: Frans Saris <franssaris@gmail.com>
Tested-by: Frans Saris <franssaris@gmail.com>
Reviewed-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
Tested-by: Jigal van Hemert <jigal.van.hemert@typo3.org>
typo3/sysext/core/Classes/Resource/Folder.php
typo3/sysext/core/Tests/Unit/Resource/FolderTest.php
typo3/sysext/core/Tests/Unit/Resource/ResourceFactoryTest.php

index 8714c0d..da091e6 100644 (file)
@@ -81,7 +81,7 @@ class Folder implements FolderInterface
     public function __construct(ResourceStorage $storage, $identifier, $name)
     {
         $this->storage = $storage;
-        $this->identifier = rtrim($identifier, '/') . '/';
+        $this->identifier = $identifier;
         $this->name = $name;
     }
 
index 0a84a7f..321d7e6 100644 (file)
@@ -140,6 +140,33 @@ class FolderTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
     /**
      * @test
      */
+    public function getSubfolderCallsFactoryWithCorrectArguments()
+    {
+        $mockedStorage = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class, array(), array(), '', false);
+        $mockedStorage->expects($this->once())->method('hasFolderInFolder')->with($this->equalTo('someSubfolder'))->will($this->returnValue(true));
+        /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Resource\ResourceFactory $mockedFactory */
+        $mockedFactory = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceFactory::class);
+        $folderFixture = $this->createFolderFixture(
+            '/somePath/someFolder/',
+            'someFolder',
+            $mockedStorage
+        );
+        $subfolderFixture = $this->createFolderFixture(
+            '/somePath/someSubfolder/',
+            'someSubfolder',
+            $mockedStorage
+        );
+        $mockedStorage->expects($this->once())->method('getFolderInFolder')->will($this->returnValue($subfolderFixture));
+        \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(
+            \TYPO3\CMS\Core\Resource\ResourceFactory::class,
+            $mockedFactory
+        );
+        $this->assertEquals($subfolderFixture, $folderFixture->getSubfolder('someSubfolder'));
+    }
+
+    /**
+     * @test
+     */
     public function getParentFolderGetsParentFolderFromStorage()
     {
         $parentIdentifier = '/parent/';
index 0369a49..72280f0 100644 (file)
@@ -62,7 +62,7 @@ class ResourceFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $name = $this->getUniqueId();
         $storageCollection = $this->subject->createFolderObject($mockedMount, $path, $name, 0);
         $this->assertSame($mockedMount, $storageCollection->getStorage());
-        $this->assertEquals($path . '/', $storageCollection->getIdentifier());
+        $this->assertEquals($path, $storageCollection->getIdentifier());
         $this->assertEquals($name, $storageCollection->getName());
     }