17 use \TYPO3\CMS\Core\Tests\Functional\Framework\Frontend\Response;
189 if (!defined(
'ORIGINAL_ROOT')) {
190 $this->markTestSkipped(
'Functional tests must be called through phpunit on CLI');
193 $this->bootstrapUtility->setUp(
195 $this->coreExtensionsToLoad,
196 $this->testExtensionsToLoad,
197 $this->pathsToLinkInTestInstance,
198 $this->configurationToUseInTestInstance,
199 $this->additionalFoldersToCreate
222 protected function setUpBackendUserFromFixture($userUid) {
223 $this->importDataSet(ORIGINAL_ROOT .
'typo3/sysext/core/Tests/Functional/Fixtures/be_users.xml');
225 $userRow =
$database->exec_SELECTgetSingleRow(
'*',
'be_users',
'uid = ' . (
int)$userUid);
229 $sessionId = $backendUser->createSessionId();
230 $_COOKIE[
'be_typo_user'] = $sessionId;
231 $backendUser->id = $sessionId;
232 $backendUser->sendNoCacheHeaders = FALSE;
233 $backendUser->dontSetCookie = TRUE;
234 $backendUser->createUserSession($userRow);
238 if (!is_array(
$GLOBALS[
'BE_USER']->user) || !
$GLOBALS[
'BE_USER']->user[
'uid']) {
240 'Can not initialize backend user',
244 $GLOBALS[
'BE_USER']->backendCheckLogin();
256 protected function importDataSet($path) {
257 if (!is_file($path)) {
259 'Fixture file ' . $path .
' not found',
266 $fileContent = file_get_contents($path);
268 $previousValueOfEntityLoader = libxml_disable_entity_loader(TRUE);
269 $xml = simplexml_load_string($fileContent);
270 libxml_disable_entity_loader($previousValueOfEntityLoader);
271 $foreignKeys = array();
274 foreach ($xml->children() as $table) {
275 $insertArray = array();
278 foreach ($table->children() as $column) {
279 $columnName = $column->getName();
282 if (isset($column[
'ref'])) {
283 list($tableName, $elementId) = explode(
'#', $column[
'ref']);
284 $columnValue = $foreignKeys[$tableName][$elementId];
285 } elseif (isset($column[
'is-NULL']) && ($column[
'is-NULL'] ===
'yes')) {
288 $columnValue = (string) $table->$columnName;
291 $insertArray[$columnName] = $columnValue;
294 $tableName = $table->getName();
298 'Error when processing fixture file: ' . $path .
' Can not insert data to table ' . $tableName,
302 if (isset($table[
'id'])) {
303 $elementId = (string) $table[
'id'];
304 $foreignKeys[$tableName][$elementId] =
$database->sql_insert_id();
314 $pageId = (int)$pageId;
318 $this->fail(
'Cannot set up frontend root page "' . $pageId .
'"');
321 $pagesFields = array(
327 $templateFields = array(
335 foreach ($typoScriptFiles as $typoScriptFile) {
336 $templateFields[
'config'] .=
'<INCLUDE_TYPOSCRIPT: source="FILE:' . $typoScriptFile .
'">' . LF;
350 protected function getFrontendResponse($pageId, $languageId = 0, $backendUserId = 0, $workspaceId = 0, $failOnFailure = TRUE) {
351 $pageId = (int)$pageId;
352 $languageId = (int)$languageId;
354 $additionalParameter =
'';
355 if (!empty($backendUserId)) {
356 $additionalParameter .=
'&backendUserId=' . (int)$backendUserId;
358 if (!empty($workspaceId)) {
359 $additionalParameter .=
'&workspaceId=' . (int)$workspaceId;
364 'requestUrl' =>
'http://localhost/?id=' . $pageId .
'&L=' . $languageId . $additionalParameter,
367 $template = new \Text_Template(ORIGINAL_ROOT .
'typo3/sysext/core/Tests/Functional/Fixtures/Frontend/request.tpl');
370 'arguments' => var_export($arguments, TRUE),
371 'originalRoot' => ORIGINAL_ROOT,
375 $php = \PHPUnit_Util_PHP::factory();
376 $response = $php->runJob($template->render());
377 $result = json_decode($response[
'stdout'], TRUE);
380 $this->fail(
'Frontend Response is empty');
384 $this->fail(
'Frontend Response has failure:' . LF .
$result[
'error']);
static getInstancePath($testCaseClassName)
$configurationToUseInTestInstance
setUpFrontendRootPage($pageId, array $typoScriptFiles=array())
$additionalFoldersToCreate
$pathsToLinkInTestInstance
static makeInstance($className)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
getFrontendResponse($pageId, $languageId=0, $backendUserId=0, $workspaceId=0, $failOnFailure=TRUE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getInstanceIdentifier($testCaseClassName)