mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX DataObjectSchemaGenerationTest trying to modify config statics directly
This commit is contained in:
parent
024a0b90a9
commit
80bd38e1e9
@ -43,8 +43,10 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||
// Table will have been initially created by the $extraDataObjects setting
|
||||
|
||||
// Let's insert a new field here
|
||||
$oldDB = DataObjectSchemaGenerationTest_DO::$db;
|
||||
DataObjectSchemaGenerationTest_DO::$db['SecretField'] = 'Varchar(100)';
|
||||
Config::nest();
|
||||
Config::inst()->update('DataObjectSchemaGenerationTest_DO', 'db', array(
|
||||
'SecretField' => 'Varchar(100)'
|
||||
));
|
||||
|
||||
// Verify that the above extra field triggered a schema update
|
||||
$db->beginSchemaUpdate();
|
||||
@ -55,7 +57,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||
$this->assertTrue($needsUpdating);
|
||||
|
||||
// Restore db configuration
|
||||
DataObjectSchemaGenerationTest_DO::$db = $oldDB;
|
||||
Config::unnest();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -76,8 +78,11 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||
$this->assertFalse($needsUpdating);
|
||||
|
||||
// Test with alternate index format, although these indexes are the same
|
||||
$oldIndexes = DataObjectSchemaGenerationTest_IndexDO::$indexes;
|
||||
DataObjectSchemaGenerationTest_IndexDO::$indexes = DataObjectSchemaGenerationTest_IndexDO::$indexes_alt;
|
||||
Config::nest();
|
||||
Config::inst()->remove('DataObjectSchemaGenerationTest_IndexDO', 'indexes');
|
||||
Config::inst()->update('DataObjectSchemaGenerationTest_IndexDO', 'indexes',
|
||||
Config::inst()->get('DataObjectSchemaGenerationTest_IndexDO', 'indexes_alt')
|
||||
);
|
||||
|
||||
// Verify that it still doesn't need to be recreated
|
||||
$db->beginSchemaUpdate();
|
||||
@ -88,7 +93,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||
$this->assertFalse($needsUpdating);
|
||||
|
||||
// Restore old index format
|
||||
DataObjectSchemaGenerationTest_IndexDO::$indexes = $oldIndexes;
|
||||
Config::unnest();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,8 +106,12 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||
// Table will have been initially created by the $extraDataObjects setting
|
||||
|
||||
// Update the SearchFields index here
|
||||
$oldIndexes = DataObjectSchemaGenerationTest_IndexDO::$indexes;
|
||||
DataObjectSchemaGenerationTest_IndexDO::$indexes['SearchFields']['value'] = '"Title"';
|
||||
Config::nest();
|
||||
Config::inst()->update('DataObjectSchemaGenerationTest_IndexDO', 'indexes', array(
|
||||
'SearchFields' => array(
|
||||
'value' => 'Title'
|
||||
)
|
||||
));
|
||||
|
||||
// Verify that the above index change triggered a schema update
|
||||
$db->beginSchemaUpdate();
|
||||
@ -113,7 +122,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||
$this->assertTrue($needsUpdating);
|
||||
|
||||
// Restore old indexes
|
||||
DataObjectSchemaGenerationTest_IndexDO::$indexes = $oldIndexes;
|
||||
Config::unnest();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user