2 /***************************************************************
5 * (c) 2010-2011 Fabien Udriot <fabien.udriot@ecodev.ch>
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
26 * Testcase for class t3lib_SpriteManager.
28 * @author Fabien Udriot <fabien.udriot@ecodev.ch>
33 class t3lib_SpriteManagerTest
extends tx_phpunit_testcase
{
36 * Enable backup of global and system variables
40 protected $backupGlobals = TRUE;
43 * Exclude TYPO3_DB from backup/ restore of $GLOBALS
44 * because resource types cannot be handled during serializing
48 protected $backupGlobalsBlacklist = array('TYPO3_DB');
51 //////////////////////////////////////////
52 // Tests concerning addTcaTypeIcon
53 //////////////////////////////////////////
58 public function addTcaTypeIconWithEmptyValueSetsArrayKey() {
59 t3lib_SpriteManager
::addTcaTypeIcon('', '', '');
60 $this->assertArrayHasKey('tcarecords--', $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']);
66 public function addTcaTypeIconWithEmptyValueSetsEmptyArrayValue() {
67 t3lib_SpriteManager
::addTcaTypeIcon('', '', '');
68 $this->assertEquals('', $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['tcarecords--']);
74 public function addTcaTypeIconWithTableAndTypeSetsArrayKey() {
75 $table = 'tt_content';
76 $type = 'contains-news';
77 t3lib_SpriteManager
::addTcaTypeIcon($table, $type, '');
78 $this->assertArrayHasKey('tcarecords-' . $table . '-' . $type, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']);
84 public function addTcaTypeIconWithTableAndTypeAndValueSetsArrayValue() {
85 $imagePath = 'path/to/my-icon.png';
86 $table = 'tt_content';
87 $type = 'contains-news';
88 t3lib_SpriteManager
::addTcaTypeIcon($table, $type, $imagePath);
89 $this->assertEquals($imagePath, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['tcarecords-' . $table . '-' . $type]);
93 //////////////////////////////////////////
94 // Tests concerning addSingleIcons
95 //////////////////////////////////////////
100 public function addSingleIconsWithEmptyValueSetsArrayKey() {
102 $imagePath = 'path/to/my-icon.png';
103 $icons = array($type => $imagePath);
104 $extensionKey = 'dummy';
105 t3lib_SpriteManager
::addSingleIcons($icons, $extensionKey);
106 $this->assertArrayHasKey('extensions-' . $extensionKey . '-' . $type, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']);
112 public function addSingleIconsWithEmptyValueSetsImagePathValue() {
114 $imagePath = 'path/to/my-icon.png';
115 $icons = array($type => $imagePath);
116 $extensionKey = 'dummy';
117 t3lib_SpriteManager
::addSingleIcons($icons, $extensionKey);
118 $this->assertEquals($imagePath, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['extensions-' . $extensionKey . '-' . $type]);
124 public function addSingleIconsWithNormalValueSetsArrayKey() {
125 $type = 'contains-news';
126 $imagePath = 'path/to/my-icon.png';
127 $icons = array($type => $imagePath);
128 $extensionKey = 'dummy';
129 t3lib_SpriteManager
::addSingleIcons($icons, $extensionKey);
130 $this->assertArrayHasKey('extensions-' . $extensionKey . '-' . $type, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']);
136 public function addSingleIconsWithNormalValueSetsImagePathValue() {
137 $type = 'contains-news';
138 $imagePath = 'path/to/my-icon.png';
139 $icons = array($type => $imagePath);
140 $extensionKey = 'dummy';
141 t3lib_SpriteManager
::addSingleIcons($icons, $extensionKey);
142 $this->assertEquals($imagePath, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['extensions-' . $extensionKey . '-' . $type]);