mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-31 05:50:42 +02:00
[feature/dbal-tests] Added database test & refactored test framework
There is now a phpbb_database_test_case which can be used as a base class for tests that require database access. You have to set up a test_config.php file in your tests/ directory containing host, user, pass etc. Extra test functionality has been moved to phpbb_test_case_helpers to provide the same functionality in database tests and regular tests without duplicating the code. This is achieved through delegation of method calls.
This commit is contained in:
@@ -9,29 +9,19 @@
|
||||
|
||||
class phpbb_test_case extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $expectedTriggerError = false;
|
||||
protected $test_case_helpers;
|
||||
|
||||
public function init_test_case_helpers()
|
||||
{
|
||||
if (!$this->test_case_helpers)
|
||||
{
|
||||
$this->test_case_helpers = new phpbb_test_case_helpers($this);
|
||||
}
|
||||
}
|
||||
|
||||
public function setExpectedTriggerError($errno, $message = '')
|
||||
{
|
||||
$exceptionName = '';
|
||||
switch ($errno)
|
||||
{
|
||||
case E_NOTICE:
|
||||
case E_STRICT:
|
||||
PHPUnit_Framework_Error_Notice::$enabled = true;
|
||||
$exceptionName = 'PHPUnit_Framework_Error_Notice';
|
||||
break;
|
||||
|
||||
case E_WARNING:
|
||||
PHPUnit_Framework_Error_Warning::$enabled = true;
|
||||
$exceptionName = 'PHPUnit_Framework_Error_Warning';
|
||||
break;
|
||||
|
||||
default:
|
||||
$exceptionName = 'PHPUnit_Framework_Error';
|
||||
break;
|
||||
}
|
||||
$this->expectedTriggerError = true;
|
||||
$this->setExpectedException($exceptionName, (string) $message, $errno);
|
||||
$this->init_test_case_helpers();
|
||||
$this->test_case_helpers->setExpectedTriggerError($errno, $message);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user