20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
45 protected function setUp()
47 $this->subject = $this->getAccessibleMock(ResourceFactory::class, [
'dummy'], [],
'',
false);
55 foreach ($this->filesCreated as $file) {
69 $mockedMount = $this->createMock(\
TYPO3\CMS\Core\Resource\ResourceStorage::class);
70 $path = $this->getUniqueId();
71 $name = $this->getUniqueId();
72 $storageCollection = $this->subject->createFolderObject($mockedMount, $path, $name, 0);
73 $this->assertSame($mockedMount, $storageCollection->getStorage());
74 $this->assertEquals($path, $storageCollection->getIdentifier());
75 $this->assertEquals($name, $storageCollection->getName());
86 $mockedDriver = $this->getMockForAbstractClass(\
TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class);
87 $driverFixtureClass = get_class($mockedDriver);
88 \TYPO3\CMS\Core\Utility\GeneralUtility::addInstance($driverFixtureClass, $mockedDriver);
89 $mockedRegistry = $this->createMock(\
TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class);
90 $mockedRegistry->expects($this->once())->method(
'getDriverClass')->with($this->equalTo($driverFixtureClass))->will($this->returnValue($driverFixtureClass));
91 \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\
TYPO3\CMS\Core\Resource\Driver\DriverRegistry::class, $mockedRegistry);
92 $obj = $this->subject->getDriverObject($driverFixtureClass, []);
93 $this->assertInstanceOf(\
TYPO3\CMS\Core\Resource\Driver\AbstractDriver::class, $obj);
107 ResourceFactory::class,
108 [
'getFolderObjectFromCombinedIdentifier'],
114 ->expects($this->once())
115 ->method(
'getFolderObjectFromCombinedIdentifier')
127 ResourceFactory::class,
128 [
'getFolderObjectFromCombinedIdentifier'],
134 ->expects($this->once())
135 ->method(
'getFolderObjectFromCombinedIdentifier')
145 $this->subject = $this->getAccessibleMock(ResourceFactory::class, [
'getFileObjectFromCombinedIdentifier'], [],
'',
false);
146 $filename =
'typo3temp/var/tests/4711.txt';
147 $this->subject->expects($this->once())
148 ->method(
'getFileObjectFromCombinedIdentifier')
153 $this->subject->retrieveFileOrFolderObject($filename);
169 $this->subject->_set(
'localDriverStorageCache', $storageConfiguration);
170 $this->assertSame($expectedStorageId, $this->subject->_callRef(
'findBestMatchingStorageByLocalPath', $path));
179 'NoLocalStoragesReturnDefaultStorage' => [
181 'my/dummy/Image.png',
184 'NoMatchReturnsDefaultStorage' => [
185 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'fileadmin2/public/']),
186 'my/dummy/Image.png',
189 'MatchReturnsTheMatch' => [
190 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'other/public/']),
191 'fileadmin/dummy/Image.png',
194 'TwoFoldersWithSameStartReturnsCorrect' => [
195 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'fileadmin/public/']),
196 'fileadmin/dummy/Image.png',
199 'NestedStorageReallyReturnsTheBestMatching' => [
200 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'fileadmin/public/']),
201 'fileadmin/public/Image.png',
204 'CommonPrefixButWrongPath' => [
205 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'uploads/test/']),
206 'uploads/bogus/dummy.png',
209 'CommonPrefixRightPath' => [
210 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'uploads/test/']),
211 'uploads/test/dummy.png',
214 'FindStorageFromWindowsPath' => [
215 array_map([$this,
'asRelativePath'], [1 =>
'fileadmin/', 2 =>
'uploads/test/']),
216 'uploads\\test\\dummy.png',