|
@@ 86-106 (lines=21) @@
|
| 83 |
|
/** |
| 84 |
|
* Check that updates to a class fields are reflected in the database |
| 85 |
|
*/ |
| 86 |
|
public function testFieldsRequestChanges() { |
| 87 |
|
$schema = DB::get_schema(); |
| 88 |
|
$test = $this; |
| 89 |
|
DB::quiet(); |
| 90 |
|
|
| 91 |
|
// Table will have been initially created by the $extraDataObjects setting |
| 92 |
|
|
| 93 |
|
// Let's insert a new field here |
| 94 |
|
Config::inst()->update('DataObjectSchemaGenerationTest_DO', 'db', array( |
| 95 |
|
'SecretField' => 'Varchar(100)' |
| 96 |
|
)); |
| 97 |
|
|
| 98 |
|
// Verify that the above extra field triggered a schema update |
| 99 |
|
$schema->schemaUpdate(function() use ($test, $schema) { |
| 100 |
|
$obj = new DataObjectSchemaGenerationTest_DO(); |
| 101 |
|
$obj->requireTable(); |
| 102 |
|
$needsUpdating = $schema->doesSchemaNeedUpdating(); |
| 103 |
|
$schema->cancelSchemaUpdate(); |
| 104 |
|
$test->assertTrue($needsUpdating); |
| 105 |
|
}); |
| 106 |
|
} |
| 107 |
|
|
| 108 |
|
/** |
| 109 |
|
* Check that indexes on a newly generated class do not subsequently request modification |
|
@@ 146-168 (lines=23) @@
|
| 143 |
|
/** |
| 144 |
|
* Check that updates to a dataobject's indexes are reflected in DDL |
| 145 |
|
*/ |
| 146 |
|
public function testIndexesRerequestChanges() { |
| 147 |
|
$schema = DB::get_schema(); |
| 148 |
|
$test = $this; |
| 149 |
|
DB::quiet(); |
| 150 |
|
|
| 151 |
|
// Table will have been initially created by the $extraDataObjects setting |
| 152 |
|
|
| 153 |
|
// Update the SearchFields index here |
| 154 |
|
Config::inst()->update('DataObjectSchemaGenerationTest_IndexDO', 'indexes', array( |
| 155 |
|
'SearchFields' => array( |
| 156 |
|
'value' => 'Title' |
| 157 |
|
) |
| 158 |
|
)); |
| 159 |
|
|
| 160 |
|
// Verify that the above index change triggered a schema update |
| 161 |
|
$schema->schemaUpdate(function() use ($test, $schema) { |
| 162 |
|
$obj = new DataObjectSchemaGenerationTest_IndexDO(); |
| 163 |
|
$obj->requireTable(); |
| 164 |
|
$needsUpdating = $schema->doesSchemaNeedUpdating(); |
| 165 |
|
$schema->cancelSchemaUpdate(); |
| 166 |
|
$test->assertTrue($needsUpdating); |
| 167 |
|
}); |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
/** |
| 171 |
|
* Tests the generation of the ClassName spec and ensure it's not unnecessarily influenced |