mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
117806756c
ENHANCEMENT Added DatabaseTest git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@65494 467b73ca-7a2a-4603-9d3b-597d59a354a9
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage Testing
|
|
*/
|
|
class DatabaseTest extends SapphireTest {
|
|
|
|
function testDontRequireField() {
|
|
$conn = DB::getConn();
|
|
$this->assertArrayHasKey(
|
|
'MyField',
|
|
$conn->fieldList('DatabaseTest_MyObject')
|
|
);
|
|
|
|
$conn->dontRequireField('DatabaseTest_MyObject', 'MyField');
|
|
$this->assertArrayHasKey(
|
|
'_obsolete_MyField',
|
|
$conn->fieldList('DatabaseTest_MyObject'),
|
|
'Field is renamed to _obsolete_<fieldname> through dontRequireField()'
|
|
);
|
|
|
|
// tested schema updates, so need to rebuild the database
|
|
self::kill_temp_db();
|
|
self::create_temp_db();
|
|
}
|
|
|
|
function testRenameField() {
|
|
$conn = DB::getConn();
|
|
|
|
$conn->renameField('DatabaseTest_MyObject', 'MyField', 'MyRenamedField');
|
|
|
|
$this->assertArrayHasKey(
|
|
'MyRenamedField',
|
|
$conn->fieldList('DatabaseTest_MyObject'),
|
|
'New fieldname is set through renameField()'
|
|
);
|
|
$this->assertArrayNotHasKey(
|
|
'MyField',
|
|
$conn->fieldList('DatabaseTest_MyObject'),
|
|
'Old fieldname isnt preserved through renameField()'
|
|
);
|
|
|
|
// tested schema updates, so need to rebuild the database
|
|
self::kill_temp_db();
|
|
self::create_temp_db();
|
|
}
|
|
|
|
}
|
|
|
|
class DatabaseTest_MyObject extends DataObject implements TestOnly {
|
|
static $db = array(
|
|
'MyField' => 'Varchar'
|
|
);
|
|
}
|
|
?>
|