function SchemaTest::testSchemaChangeField in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/SchemaTest.php \Drupal\system\Tests\Database\SchemaTest::testSchemaChangeField()
Tests changing columns between types.
File
- core/
modules/ system/ src/ Tests/ Database/ SchemaTest.php, line 645 - Contains \Drupal\system\Tests\Database\SchemaTest.
Class
- SchemaTest
- Tests table creation and modification via the schema API.
Namespace
Drupal\system\Tests\DatabaseCode
function testSchemaChangeField() {
$field_specs = array(
array(
'type' => 'int',
'size' => 'normal',
'not null' => FALSE,
),
array(
'type' => 'int',
'size' => 'normal',
'not null' => TRUE,
'initial' => 1,
'default' => 17,
),
array(
'type' => 'float',
'size' => 'normal',
'not null' => FALSE,
),
array(
'type' => 'float',
'size' => 'normal',
'not null' => TRUE,
'initial' => 1,
'default' => 7.3,
),
array(
'type' => 'numeric',
'scale' => 2,
'precision' => 10,
'not null' => FALSE,
),
array(
'type' => 'numeric',
'scale' => 2,
'precision' => 10,
'not null' => TRUE,
'initial' => 1,
'default' => 7,
),
);
foreach ($field_specs as $i => $old_spec) {
foreach ($field_specs as $j => $new_spec) {
if ($i === $j) {
// Do not change a field into itself.
continue;
}
$this
->assertFieldChange($old_spec, $new_spec);
}
}
$field_specs = array(
array(
'type' => 'varchar_ascii',
'length' => '255',
),
array(
'type' => 'varchar',
'length' => '255',
),
array(
'type' => 'text',
),
array(
'type' => 'blob',
'size' => 'big',
),
);
foreach ($field_specs as $i => $old_spec) {
foreach ($field_specs as $j => $new_spec) {
if ($i === $j) {
// Do not change a field into itself.
continue;
}
// Note if the serialized data contained an object this would fail on
// Postgres.
// @see https://www.drupal.org/node/1031122
$this
->assertFieldChange($old_spec, $new_spec, serialize([
'string' => "This \n has \\\\ some backslash \"*string action.\\n",
]));
}
}
}