[TASK] Update caching framework to latest FLOW3 version
[Packages/TYPO3.CMS.git] / tests / t3lib / class.t3lib_spritemanagerTest.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Fabien Udriot <fabien.udriot@ecodev.ch>
6 * All rights reserved
7 *
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.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
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.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * Testcase for class t3lib_SpriteManager.
27 *
28 * @author Fabien Udriot <fabien.udriot@ecodev.ch>
29 *
30 * @package TYPO3
31 * @subpackage t3lib
32 */
33 class t3lib_SpriteManagerTest extends tx_phpunit_testcase {
34
35 /**
36 * Enable backup of global and system variables
37 *
38 * @var boolean
39 */
40 protected $backupGlobals = TRUE;
41
42 /**
43 * Exclude TYPO3_DB from backup/ restore of $GLOBALS
44 * because resource types cannot be handled during serializing
45 *
46 * @var array
47 */
48 protected $backupGlobalsBlacklist = array('TYPO3_DB');
49
50
51 //////////////////////////////////////////
52 // Tests concerning addTcaTypeIcon
53 //////////////////////////////////////////
54
55 /**
56 * @test
57 */
58 public function addTcaTypeIconWithEmptyValueSetsArrayKey() {
59 t3lib_SpriteManager::addTcaTypeIcon('', '', '');
60 $this->assertArrayHasKey('tcarecords--', $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']);
61 }
62
63 /**
64 * @test
65 */
66 public function addTcaTypeIconWithEmptyValueSetsEmptyArrayValue() {
67 t3lib_SpriteManager::addTcaTypeIcon('', '', '');
68 $this->assertEquals('', $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['tcarecords--']);
69 }
70
71 /**
72 * @test
73 */
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']);
79 }
80
81 /**
82 * @test
83 */
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]);
90 }
91
92
93 //////////////////////////////////////////
94 // Tests concerning addSingleIcons
95 //////////////////////////////////////////
96
97 /**
98 * @test
99 */
100 public function addSingleIconsWithEmptyValueSetsArrayKey() {
101 $type = '';
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']);
107 }
108
109 /**
110 * @test
111 */
112 public function addSingleIconsWithEmptyValueSetsImagePathValue() {
113 $type = '';
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]);
119 }
120
121 /**
122 * @test
123 */
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']);
131 }
132
133 /**
134 * @test
135 */
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]);
143 }
144 }
145 ?>