TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility Class Reference

Public Member Functions

 setUp ( $testCaseClassName, array $coreExtensionsToLoad, array $testExtensionsToLoad, array $pathsToLinkInTestInstance, array $configurationToUse, array $additionalFoldersToCreate)
 

Static Public Member Functions

static getInstanceIdentifier ($testCaseClassName)
 
static getInstancePath ($testCaseClassName)
 

Protected Member Functions

 recentTestInstanceExists ()
 
 setUpIdentifier ($testCaseClassName)
 
 setUpInstancePath ($testCaseClassName)
 
 removeOldInstanceIfExists ()
 
 setUpInstanceDirectories (array $additionalFoldersToCreate=[])
 
 setUpInstanceCoreLinks ()
 
 linkTestExtensionsToInstance (array $extensionPaths)
 
 linkPathsInTestInstance (array $pathsToLinkInTestInstance)
 
 setUpLocalConfiguration (array $configurationToMerge)
 
 setUpPackageStates (array $coreExtensionsToLoad, array $testExtensionPaths)
 
 setUpBasicTypo3Bootstrap ()
 
 removeInstance ()
 
 rmdir ($path, $removeNonEmpty=false)
 
 writeFile ($file, $content)
 
 arrayExport (array $array=[], $level=0)
 
 mergeRecursiveWithOverrule (array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
 

Protected Attributes

 $identifier
 
 $instancePath
 
 $databaseName
 
 $originalDatabaseName
 
 $defaultActivatedCoreExtensions
 
 $defaultFoldersToCreate
 

Detailed Description

Utility class to set up and bootstrap TYPO3 CMS for functional tests

Definition at line 20 of file FunctionalTestCaseBootstrapUtility.php.

Member Function Documentation

◆ arrayExport()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::arrayExport ( array  $array = [],
  $level = 0 
)
protected

COPIED FROM ArrayUtility

Exports an array as string. Similar to var_export(), but representation follows the TYPO3 core CGL.

See unit tests for detailed examples

Parameters
array$arrayArray to export
int$levelInternal level used for recursion, do not set from outside!
Returns
string String representation of array
Exceptions

Definition at line 695 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpLocalConfiguration(), and TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpPackageStates().

◆ getInstanceIdentifier()

static TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::getInstanceIdentifier (   $testCaseClassName)
static

Calculate a "unique" identifier for the test database and the instance patch based on the given test case class name.

Parameters
string$testCaseClassNameName of test case class
Returns
string

Definition at line 73 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCase\getInstanceIdentifier().

◆ getInstancePath()

static TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::getInstancePath (   $testCaseClassName)
static

Calculates path to TYPO3 CMS test installation for this test case.

Parameters
string$testCaseClassNameName of test case class
Returns
string

Definition at line 85 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCase\getInstancePath().

◆ linkPathsInTestInstance()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::linkPathsInTestInstance ( array  $pathsToLinkInTestInstance)
protected

Link paths inside the test instance, e.g. from a fixture fileadmin subfolder to the test instance fileadmin folder

Parameters
array$pathsToLinkInTestInstanceContains paths as array of source => destination in key => value pairs of folders relative to test instance root
Exceptions

Definition at line 272 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ linkTestExtensionsToInstance()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::linkTestExtensionsToInstance ( array  $extensionPaths)
protected

Link test extensions to the typo3conf/ext folder of the instance.

Parameters
array$extensionPathsContains paths to extensions relative to document root
Exceptions
Exception
Returns
void

Definition at line 241 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ mergeRecursiveWithOverrule()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::mergeRecursiveWithOverrule ( array &  $original,
array  $overrule,
  $addKeys = true,
  $includeEmptyValues = true,
  $enableUnsetFeature = true 
)
protected

COPIED FROM ArrayUtility

Merges two arrays recursively and "binary safe" (integer keys are overridden as well), overruling similar values in the original array with the values of the overrule array. In case of identical keys, ie. keeping the values of the overrule array.

This method takes the original array by reference for speed optimization with large arrays

The differences to the existing PHP function array_merge_recursive() are:

  • Keys of the original array can be unset via the overrule array. ($enableUnsetFeature)
  • Much more control over what is actually merged. ($addKeys, $includeEmptyValues)
  • Elements or the original array get overwritten if the same key is present in the overrule array.
Parameters
array$originalOriginal array. It will be modified by this method and contains the result afterwards!
array$overruleOverrule array, overruling the original array
bool$addKeysIf set to FALSE, keys that are NOT found in $original will not be set. Thus only existing value can/will be overruled from overrule array.
bool$includeEmptyValuesIf set, values from $overrule will overrule if they are empty or zero.
bool$enableUnsetFeatureIf set, special values "__UNSET" can be used in the overrule array in order to unset array keys in the original array.
Returns
void

Definition at line 766 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpLocalConfiguration().

◆ recentTestInstanceExists()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::recentTestInstanceExists ( )
protected

Checks whether the current test instance exists and is younger than some minutes.

Returns
bool

Definition at line 138 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ removeInstance()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::removeInstance ( )
protected

◆ removeOldInstanceIfExists()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::removeOldInstanceIfExists ( )
protected

Remove test instance folder structure in setUp() if it exists. This may happen if a functional test before threw a fatal.

Returns
void

Definition at line 180 of file FunctionalTestCaseBootstrapUtility.php.

References TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\removeInstance().

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ rmdir()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::rmdir (   $path,
  $removeNonEmpty = false 
)
protected

COPIED FROM GeneralUtility

Wrapper function for rmdir, allowing recursive deletion of folders and files

Parameters
string$pathAbsolute path to folder, see PHP rmdir() function. Removes trailing slash internally.
bool$removeNonEmptyAllow deletion of non-empty directories
Returns
bool TRUE if went well!

Definition at line 624 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\removeInstance().

◆ setUp()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUp (   $testCaseClassName,
array  $coreExtensionsToLoad,
array  $testExtensionsToLoad,
array  $pathsToLinkInTestInstance,
array  $configurationToUse,
array  $additionalFoldersToCreate 
)

Set up creates a test instance and database.

Parameters
string$testCaseClassNameName of test case class
array$coreExtensionsToLoadArray of core extensions to load
array$testExtensionsToLoadArray of test extensions to load
array$pathsToLinkInTestInstanceArray of source => destination path pairs to be linked
array$configurationToUseArray of TYPO3_CONF_VARS that need to be overridden
array$additionalFoldersToCreateArray of folder paths to be created
Returns
string Path to TYPO3 CMS test installation for this test case

Definition at line 101 of file FunctionalTestCaseBootstrapUtility.php.

References TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\$instancePath, TYPO3\CMS\Core\Core\Bootstrap\getInstance(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\linkPathsInTestInstance(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\linkTestExtensionsToInstance(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\recentTestInstanceExists(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\removeOldInstanceIfExists(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpBasicTypo3Bootstrap(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpIdentifier(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpInstanceCoreLinks(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpInstanceDirectories(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpInstancePath(), TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpLocalConfiguration(), and TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpPackageStates().

◆ setUpBasicTypo3Bootstrap()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpBasicTypo3Bootstrap ( )
protected

◆ setUpIdentifier()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpIdentifier (   $testCaseClassName)
protected

Calculate a "unique" identifier for the test database and the instance patch based on the given test case class name.

As a result, the database name will be identical between different test runs, but different between each test case.

Parameters
string$testCaseClassNameName of test case class
Returns
void

Definition at line 158 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ setUpInstanceCoreLinks()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpInstanceCoreLinks ( )
protected

Link TYPO3 CMS core from "parent" instance.

Exceptions
Exception
Returns
void

Definition at line 217 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ setUpInstanceDirectories()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpInstanceDirectories ( array  $additionalFoldersToCreate = [])
protected

Create folder structure of test instance.

Parameters
array$additionalFoldersToCreateArray of additional folders to be created
Exceptions
Exception
Returns
void

Definition at line 194 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ setUpInstancePath()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpInstancePath (   $testCaseClassName)
protected

Calculates path to TYPO3 CMS test installation for this test case.

Parameters
string$testCaseClassNameName of test case class
Returns
void

Definition at line 169 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ setUpLocalConfiguration()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpLocalConfiguration ( array  $configurationToMerge)
protected

◆ setUpPackageStates()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::setUpPackageStates ( array  $coreExtensionsToLoad,
array  $testExtensionPaths 
)
protected

Compile typo3conf/PackageStates.php containing default packages like core, a functional test specific list of additional core extensions, and a list of test extensions.

Parameters
array$coreExtensionsToLoadAdditional core extensions to load
array$testExtensionPathsPaths to extensions relative to document root
Exceptions
ExceptionFigure out what the intention of the upper arguments is

Definition at line 390 of file FunctionalTestCaseBootstrapUtility.php.

References TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\arrayExport(), and TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\writeFile().

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUp().

◆ writeFile()

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::writeFile (   $file,
  $content 
)
protected

COPIED FROM GeneralUtility

Writes $content to the file $file

Parameters
string$fileFilepath to write to
string$contentContent to write
Returns
bool TRUE if the file was successfully opened and written to.

Definition at line 669 of file FunctionalTestCaseBootstrapUtility.php.

Referenced by TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpLocalConfiguration(), and TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility\setUpPackageStates().

Member Data Documentation

◆ $databaseName

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::$databaseName
protected

◆ $defaultActivatedCoreExtensions

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::$defaultActivatedCoreExtensions
protected
Initial value:
= [
'core',
'backend',
'frontend',
'lang',
'extbase',
'install',
]

Definition at line 45 of file FunctionalTestCaseBootstrapUtility.php.

◆ $defaultFoldersToCreate

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::$defaultFoldersToCreate
protected
Initial value:
= [
'',
'/fileadmin',
'/typo3temp',
'/typo3conf',
'/typo3conf/ext',
'/uploads'
]

Definition at line 57 of file FunctionalTestCaseBootstrapUtility.php.

◆ $identifier

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::$identifier
protected

◆ $instancePath

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::$instancePath
protected

◆ $originalDatabaseName

TYPO3\CMS\Core\Tests\FunctionalTestCaseBootstrapUtility::$originalDatabaseName
protected

Definition at line 40 of file FunctionalTestCaseBootstrapUtility.php.