PHPUnit
PHPUnit TYPO3 extension
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Tx_Phpunit_Database_TestCase Class Reference
Inheritance diagram for Tx_Phpunit_Database_TestCase:
Tx_Phpunit_TestCase

Public Member Functions

 __construct ($name=NULL, array $data=array(), $dataName= '')
 

Protected Member Functions

 switchToTypo3Database ()
 
 createDatabase ()
 
 cleanDatabase ()
 
 dropDatabase ()
 
 useTestDatabase ($databaseName=NULL)
 
 selectDatabase ($databaseName, DatabaseConnection $database)
 
 switchToOriginalTypo3Database ($databaseObject)
 
 importExtensions (array $extensions, $importDependencies=FALSE, array &$skipDependencies=array())
 
 getDatabaseTables ($databaseName=NULL)
 
- Protected Member Functions inherited from Tx_Phpunit_TestCase
 getAccessibleMock ($originalClassName, array $methods=array(), array $arguments=array(), $mockClassName= '', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
 
 buildAccessibleProxy ($className)
 

Protected Attributes

 $testDatabase = ''
 
- Protected Attributes inherited from Tx_Phpunit_TestCase
 $backupGlobals = FALSE
 
 $backupStaticAttributes = FALSE
 

Constructor & Destructor Documentation

Tx_Phpunit_Database_TestCase::__construct (   $name = NULL,
array  $data = array(),
  $dataName = '' 
)

Constructs a test case with the given name.

Parameters
string$namethe name of a testcase
array$data?
string$dataName?

Member Function Documentation

Tx_Phpunit_Database_TestCase::cleanDatabase ( )
protected

Drops all tables in the test database.

Returns
void
Tx_Phpunit_Database_TestCase::createDatabase ( )
protected

Accesses the TYPO3 database instance and uses it to fetch the list of available databases. Then this function creates a test database (if none has been set up yet).

Returns
bool TRUE if the database has been created successfully (or if there already is a test database), FALSE otherwise
Tx_Phpunit_Database_TestCase::dropDatabase ( )
protected

Drops the test database.

Returns
bool TRUE if the database has been dropped successfully, FALSE otherwise
Tx_Phpunit_Database_TestCase::getDatabaseTables (   $databaseName = NULL)
protected

Gets the names of all tables in the database with the given name.

Parameters
string$databaseNamethe name of the database from which to retrieve the table names, if none is provided, the name of the current TYPO3 database plus a suffix "_test" is used
Returns
string[] the names of all tables in the database $databaseName, might be empty
Tx_Phpunit_Database_TestCase::importExtensions ( array  $extensions,
  $importDependencies = FALSE,
array &  $skipDependencies = array() 
)
protected

Imports the ext_tables.sql statements from the given extensions.

Parameters
string[]$extensions keys of the extensions to import, may be empty
bool$importDependencieswhether to import dependency extensions on which the given extensions depend as well
string[]&$skipDependencies keys of the extensions to skip, may be empty, will be modified
Returns
void
Tx_Phpunit_Database_TestCase::selectDatabase (   $databaseName,
DatabaseConnection  $database 
)
protected

Selects the database depending on TYPO3 version.

Parameters
string$databaseNamethe name of the database to select
DatabaseConnection$databasedatabase object to process the change
Returns
bool
Tx_Phpunit_Database_TestCase::switchToOriginalTypo3Database (   $databaseObject)
protected

Switch to the original database

Parameters
DatabaseConnection$databaseObjectThe database object
Returns
void
Tx_Phpunit_Database_TestCase::switchToTypo3Database ( )
protected

Selects the TYPO3 database (again).

If you have selected any non-TYPO3 in your unit tests, you need to call this function in tearDown() in order to avoid problems with the following unit tests and the TYPO3 back-end.

Returns
void
Tx_Phpunit_Database_TestCase::useTestDatabase (   $databaseName = NULL)
protected

Sets the TYPO3 database instance to a test database.

Note: This function does not back up the currenty TYPO3 database instance.

Parameters
string$databaseNamethe name of the test database to use; if none is provided, the name of the current TYPO3 database plus a suffix "_test" is used
Returns
DatabaseConnection the test database

The documentation for this class was generated from the following file: