|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010-2011 Fabien Udriot <fabien.udriot@ecodev.ch> 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * 00017 * This script is distributed in the hope that it will be useful, 00018 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 * GNU General Public License for more details. 00021 * 00022 * This copyright notice MUST APPEAR in all copies of the script! 00023 ***************************************************************/ 00024 00025 /** 00026 * Testcase for class t3lib_SpriteManager. 00027 * 00028 * @author Fabien Udriot <fabien.udriot@ecodev.ch> 00029 * 00030 * @package TYPO3 00031 * @subpackage t3lib 00032 */ 00033 class t3lib_SpriteManagerTest extends tx_phpunit_testcase { 00034 00035 /** 00036 * Enable backup of global and system variables 00037 * 00038 * @var boolean 00039 */ 00040 protected $backupGlobals = TRUE; 00041 00042 /** 00043 * Exclude TYPO3_DB from backup/ restore of $GLOBALS 00044 * because resource types cannot be handled during serializing 00045 * 00046 * @var array 00047 */ 00048 protected $backupGlobalsBlacklist = array('TYPO3_DB'); 00049 00050 00051 ////////////////////////////////////////// 00052 // Tests concerning addTcaTypeIcon 00053 ////////////////////////////////////////// 00054 00055 /** 00056 * @test 00057 */ 00058 public function addTcaTypeIconWithEmptyValueSetsArrayKey() { 00059 t3lib_SpriteManager::addTcaTypeIcon('', '', ''); 00060 $this->assertArrayHasKey('tcarecords--', $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']); 00061 } 00062 00063 /** 00064 * @test 00065 */ 00066 public function addTcaTypeIconWithEmptyValueSetsEmptyArrayValue() { 00067 t3lib_SpriteManager::addTcaTypeIcon('', '', ''); 00068 $this->assertEquals('', $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['tcarecords--']); 00069 } 00070 00071 /** 00072 * @test 00073 */ 00074 public function addTcaTypeIconWithTableAndTypeSetsArrayKey() { 00075 $table = 'tt_content'; 00076 $type = 'contains-news'; 00077 t3lib_SpriteManager::addTcaTypeIcon($table, $type, ''); 00078 $this->assertArrayHasKey('tcarecords-' . $table . '-' . $type, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']); 00079 } 00080 00081 /** 00082 * @test 00083 */ 00084 public function addTcaTypeIconWithTableAndTypeAndValueSetsArrayValue() { 00085 $imagePath = 'path/to/my-icon.png'; 00086 $table = 'tt_content'; 00087 $type = 'contains-news'; 00088 t3lib_SpriteManager::addTcaTypeIcon($table, $type, $imagePath); 00089 $this->assertEquals($imagePath, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['tcarecords-' . $table . '-' . $type]); 00090 } 00091 00092 00093 ////////////////////////////////////////// 00094 // Tests concerning addSingleIcons 00095 ////////////////////////////////////////// 00096 00097 /** 00098 * @test 00099 */ 00100 public function addSingleIconsWithEmptyValueSetsArrayKey() { 00101 $type = ''; 00102 $imagePath = 'path/to/my-icon.png'; 00103 $icons = array($type => $imagePath); 00104 $extensionKey = 'dummy'; 00105 t3lib_SpriteManager::addSingleIcons($icons, $extensionKey); 00106 $this->assertArrayHasKey('extensions-' . $extensionKey . '-' . $type, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']); 00107 } 00108 00109 /** 00110 * @test 00111 */ 00112 public function addSingleIconsWithEmptyValueSetsImagePathValue() { 00113 $type = ''; 00114 $imagePath = 'path/to/my-icon.png'; 00115 $icons = array($type => $imagePath); 00116 $extensionKey = 'dummy'; 00117 t3lib_SpriteManager::addSingleIcons($icons, $extensionKey); 00118 $this->assertEquals($imagePath, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['extensions-' . $extensionKey . '-' . $type]); 00119 } 00120 00121 /** 00122 * @test 00123 */ 00124 public function addSingleIconsWithNormalValueSetsArrayKey() { 00125 $type = 'contains-news'; 00126 $imagePath = 'path/to/my-icon.png'; 00127 $icons = array($type => $imagePath); 00128 $extensionKey = 'dummy'; 00129 t3lib_SpriteManager::addSingleIcons($icons, $extensionKey); 00130 $this->assertArrayHasKey('extensions-' . $extensionKey . '-' . $type, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']); 00131 } 00132 00133 /** 00134 * @test 00135 */ 00136 public function addSingleIconsWithNormalValueSetsImagePathValue() { 00137 $type = 'contains-news'; 00138 $imagePath = 'path/to/my-icon.png'; 00139 $icons = array($type => $imagePath); 00140 $extensionKey = 'dummy'; 00141 t3lib_SpriteManager::addSingleIcons($icons, $extensionKey); 00142 $this->assertEquals($imagePath, $GLOBALS['TBE_STYLES']['spritemanager']['singleIcons']['extensions-' . $extensionKey . '-' . $type]); 00143 } 00144 } 00145 ?>
1.8.0