TYPO3 CMS  TYPO3_6-2
FileCollectionRegistryTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $testSubject;
26 
27  public function setUp() {
28  $this->initializeTestSubject();
29  }
30 
31  protected function initializeTestSubject() {
32  $this->testSubject = new \TYPO3\CMS\Core\Resource\Collection\FileCollectionRegistry();
33  }
34 
39  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
40  $this->testSubject->registerFileCollectionClass($className, 'foobar');
41  $returnedClassName = $this->testSubject->getFileCollectionClass('foobar');
42  $this->assertEquals($className, $returnedClassName);
43  }
44 
51  $this->testSubject->registerFileCollectionClass($this->getUniqueId(), substr($this->getUniqueId(), 0, 30));
52  }
53 
60  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
61  $type = str_pad('', 40);
62  $this->testSubject->registerFileCollectionClass($className, $type);
63  }
64 
71  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
72  $className2 = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\StaticFileCollection'));
73  $this->testSubject->registerFileCollectionClass($className, 'foobar');
74  $this->testSubject->registerFileCollectionClass($className2, 'foobar');
75  }
76 
81  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
82  $className2 = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\StaticFileCollection'));
83  $this->testSubject->registerFileCollectionClass($className, 'foobar');
84  $this->testSubject->registerFileCollectionClass($className2, 'foobar', TRUE);
85  }
86 
93  $this->testSubject->getFileCollectionClass($this->getUniqueId());
94  }
95 
100  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
101  $this->testSubject->registerFileCollectionClass($className, 'foobar');
102  $this->assertEquals($className, $this->testSubject->getFileCollectionClass('foobar'));
103  }
104 
109  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
110  $type = substr($this->getUniqueId(), 0, 30);
111  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredCollections'] = array(
112  $type => $className
113  );
114  $this->initializeTestSubject();
115  $this->assertEquals($className, $this->testSubject->getFileCollectionClass($type));
116  }
117 
122  $className = get_class($this->getMockForAbstractClass('TYPO3\\CMS\\Core\\Resource\\Collection\\AbstractFileCollection'));
123  $type = 'foo';
124  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredCollections'] = array(
125  $type => $className
126  );
127  $this->initializeTestSubject();
128  $this->assertTrue($this->testSubject->fileCollectionTypeExists($type));
129  $this->assertFalse($this->testSubject->fileCollectionTypeExists('bar'));
130  }
131 
136  $GLOBALS['TYPO3_CONF_VARS']['SYS']['fal']['registeredFileCollections'] = array();
137  $this->initializeTestSubject();
138  $this->assertFalse($this->testSubject->fileCollectionTypeExists($this->getUniqueId()));
139  }
140 
144  public function addNewTypeToTCA() {
145 
146  // Create a TCA fixture for sys_file_collection
147  $GLOBALS['TCA']['sys_file_collection'] = array(
148  'types' => array(
149  'typeB' => array('showitem' => 'fieldA, fieldB, fieldC;labelC;paletteC;specialC, fieldD'),
150  ),
151  'columns' => array(
152  'type' => array(
153  'config' => array(
154  'items' => array('Type B', 'typeB')
155  )
156  )
157  )
158  );
159 
160  $type = 'my_type';
161  $label = 'The Label';
162 
163  $this->testSubject->addTypeToTCA($type, $label, 'something');
164 
165  // check type
166  $this->assertEquals('sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, title;;1, type, something', $GLOBALS['TCA']['sys_file_collection']['types']['my_type']['showitem']);
167 
168  $indexOfNewType = count($GLOBALS['TCA']['sys_file_collection']['columns']['type']['config']['items']) - 1;
169 
170  // check if columns.type.item exist
171  $this->assertEquals($type, $GLOBALS['TCA']['sys_file_collection']['columns']['type']['config']['items'][$indexOfNewType][1]);
172  $this->assertEquals($label, $GLOBALS['TCA']['sys_file_collection']['columns']['type']['config']['items'][$indexOfNewType][0]);
173  }
174 }
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]