TYPO3 CMS  TYPO3_6-2
IndexerServiceTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  public function indexFileUpdatesFileProperties() {
27  $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
28 
30  $subject = $this->getMock(
31  'TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService',
32  array('gatherFileInformation', 'getFileIndexRepository', 'emitPreFileIndexSignal', 'emitPostFileIndexSignal')
33  );
34 
35  $fileInfo = array(
36  'mount' => 1,
37  'identifier' => '/some/filepath/filename.jpg',
38  'size' => 1234,
39  'uid' => rand(1, 100),
40  'sha1' => '123',
41  );
42 
43  $subject->expects($this->any())->method('gatherFileInformation')->will($this->returnValue($fileInfo));
44 
45  $repositoryMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
46  $repositoryMock->expects($this->any())->method('findByContentHash')->will($this->returnValue(array()));
47  $subject->expects($this->any())->method('getFileIndexRepository')->will($this->returnValue($repositoryMock));
48 
49  $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
50  $mockedFile->expects($this->once())->method('updateProperties');
51 
52  $subject->indexFile($mockedFile);
53  }
54 
58  public function indexFileSetsCreationdateAndTimestampPropertiesOfRecordToCurrentExecutionTime() {
59  $fileInfo = array();
61  $subject = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService', array('gatherFileInformation', 'getFileIndexRepository', 'emitPreFileIndexSignal', 'emitPostFileIndexSignal'));
62 
63  $subject->expects($this->any())->method('gatherFileInformation')->will($this->returnValue($fileInfo));
64 
65  $repositoryMock = $this->getMock('TYPO3\\CMS\\Core\\Resource\\Index\\FileIndexRepository');
66  $repositoryMock->expects($this->any())->method('findByContentHash')->will($this->returnValue(array()));
67  $repositoryMock->expects($this->once())->method('add');
68  $subject->expects($this->any())->method('getFileIndexRepository')->will($this->returnValue($repositoryMock));
69 
70  $GLOBALS['TYPO3_DB'] = $this->getMock('TYPO3\\CMS\\Core\\Database\\DatabaseConnection', array(), array(), '', FALSE);
71 
72  $mockedFile = $this->getMock('TYPO3\\CMS\\Core\\Resource\\File', array(), array(), '', FALSE);
73 
74  $subject->indexFile($mockedFile);
75  }
76 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]