TYPO3 CMS  TYPO3_6-2
SystemEnvironmentBuilderTest.php
Go to the documentation of this file.
1 <?php
3 
22 
26  protected $fixture = NULL;
27 
33  public function setUp() {
34  $this->fixture = $this->getAccessibleMock('TYPO3\\CMS\\Core\\Core\\SystemEnvironmentBuilder', array('dummy'));
35  }
36 
43  $fileName = $this->getUniqueId('filename');
44  $data = array();
45  $phpExtensions = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', 'php,php3,php4,php5,php6,phpsh,phtml', TRUE);
46  foreach ($phpExtensions as $extension) {
47  $data[] = array($fileName . '.' . $extension);
48  $data[] = array($fileName . '.' . $extension . '.txt');
49  }
50  return $data;
51  }
52 
60  public function fileDenyPatternMatchesPhpExtension($phpExtension) {
61  $this->assertGreaterThan(0, preg_match('/' . FILE_DENY_PATTERN_DEFAULT . '/', $phpExtension), $phpExtension);
62  }
63 
68  $fakedLocalPart = $this->getUniqueId('Test');
69  $GLOBALS['_SERVER']['argv'][0] = $fakedLocalPart;
70  $this->assertStringEndsWith($fakedLocalPart, $this->fixture->_call('getPathThisScriptCli'));
71  }
72 
77  $fakedLocalPart = $this->getUniqueId('Test');
78  unset($GLOBALS['_SERVER']['argv']);
79  $GLOBALS['_ENV']['_'] = $fakedLocalPart;
80  $this->assertStringEndsWith($fakedLocalPart, $this->fixture->_call('getPathThisScriptCli'));
81  }
82 
87  $fakedLocalPart = $this->getUniqueId('Test');
88  unset($GLOBALS['_SERVER']['argv']);
89  unset($GLOBALS['_ENV']['_']);
90  $GLOBALS['_SERVER']['_'] = $fakedLocalPart;
91  $this->assertStringEndsWith($fakedLocalPart, $this->fixture->_call('getPathThisScriptCli'));
92  }
93 
98  if (TYPO3_OS === 'WIN') {
99  $this->markTestSkipped('Test not available on Windows OS.');
100  }
101  $GLOBALS['_SERVER']['argv'][0] = 'foo';
102  $fakedAbsolutePart = '/' . $this->getUniqueId('Absolute') . '/';
103  $_SERVER['PWD'] = $fakedAbsolutePart;
104  $this->assertStringStartsWith($fakedAbsolutePart, $this->fixture->_call('getPathThisScriptCli'));
105  }
106 
111  if (TYPO3_OS === 'WIN') {
112  $this->markTestSkipped('Test not available on Windows OS.');
113  }
114  $input = '/foo/bar/test.php';
115  $expected = '/foo/bar/';
116  $actual = $this->fixture->_call('getUnifiedDirectoryNameWithTrailingSlash', $input);
117  $this->assertEquals($expected, $actual);
118  }
119 
124  $backupPath = get_include_path();
125  $this->fixture->_call('addCorePearPathToIncludePath');
126  $actualValue = get_include_path();
127  set_include_path($backupPath);
128  $this->assertStringStartsWith(PATH_typo3 . 'contrib/pear/' . PATH_SEPARATOR, $actualValue);
129  }
130 
135  $GLOBALS['error'] = 'foo';
136  $this->fixture->_call('initializeGlobalVariables');
137  $this->assertFalse(isset($GLOBALS['error']));
138  }
139 
144  unset($GLOBALS['CLIENT']);
145  $this->fixture->_call('initializeGlobalVariables');
146  $this->assertArrayHasKey('CLIENT', $GLOBALS);
147  }
148 
153  unset($GLOBALS['TYPO3_MISC']);
154  $this->fixture->_call('initializeGlobalVariables');
155  $this->assertInternalType('array', $GLOBALS['TYPO3_MISC']);
156  }
157 
162  unset($GLOBALS['T3_VAR']);
163  $this->fixture->_call('initializeGlobalVariables');
164  $this->assertInternalType('array', $GLOBALS['T3_VAR']);
165  }
166 
171  unset($GLOBALS['T3_SERVICES']);
172  $this->fixture->_call('initializeGlobalVariables');
173  $this->assertInternalType('array', $GLOBALS['T3_SERVICES']);
174  }
175 
182  return array(
183  'PARSETIME_START' => array('PARSETIME_START'),
184  'EXEC_TIME' => array('EXEC_TIME'),
185  'ACCESS_TIME' => array('ACCESS_TIME'),
186  'SIM_EXEC_TIME' => array('SIM_EXEC_TIME'),
187  'SIM_ACCESS_TIME' => array('SIM_ACCESS_TIME')
188  );
189  }
190 
197  unset($GLOBALS[$variable]);
198  $this->fixture->_call('initializeGlobalTimeTrackingVariables');
199  $this->assertTrue(isset($GLOBALS[$variable]));
200  }
201 
206  unset($GLOBALS['TYPO3_MISC']['microtime_start']);
207  $this->fixture->_call('initializeGlobalTimeTrackingVariables');
208  $this->assertTrue(isset($GLOBALS['TYPO3_MISC']['microtime_start']));
209  }
210 
215  $this->fixture->_call('initializeGlobalTimeTrackingVariables');
216  $this->assertEquals(0, $GLOBALS['ACCESS_TIME'] % 60);
217  }
218 
223  $this->fixture->_call('initializeGlobalTimeTrackingVariables');
224  $this->assertEquals(0, $GLOBALS['SIM_ACCESS_TIME'] % 60);
225  }
226 
231  $backupReporting = error_reporting();
232  $this->fixture->_call('initializeBasicErrorReporting');
233  $actualReporting = error_reporting();
234  error_reporting($backupReporting);
235  $this->assertEquals(0, $actualReporting & E_STRICT);
236  }
237 
242  $backupReporting = error_reporting();
243  $this->fixture->_call('initializeBasicErrorReporting');
244  $actualReporting = error_reporting();
245  error_reporting($backupReporting);
246  $this->assertEquals(0, $actualReporting & E_NOTICE);
247  }
248 
253  $backupReporting = error_reporting();
254  $this->fixture->_call('initializeBasicErrorReporting');
255  $actualReporting = error_reporting();
256  error_reporting($backupReporting);
257  $this->assertEquals(0, $actualReporting & E_DEPRECATED);
258  }
259 
260 }
static trimExplode($delim, $string, $removeEmptyValues=FALSE, $limit=0)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]