update to drupal 7.23
This commit is contained in:
@@ -44,7 +44,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
db_create_table('test_table', $table_specification);
|
||||
|
||||
// Assert that the table exists.
|
||||
$this->assertTrue(db_table_exists('test_table'), t('The table exists.'));
|
||||
$this->assertTrue(db_table_exists('test_table'), 'The table exists.');
|
||||
|
||||
// Assert that the table comment has been set.
|
||||
$this->checkSchemaComment($table_specification['description'], 'test_table');
|
||||
@@ -53,46 +53,46 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
$this->checkSchemaComment($table_specification['fields']['test_field']['description'], 'test_table', 'test_field');
|
||||
|
||||
// An insert without a value for the column 'test_table' should fail.
|
||||
$this->assertFalse($this->tryInsert(), t('Insert without a default failed.'));
|
||||
$this->assertFalse($this->tryInsert(), 'Insert without a default failed.');
|
||||
|
||||
// Add a default value to the column.
|
||||
db_field_set_default('test_table', 'test_field', 0);
|
||||
// The insert should now succeed.
|
||||
$this->assertTrue($this->tryInsert(), t('Insert with a default succeeded.'));
|
||||
$this->assertTrue($this->tryInsert(), 'Insert with a default succeeded.');
|
||||
|
||||
// Remove the default.
|
||||
db_field_set_no_default('test_table', 'test_field');
|
||||
// The insert should fail again.
|
||||
$this->assertFalse($this->tryInsert(), t('Insert without a default failed.'));
|
||||
$this->assertFalse($this->tryInsert(), 'Insert without a default failed.');
|
||||
|
||||
// Test for fake index and test for the boolean result of indexExists().
|
||||
$index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
|
||||
$this->assertIdentical($index_exists, FALSE, t('Fake index does not exists'));
|
||||
$this->assertIdentical($index_exists, FALSE, 'Fake index does not exists');
|
||||
// Add index.
|
||||
db_add_index('test_table', 'test_field', array('test_field'));
|
||||
// Test for created index and test for the boolean result of indexExists().
|
||||
$index_exists = Database::getConnection()->schema()->indexExists('test_table', 'test_field');
|
||||
$this->assertIdentical($index_exists, TRUE, t('Index created.'));
|
||||
$this->assertIdentical($index_exists, TRUE, 'Index created.');
|
||||
|
||||
// Rename the table.
|
||||
db_rename_table('test_table', 'test_table2');
|
||||
|
||||
// Index should be renamed.
|
||||
$index_exists = Database::getConnection()->schema()->indexExists('test_table2', 'test_field');
|
||||
$this->assertTrue($index_exists, t('Index was renamed.'));
|
||||
$this->assertTrue($index_exists, 'Index was renamed.');
|
||||
|
||||
// We need the default so that we can insert after the rename.
|
||||
db_field_set_default('test_table2', 'test_field', 0);
|
||||
$this->assertFalse($this->tryInsert(), t('Insert into the old table failed.'));
|
||||
$this->assertTrue($this->tryInsert('test_table2'), t('Insert into the new table succeeded.'));
|
||||
$this->assertFalse($this->tryInsert(), 'Insert into the old table failed.');
|
||||
$this->assertTrue($this->tryInsert('test_table2'), 'Insert into the new table succeeded.');
|
||||
|
||||
// We should have successfully inserted exactly two rows.
|
||||
$count = db_query('SELECT COUNT(*) FROM {test_table2}')->fetchField();
|
||||
$this->assertEqual($count, 2, t('Two fields were successfully inserted.'));
|
||||
$this->assertEqual($count, 2, 'Two fields were successfully inserted.');
|
||||
|
||||
// Try to drop the table.
|
||||
db_drop_table('test_table2');
|
||||
$this->assertFalse(db_table_exists('test_table2'), t('The dropped table does not exist.'));
|
||||
$this->assertFalse(db_table_exists('test_table2'), 'The dropped table does not exist.');
|
||||
|
||||
// Recreate the table.
|
||||
db_create_table('test_table', $table_specification);
|
||||
@@ -108,14 +108,14 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
// Assert that the column comment has been set.
|
||||
$this->checkSchemaComment('Changed column description.', 'test_table', 'test_serial');
|
||||
|
||||
$this->assertTrue($this->tryInsert(), t('Insert with a serial succeeded.'));
|
||||
$this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.');
|
||||
$max1 = db_query('SELECT MAX(test_serial) FROM {test_table}')->fetchField();
|
||||
$this->assertTrue($this->tryInsert(), t('Insert with a serial succeeded.'));
|
||||
$this->assertTrue($this->tryInsert(), 'Insert with a serial succeeded.');
|
||||
$max2 = db_query('SELECT MAX(test_serial) FROM {test_table}')->fetchField();
|
||||
$this->assertTrue($max2 > $max1, t('The serial is monotone.'));
|
||||
$this->assertTrue($max2 > $max1, 'The serial is monotone.');
|
||||
|
||||
$count = db_query('SELECT COUNT(*) FROM {test_table}')->fetchField();
|
||||
$this->assertEqual($count, 2, t('There were two rows.'));
|
||||
$this->assertEqual($count, 2, 'There were two rows.');
|
||||
|
||||
// Use database specific data type and ensure that table is created.
|
||||
$table_specification = array(
|
||||
@@ -134,7 +134,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
db_create_table('test_timestamp', $table_specification);
|
||||
}
|
||||
catch (Exception $e) {}
|
||||
$this->assertTrue(db_table_exists('test_timestamp'), t('Table with database specific datatype was created.'));
|
||||
$this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
|
||||
}
|
||||
|
||||
function tryInsert($table = 'test_table') {
|
||||
@@ -162,7 +162,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
function checkSchemaComment($description, $table, $column = NULL) {
|
||||
if (method_exists(Database::getConnection()->schema(), 'getComment')) {
|
||||
$comment = Database::getConnection()->schema()->getComment($table, $column);
|
||||
$this->assertEqual($comment, $description, t('The comment matches the schema description.'));
|
||||
$this->assertEqual($comment, $description, 'The comment matches the schema description.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,8 +193,8 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
|
||||
// Finally, check each column and try to insert invalid values into them.
|
||||
foreach ($table_spec['fields'] as $column_name => $column_spec) {
|
||||
$this->assertTrue(db_field_exists($table_name, $column_name), t('Unsigned @type column was created.', array('@type' => $column_spec['type'])));
|
||||
$this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), t('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type'])));
|
||||
$this->assertTrue(db_field_exists($table_name, $column_name), format_string('Unsigned @type column was created.', array('@type' => $column_spec['type'])));
|
||||
$this->assertFalse($this->tryUnsignedInsert($table_name, $column_name), format_string('Unsigned @type column rejected a negative value.', array('@type' => $column_spec['type'])));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,7 +312,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
'primary key' => array('serial_column'),
|
||||
);
|
||||
db_create_table($table_name, $table_spec);
|
||||
$this->pass(t('Table %table created.', array('%table' => $table_name)));
|
||||
$this->pass(format_string('Table %table created.', array('%table' => $table_name)));
|
||||
|
||||
// Check the characteristics of the field.
|
||||
$this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
|
||||
@@ -329,7 +329,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
'primary key' => array('serial_column'),
|
||||
);
|
||||
db_create_table($table_name, $table_spec);
|
||||
$this->pass(t('Table %table created.', array('%table' => $table_name)));
|
||||
$this->pass(format_string('Table %table created.', array('%table' => $table_name)));
|
||||
|
||||
// Insert some rows to the table to test the handling of initial values.
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
@@ -339,7 +339,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
}
|
||||
|
||||
db_add_field($table_name, 'test_field', $field_spec);
|
||||
$this->pass(t('Column %column created.', array('%column' => 'test_field')));
|
||||
$this->pass(format_string('Column %column created.', array('%column' => 'test_field')));
|
||||
|
||||
// Check the characteristics of the field.
|
||||
$this->assertFieldCharacteristics($table_name, 'test_field', $field_spec);
|
||||
@@ -362,7 +362,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
->countQuery()
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertEqual($count, 0, t('Initial values filled out.'));
|
||||
$this->assertEqual($count, 0, 'Initial values filled out.');
|
||||
}
|
||||
|
||||
// Check that the default value has been registered.
|
||||
@@ -376,7 +376,7 @@ class SchemaTestCase extends DrupalWebTestCase {
|
||||
->condition('serial_column', $id)
|
||||
->execute()
|
||||
->fetchField();
|
||||
$this->assertEqual($field_value, $field_spec['default'], t('Default value registered.'));
|
||||
$this->assertEqual($field_value, $field_spec['default'], 'Default value registered.');
|
||||
}
|
||||
|
||||
db_drop_field($table_name, $field_name);
|
||||
|
||||
Reference in New Issue
Block a user