public function testTablesAreCreated()
 {
     $tables = DB::table_list();
     $check = array('versionableextensionstest_dataobject_test1_live', 'versionableextensionstest_dataobject_test2_live', 'versionableextensionstest_dataobject_test3_live', 'versionableextensionstest_dataobject_test1_versions', 'versionableextensionstest_dataobject_test2_versions', 'versionableextensionstest_dataobject_test3_versions');
     // Check that the right tables exist
     foreach ($check as $tableName) {
         $this->assertContains($tableName, array_keys($tables), 'Contains table: ' . $tableName);
     }
 }
 public function testTableCaseFixed()
 {
     DB::quiet();
     // Modify table case
     DB::get_schema()->renameTable('DataObjectSchemaGenerationTest_DO', '__TEMP__DataOBJECTSchemaGenerationTest_do');
     DB::get_schema()->renameTable('__TEMP__DataOBJECTSchemaGenerationTest_do', 'DataOBJECTSchemaGenerationTest_do');
     // Check table
     $tables = DB::table_list();
     $this->assertEquals('DataOBJECTSchemaGenerationTest_do', $tables['dataobjectschemagenerationtest_do']);
     // Rebuild table
     DB::get_schema()->schemaUpdate(function () {
         DataObjectSchemaGenerationTest_DO::singleton()->requireTable();
     });
     // Check table
     $tables = DB::table_list();
     $this->assertEquals('DataObjectSchemaGenerationTest_DO', $tables['dataobjectschemagenerationtest_do']);
 }
 public function testVersionedWithSingleStage()
 {
     $tables = DB::table_list();
     $this->assertContains('versionedtest_singlestage', array_keys($tables), 'Contains base table');
     $this->assertContains('versionedtest_singlestage_versions', array_keys($tables), 'Contains versions table');
     $this->assertNotContains('versionedtest_singlestage_live', array_keys($tables), 'Does not contain separate table with _Live suffix');
     $this->assertNotContains('versionedtest_singlestage_stage', array_keys($tables), 'Does not contain separate table with _Stage suffix');
     Versioned::set_stage(Versioned::DRAFT);
     $obj = new VersionedTest_SingleStage(array('Name' => 'MyObj'));
     $obj->write();
     $this->assertNotNull(VersionedTest_SingleStage::get()->byID($obj->ID), 'Writes to and reads from default stage if its set explicitly');
     Versioned::set_stage(Versioned::LIVE);
     $obj = new VersionedTest_SingleStage(array('Name' => 'MyObj'));
     $obj->write();
     $this->assertNotNull(VersionedTest_SingleStage::get()->byID($obj->ID), 'Writes to and reads from default stage even if a non-matching stage is set');
 }