[BUGFIX] Fix ResourceFactory Test 72/19672/5
authorSteffen Ritter <info@rs-websystems.de>
Sat, 6 Apr 2013 13:20:11 +0000 (15:20 +0200)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Sat, 6 Apr 2013 13:39:16 +0000 (15:39 +0200)
Travis fails to execute some newly introduced Factory
Tests. This patch aims to clean them up and make
Travis happy again :)

Change-Id: I8b57eb9bd3cbcb2cb3fc2831a4d1fbffa1c30877
Resolves: #45748
Releases: 6.1, 6.0
Tested-by: Christian Kuhn
Reviewed-on: https://review.typo3.org/19672
Reviewed-by: Christian Kuhn
Reviewed-by: Anja Leichsenring
Tested-by: Anja Leichsenring
typo3/sysext/core/Tests/Unit/Resource/FactoryTest.php

index 6e386da..4fa88e1 100644 (file)
@@ -55,7 +55,7 @@ class FactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
 
        public function setUp() {
                $this->singletonInstances = \TYPO3\CMS\Core\Utility\GeneralUtility::getSingletonInstances();
-               $this->fixture = new \TYPO3\CMS\Core\Resource\ResourceFactory();
+               $this->fixture = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Resource\\ResourceFactory', array('dummy'));
        }
 
        public function tearDown() {
@@ -115,19 +115,29 @@ class FactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @dataProvider directoryDataProviderValidFolderValues
         */
        public function retrieveFileOrFolderObjectReturnsFolderIfPathIsGiven($source) {
-               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Resource\\Folder', $this->fixture->retrieveFileOrFolderObject($source), 'No Folder Object can be retrieved');
+               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('getFile', 'getFolder'), array(), '', FALSE);
+               $storage->expects($this->once())
+                       ->method('getFolder')
+                       ->with('fileadmin');
+               $this->fixture->_set('storageInstances', array(0 => $storage));
+               $this->fixture->retrieveFileOrFolderObject($source);
        }
 
        /**
         * @test
         */
        public function retrieveFileOrFolderObjectReturnsFileIfPathIsGiven() {
+               $filename = 'typo3temp/4711.txt';
+               $storage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('getFile', 'getFolder'), array(), '', FALSE);
+               $storage->expects($this->once())
+                       ->method('getFile')
+                       ->with($filename);
+               $this->fixture->_set('storageInstances', array(0 => $storage));
                // Create and prepare test file
-               $filename = 'typo3temp/' . uniqid('test_') . '.txt';
                \TYPO3\CMS\Core\Utility\GeneralUtility::writeFileToTypo3tempDir(PATH_site . $filename, '42');
                $this->filesCreated[] = PATH_site . $filename;
-               $this->assertInstanceOf('TYPO3\\CMS\\Core\\Resource\\File', $this->fixture->retrieveFileOrFolderObject($filename), 'No File Object can be retrieved');
+               $this->fixture->retrieveFileOrFolderObject($filename);
        }
 }
 
-?>
\ No newline at end of file
+?>