TYPO3 CMS  TYPO3_6-2
ExtendedFileUtilityTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
18 
25 
29  protected function setUp() {
30  $GLOBALS['LANG'] = $this->getMock('TYPO3\\CMS\\Lang\\LanguageService', array('sL'));
31  $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array());
32  }
33 
37  public function folderHasFilesInUseReturnsTrueIfItHasFiles() {
38  $fileUid = 1;
39  $file = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array('getUid'), array(), '', FALSE);
40  $file->expects($this->once())->method('getUid')->will($this->returnValue($fileUid));
41 
42  $folder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array('getFiles'), array(), '', FALSE);
43  $folder->expects($this->once())
44  ->method('getFiles')->with(0, 0, Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, TRUE)
45  ->will($this->returnValue(array($file))
46  );
47 
49  $subject = $this->getMock('TYPO3\\CMS\\Core\\Utility\File\\ExtendedFileUtility', array('addFlashMessage'), array(), '');
50  $GLOBALS['TYPO3_DB']->expects($this->once())
51  ->method('exec_SELECTcountRows')->with('*', 'sys_refindex', 'deleted=0 AND ref_table="sys_file" AND ref_uid IN (' . $fileUid . ') AND tablename<>"sys_file_metadata"')
52  ->will($this->returnValue(1));
53 
54  $GLOBALS['LANG']->expects($this->at(0))->method('sL')
55  ->with('LLL:EXT:lang/locallang_core.xlf:message.description.folderNotDeletedHasFilesWithReferences')
56  ->will($this->returnValue('folderNotDeletedHasFilesWithReferences'));
57  $GLOBALS['LANG']->expects($this->at(1))->method('sL')
58  ->with('LLL:EXT:lang/locallang_core.xlf:message.header.folderNotDeletedHasFilesWithReferences')
59  ->will($this->returnValue('folderNotDeletedHasFilesWithReferences'));
60 
61  $result = $subject->folderHasFilesInUse($folder);
62  $this->assertTrue($result);
63  }
64 
68  public function folderHasFilesInUseReturnsFalseIfItHasNoFiles() {
69  $folder = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Folder', array('getFiles'), array(), '', FALSE);
70  $folder->expects($this->once())->method('getFiles')->with(0, 0, Folder::FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS, TRUE)->will(
71  $this->returnValue(array())
72  );
73 
75  $subject = $this->getMock('TYPO3\\CMS\\Core\\Utility\File\\ExtendedFileUtility', array('addFlashMessage'), array(), '');
76  $this->assertFalse($subject->folderHasFilesInUse($folder));
77  }
78 
79 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
const FILTER_MODE_USE_OWN_AND_STORAGE_FILTERS
Definition: Folder.php:71
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]