/**
  * Check that once a schema has been generated, then it doesn't need any more updating
  */
 function testFieldsDontRerequestChanges()
 {
     $db = DB::getConn();
     DB::quiet();
     // Table will have been initially created by the $extraDataObjects setting
     // Verify that it doesn't need to be recreated
     $db->beginSchemaUpdate();
     $obj = new DataObjectSchemaGenerationTest_DO();
     $obj->requireTable();
     $needsUpdating = $db->doesSchemaNeedUpdating();
     $db->cancelSchemaUpdate();
     $this->assertFalse($needsUpdating);
 }
 /**
  * Check that updates to a class fields are reflected in the database
  */
 public function testFieldsRequestChanges()
 {
     $db = DB::getConn();
     DB::quiet();
     // Table will have been initially created by the $extraDataObjects setting
     // Let's insert a new field here
     Config::inst()->update('DataObjectSchemaGenerationTest_DO', 'db', array('SecretField' => 'Varchar(100)'));
     // Verify that the above extra field triggered a schema update
     $db->beginSchemaUpdate();
     $obj = new DataObjectSchemaGenerationTest_DO();
     $obj->requireTable();
     $needsUpdating = $db->doesSchemaNeedUpdating();
     $db->cancelSchemaUpdate();
     $this->assertTrue($needsUpdating);
 }
 /**
  * Check that updates to a class fields are reflected in the database
  */
 public function testFieldsRequestChanges()
 {
     $db = DB::getConn();
     DB::quiet();
     // 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)';
     // Verify that the above extra field triggered a schema update
     $db->beginSchemaUpdate();
     $obj = new DataObjectSchemaGenerationTest_DO();
     $obj->requireTable();
     $needsUpdating = $db->doesSchemaNeedUpdating();
     $db->cancelSchemaUpdate();
     $this->assertTrue($needsUpdating);
     // Restore db configuration
     DataObjectSchemaGenerationTest_DO::$db = $oldDB;
 }
 /**
  * Check that updates to a class fields are reflected in the database
  */
 public function testFieldsRequestChanges()
 {
     $schema = DB::get_schema();
     $test = $this;
     DB::quiet();
     // Table will have been initially created by the $extraDataObjects setting
     // Let's insert a new field here
     Config::nest();
     Config::inst()->update('DataObjectSchemaGenerationTest_DO', 'db', array('SecretField' => 'Varchar(100)'));
     // Verify that the above extra field triggered a schema update
     $schema->schemaUpdate(function () use($test, $schema) {
         $obj = new DataObjectSchemaGenerationTest_DO();
         $obj->requireTable();
         $needsUpdating = $schema->doesSchemaNeedUpdating();
         $schema->cancelSchemaUpdate();
         $test->assertTrue($needsUpdating);
     });
     // Restore db configuration
     Config::unnest();
 }