TYPO3 CMS  TYPO3_7-6
IconUtilityTest.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  */
16 
18 
23 {
27  protected $mockRecord = [
28  'header' => 'dummy content header',
29  'uid' => '1',
30  'pid' => '1',
31  'image' => '',
32  'hidden' => '0',
33  'starttime' => '0',
34  'endtime' => '0',
35  'fe_group' => '',
36  'CType' => 'text',
37  't3ver_id' => '0',
38  't3ver_state' => '0',
39  't3ver_wsid' => '0',
40  'sys_language_uid' => '0',
41  'l18n_parent' => '0',
42  'subheader' => '',
43  'bodytext' => '',
44  ];
45 
52  protected function getTestSubjectFolderObject($identifier)
53  {
54  $mockedStorage = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class, [], [], '', false);
55  $mockedStorage->expects($this->any())->method('getRootLevelFolder')->will($this->returnValue(
56  new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, '/', '/')
57  ));
58  $mockedStorage->expects($this->any())->method('checkFolderActionPermission')->will($this->returnValue(true));
59  $mockedStorage->expects($this->any())->method('isBrowsable')->will($this->returnValue(true));
60  return new \TYPO3\CMS\Core\Resource\Folder($mockedStorage, $identifier, $identifier);
61  }
62 
69  protected function getTestSubjectFileObject($extension)
70  {
71  $mockedStorage = $this->getMock(\TYPO3\CMS\Core\Resource\ResourceStorage::class, [], [], '', false);
72  $mockedFile = $this->getMock(\TYPO3\CMS\Core\Resource\File::class, [], [[], $mockedStorage]);
73  $mockedFile->expects($this->once())->method('getExtension')->will($this->returnValue($extension));
74  return $mockedFile;
75  }
76 
78  // Tests concerning imagemake
80 
84  {
85  if (TYPO3_OS == 'WIN') {
86  $this->markTestSkipped('imagemakeFixesPermissionsOnNewFiles() test not available on Windows.');
87  }
88  $fixtureGifFile = __DIR__ . '/Fixtures/clear.gif';
89  // Create image resource, determine target filename, fake target permission, run method and clean up
90  $fixtureGifRessource = imagecreatefromgif($fixtureGifFile);
91  $targetFilename = PATH_site . 'typo3temp/' . $this->getUniqueId('test_') . '.gif';
92  $this->testFilesToDelete[] = $targetFilename;
93  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fileCreateMask'] = '0777';
94  IconUtilityFixture::imagemake($fixtureGifRessource, $targetFilename);
95  clearstatcache();
96  $resultFilePermissions = substr(decoct(fileperms($targetFilename)), 2);
97  $this->assertEquals($resultFilePermissions, '0777');
98  }
99 
101  // Tests concerning getSpriteIconClasses
103 
109  {
110  $this->assertEquals('t3-icon', IconUtilityFixture::getSpriteIconClasses(''));
111  }
112 
119  {
120  $this->assertEquals('t3-icon', IconUtilityFixture::getSpriteIconClasses('actions'));
121  }
122 
129  {
130  $result = explode(' ', IconUtilityFixture::getSpriteIconClasses('actions-juggle'));
131  sort($result);
132  $this->assertEquals(['t3-icon', 't3-icon-actions', 't3-icon-actions-juggle', 't3-icon-juggle'], $result);
133  }
134 
141  {
142  $result = explode(' ', IconUtilityFixture::getSpriteIconClasses('actions-juggle-speed'));
143  sort($result);
144  $this->assertEquals(['t3-icon', 't3-icon-actions', 't3-icon-actions-juggle', 't3-icon-juggle-speed'], $result);
145  }
146 
153  {
154  $result = explode(' ', IconUtilityFixture::getSpriteIconClasses('actions-juggle-speed-game'));
155  sort($result);
156  $this->assertEquals(['t3-icon', 't3-icon-actions', 't3-icon-actions-juggle', 't3-icon-juggle-speed-game'], $result);
157  }
158 }
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']