Skip to content

Commit

Permalink
ENHANCEMENT Added SapphireTest->usesDatabase flag to explicitly reque…
Browse files Browse the repository at this point in the history
…st building of a test database for a test suite. This is necessitated by r93717, which removed the automatic building of these databases on every run.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@93975 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
chillu committed Nov 30, 2009
1 parent b9bbecd commit ba344f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dev/SapphireTest.php
Expand Up @@ -22,6 +22,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
*/
static $fixture_file = null;

/**
* @var Boolean If set to TRUE, this will force a test database to be generated
* in {@link setUp()}. Note that this flag is overruled by the presence of a
* {@link $fixture_file}, which always forces a database build.
*/
protected $usesDatabase = null;

protected $originalMailer;
protected $originalMemberPasswordValidator;
protected $originalRequirements;
Expand Down Expand Up @@ -70,7 +77,7 @@ function setUp() {
$fixtureFile = eval("return {$className}::\$fixture_file;");

// Set up fixture
if($fixtureFile) {
if($fixtureFile || $this->usesDatabase) {
if(substr(DB::getConn()->currentDatabase(),0,5) != 'tmpdb') {
//echo "Re-creating temp database... ";
self::create_temp_db();
Expand Down
2 changes: 2 additions & 0 deletions tests/forms/CheckboxFieldTest.php
Expand Up @@ -4,6 +4,8 @@
* @subpackage tests
*/
class CheckboxFieldTest extends SapphireTest {

protected $usesDatabase = true;

function testFieldValueTrue() {
/* Create the field, and set the value as boolean true */
Expand Down

0 comments on commit ba344f2

Please sign in to comment.