[BUGFIX] Fix incomplete mocking in ResourceStorage test
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Resource / ResourceStorageTest.php
index fd46ff7..d162790 100644 (file)
@@ -29,8 +29,6 @@ require_once 'vfsStream/vfsStream.php';
 /**
  * Testcase for the VFS mount class
  *
- * @package TYPO3
- * @subpackage t3lib
  * @author Andreas Wolf <andreas.wolf@ikt-werk.de>
  */
 class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase {
@@ -49,6 +47,11 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                parent::setUp();
                $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
                \TYPO3\CMS\Core\Utility\GeneralUtility::purgeInstances();
+               \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(
+                       'TYPO3\\CMS\\Core\\Resource\\FileRepository',
+                       $this->getMock('TYPO3\\CMS\\Core\\Resource\\FileRepository')
+               );
+
        }
 
        public function tearDown() {
@@ -92,7 +95,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
         *
         * @param array $configuration
         * @return string
-        * @see t3lib_div::array2xml()
+        * @see \TYPO3\CMS\Core\Utility\GeneralUtility::array2xml()
         */
        protected function convertConfigurationArrayToFlexformXml(array $configuration) {
                $flexformArray = array('data' => array('sDEF' => array('lDEF' => array())));
@@ -118,6 +121,11 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                if ($storageObject == NULL) {
                        $storageObject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
                }
+
+               if (!isset($driverConfiguration['basePath'])) {
+                       $driverConfiguration['basePath'] = $this->getMountRootUrl();
+               }
+
                if ($mockedDriverMethods === NULL) {
                        $driver = new \TYPO3\CMS\Core\Resource\Driver\LocalDriver($driverConfiguration);
                } else {
@@ -141,6 +149,9 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                $this->assertEquals($uri . '/', $this->fixture->getBaseUri());
        }
 
+       /**
+        * @return array
+        */
        public function capabilitiesDataProvider() {
                return array(
                        'only public' => array(
@@ -205,7 +216,7 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
         */
        public function fileAndFolderListFiltersAreInitializedWithDefaultFilters() {
                $this->prepareFixture(array());
-               $this->assertEquals($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['callbackFilterMethods'], $this->fixture->getFileAndFolderNameFilters());
+               $this->assertEquals($GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['defaultFilterCallbacks'], $this->fixture->getFileAndFolderNameFilters());
        }
 
        /**
@@ -609,6 +620,33 @@ class ResourceStorageTest extends \TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCa
                $this->fixture->replaceFile($mockedFile, PATH_site . uniqid());
        }
 
+       /**
+        * @test
+        */
+       public function getFileListHandsOverRecursiveFALSEifNotExplicitlySet() {
+               $this->prepareFixture(array());
+               $driver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), $this->fixture, array('getFileList'));
+               $driver->expects($this->once())
+                       ->method('getFileList')
+                       ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), FALSE)
+                       ->will($this->returnValue(array()));
+               $this->fixture->getFileList('/');
+       }
+
+       /**
+        * @test
+        */
+       public function getFileListHandsOverRecursiveTRUEifSet() {
+
+               $this->prepareFixture(array());
+               $driver = $this->createDriverMock(array('basePath' => $this->getMountRootUrl()), $this->fixture, array('getFileList'));
+               $driver->expects($this->once())
+                       ->method('getFileList')
+                       ->with($this->anything(), $this->anything(), $this->anything(), $this->anything(), $this->anything(), TRUE)
+                       ->will($this->returnValue(array()));
+               $this->fixture->getFileList('/', 0, 0, TRUE, TRUE, TRUE);
+       }
+
 }
 
 ?>
\ No newline at end of file