TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Build\UnitTestsBootstrap Class Reference

Public Member Functions

 bootstrapSystem ()
 

Protected Member Functions

 enableDisplayErrors ()
 
 checkForCliDispatch ()
 
 getWebRoot ()
 
 createNecessaryDirectoriesInDocumentRoot ()
 
 createDirectory ($directory)
 
 includeAndStartCoreBootstrap ()
 
 initializeConfiguration ()
 
 finishCoreBootstrap ()
 
 exitWithMessage ($message)
 

Detailed Description

This file is defined in UnitTests.xml and called by phpunit before instantiating the test suites, it must also be included with phpunit parameter –bootstrap if executing single test case classes.

For easy access to the PHPUnit and VFS framework, it is recommended to install the phpunit TYPO3 Extension It does not need to be activated, nor a cli user needs to be present. But it is also possible to use other installations of PHPUnit and VFS

  • Call whole unit test suite, example:

cd /var/www/t3master/foo # Document root of TYPO3 CMS sources (location of index.php)

  • typo3/../bin/phpunit -c typo3/sysext/core/Build/UnitTests.xml

Call single test case, example:

Definition at line 38 of file UnitTestsBootstrap.php.

Member Function Documentation

◆ bootstrapSystem()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::bootstrapSystem ( )

Bootstraps the system for unit tests.

Returns
void

Definition at line 45 of file UnitTestsBootstrap.php.

References TYPO3\CMS\Core\Build\UnitTestsBootstrap\enableDisplayErrors().

◆ checkForCliDispatch()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::checkForCliDispatch ( )
protected

Checks whether the tests are run using the CLI dispatcher. If so, echos a helpful message and exits with an error code 1.

Returns
UnitTestsBootstrap fluent interface

Definition at line 74 of file UnitTestsBootstrap.php.

References TYPO3\CMS\Core\Build\UnitTestsBootstrap\exitWithMessage(), and TYPO3\CMS\Core\Build\UnitTestsBootstrap\getWebRoot().

◆ createDirectory()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::createDirectory (   $directory)
protected

Creates the directory $directory (recursively if required).

If $directory already exists, this method is a no-op.

Parameters
string$directoryabsolute path of the directory to be created
Returns
void
Exceptions

Definition at line 171 of file UnitTestsBootstrap.php.

Referenced by TYPO3\CMS\Core\Build\UnitTestsBootstrap\createNecessaryDirectoriesInDocumentRoot().

◆ createNecessaryDirectoriesInDocumentRoot()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::createNecessaryDirectoriesInDocumentRoot ( )
protected

Creates the following directories in the TYPO3 document root:

  • typo3conf
  • typo3conf/ext
  • typo3temp
  • uploads
Returns
UnitTestsBootstrap fluent interface

Definition at line 153 of file UnitTestsBootstrap.php.

References TYPO3\CMS\Core\Build\UnitTestsBootstrap\createDirectory().

◆ enableDisplayErrors()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::enableDisplayErrors ( )
protected

Makes sure error messages during the tests get displayed no matter what is set in php.ini.

Returns
UnitTestsBootstrap fluent interface

Definition at line 62 of file UnitTestsBootstrap.php.

Referenced by TYPO3\CMS\Core\Build\UnitTestsBootstrap\bootstrapSystem().

◆ exitWithMessage()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::exitWithMessage (   $message)
protected

Echo out a text message and exit with error code

Parameters
string$message

Definition at line 240 of file UnitTestsBootstrap.php.

References TYPO3\CMS\Core\Build\$bootstrap.

Referenced by TYPO3\CMS\Core\Build\UnitTestsBootstrap\checkForCliDispatch(), and TYPO3\CMS\Core\Build\UnitTestsBootstrap\includeAndStartCoreBootstrap().

◆ finishCoreBootstrap()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::finishCoreBootstrap ( )
protected

Finishes the last steps of the Core Bootstrap.

Returns
UnitTestsBootstrap fluent interface

Definition at line 224 of file UnitTestsBootstrap.php.

References TYPO3\CMS\Core\Core\Bootstrap\getInstance().

◆ getWebRoot()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::getWebRoot ( )
protected

Returns the absolute path the TYPO3 document root.

Returns
string the TYPO3 document root using Unix path separators

Definition at line 114 of file UnitTestsBootstrap.php.

References $GLOBALS, and TYPO3\CMS\Core\Core\Bootstrap\getInstance().

Referenced by TYPO3\CMS\Core\Build\UnitTestsBootstrap\checkForCliDispatch().

◆ includeAndStartCoreBootstrap()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::includeAndStartCoreBootstrap ( )
protected

Includes the Core Bootstrap class and calls its first few functions.

Returns
UnitTestsBootstrap fluent interface

Definition at line 188 of file UnitTestsBootstrap.php.

References TYPO3\CMS\Core\Build\UnitTestsBootstrap\exitWithMessage(), and TYPO3\CMS\Core\Core\Bootstrap\getInstance().

◆ initializeConfiguration()

TYPO3\CMS\Core\Build\UnitTestsBootstrap::initializeConfiguration ( )
protected

Provides the default configuration in $GLOBALS['TYPO3_CONF_VARS'].

Returns
UnitTestsBootstrap fluent interface

Definition at line 208 of file UnitTestsBootstrap.php.

References $GLOBALS.