TYPO3 CMS  TYPO3_6-2
AbstractFileTest.php
Go to the documentation of this file.
1 <?php
3 
17 
24 
28  public function getParentFolderGetsParentFolderFromStorage() {
29  $parentIdentifier = '/parent/';
30  $currentIdentifier = '/parent/current/';
31 
32  $mockedStorageForParent = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array(), array(), '', FALSE);
33 
35  $parentFolderFixture = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractFile');
36  $parentFolderFixture->setIdentifier($parentIdentifier)->setStorage($mockedStorageForParent);
37 
38  $mockedStorage = $this->getMock('TYPO3\\CMS\\Core\\Resource\\ResourceStorage', array('getFolderIdentifierFromFileIdentifier', 'getFolder'), array(), '', FALSE);
39  $mockedStorage->expects($this->once())->method('getFolderIdentifierFromFileIdentifier')->with($currentIdentifier)->will($this->returnValue($parentIdentifier));
40  $mockedStorage->expects($this->once())->method('getFolder')->with($parentIdentifier)->will($this->returnValue($parentFolderFixture));
41 
43  $currentFolderFixture = $this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\AbstractFile');
44  $currentFolderFixture->setIdentifier($currentIdentifier)->setStorage($mockedStorage);
45 
46  $this->assertSame($parentFolderFixture, $currentFolderFixture->getParentFolder());
47  }
48 
58  $mockedStorage = $this->getMockBuilder('TYPO3\\CMS\\Core\\Resource\\ResourceStorage')
59  ->disableOriginalConstructor()->getMock();
60  $mockedStorage->expects($this->never())->method('getFileInfoByIdentifier')->with('/foo', 'mimetype');
61  $subject = new File(array('identifier' => '/foo', 'mime_type' => 'my/mime-type'), $mockedStorage);
62 
63  $this->assertEquals('my/mime-type', $subject->getMimeType());
64  }
65 
66 }