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,9 +43,11 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
// Table will have been initially created by the $extraDataObjects setting
|
// Table will have been initially created by the $extraDataObjects setting
|
||||||
|
|
||||||
// Let's insert a new field here
|
// Let's insert a new field here
|
||||||
$oldDB = DataObjectSchemaGenerationTest_DO::$db;
|
Config::nest();
|
||||||
DataObjectSchemaGenerationTest_DO::$db['SecretField'] = 'Varchar(100)';
|
Config::inst()->update('DataObjectSchemaGenerationTest_DO', 'db', array(
|
||||||
|
'SecretField' => 'Varchar(100)'
|
||||||
|
));
|
||||||
|
|
||||||
// Verify that the above extra field triggered a schema update
|
// Verify that the above extra field triggered a schema update
|
||||||
$db->beginSchemaUpdate();
|
$db->beginSchemaUpdate();
|
||||||
$obj = new DataObjectSchemaGenerationTest_DO();
|
$obj = new DataObjectSchemaGenerationTest_DO();
|
||||||
@ -55,7 +57,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$this->assertTrue($needsUpdating);
|
$this->assertTrue($needsUpdating);
|
||||||
|
|
||||||
// Restore db configuration
|
// Restore db configuration
|
||||||
DataObjectSchemaGenerationTest_DO::$db = $oldDB;
|
Config::unnest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,9 +78,12 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$this->assertFalse($needsUpdating);
|
$this->assertFalse($needsUpdating);
|
||||||
|
|
||||||
// Test with alternate index format, although these indexes are the same
|
// Test with alternate index format, although these indexes are the same
|
||||||
$oldIndexes = DataObjectSchemaGenerationTest_IndexDO::$indexes;
|
Config::nest();
|
||||||
DataObjectSchemaGenerationTest_IndexDO::$indexes = DataObjectSchemaGenerationTest_IndexDO::$indexes_alt;
|
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
|
// Verify that it still doesn't need to be recreated
|
||||||
$db->beginSchemaUpdate();
|
$db->beginSchemaUpdate();
|
||||||
$obj2 = new DataObjectSchemaGenerationTest_IndexDO();
|
$obj2 = new DataObjectSchemaGenerationTest_IndexDO();
|
||||||
@ -88,7 +93,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$this->assertFalse($needsUpdating);
|
$this->assertFalse($needsUpdating);
|
||||||
|
|
||||||
// Restore old index format
|
// Restore old index format
|
||||||
DataObjectSchemaGenerationTest_IndexDO::$indexes = $oldIndexes;
|
Config::unnest();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,9 +106,13 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
// Table will have been initially created by the $extraDataObjects setting
|
// Table will have been initially created by the $extraDataObjects setting
|
||||||
|
|
||||||
// Update the SearchFields index here
|
// Update the SearchFields index here
|
||||||
$oldIndexes = DataObjectSchemaGenerationTest_IndexDO::$indexes;
|
Config::nest();
|
||||||
DataObjectSchemaGenerationTest_IndexDO::$indexes['SearchFields']['value'] = '"Title"';
|
Config::inst()->update('DataObjectSchemaGenerationTest_IndexDO', 'indexes', array(
|
||||||
|
'SearchFields' => array(
|
||||||
|
'value' => 'Title'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
// Verify that the above index change triggered a schema update
|
// Verify that the above index change triggered a schema update
|
||||||
$db->beginSchemaUpdate();
|
$db->beginSchemaUpdate();
|
||||||
$obj = new DataObjectSchemaGenerationTest_IndexDO();
|
$obj = new DataObjectSchemaGenerationTest_IndexDO();
|
||||||
@ -113,7 +122,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$this->assertTrue($needsUpdating);
|
$this->assertTrue($needsUpdating);
|
||||||
|
|
||||||
// Restore old indexes
|
// Restore old indexes
|
||||||
DataObjectSchemaGenerationTest_IndexDO::$indexes = $oldIndexes;
|
Config::unnest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user