summaryrefslogtreecommitdiff
path: root/modules/simpletest/tests/database_test.install
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2008-08-31 11:43:41 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2008-08-31 11:43:41 +0000
commit382f4a8c5fc7d60dd1b27f204db16947f6198c16 (patch)
treedd28a5320ad77562b0a6a625a23026d7a50a74d2 /modules/simpletest/tests/database_test.install
parentdf4b23bfee6f6db2226da06e937687b187b521c5 (diff)
downloadbrdo-382f4a8c5fc7d60dd1b27f204db16947f6198c16.tar.gz
brdo-382f4a8c5fc7d60dd1b27f204db16947f6198c16.tar.bz2
#276276 by Crell and florbuit: New database system unit tests. WOOHOO! :D
Diffstat (limited to 'modules/simpletest/tests/database_test.install')
-rw-r--r--modules/simpletest/tests/database_test.install168
1 files changed, 168 insertions, 0 deletions
diff --git a/modules/simpletest/tests/database_test.install b/modules/simpletest/tests/database_test.install
new file mode 100644
index 000000000..e2fcb1b77
--- /dev/null
+++ b/modules/simpletest/tests/database_test.install
@@ -0,0 +1,168 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_schema().
+ *
+ * The database tests use the database API which depends on schema
+ * information for certain operations on certain databases.
+ * Therefore, the schema must actually be declared in a normal module
+ * like any other, not directly in the test file.
+ */
+function database_test_schema() {
+ $schema['test'] = array(
+ 'description' => 'Basic test table for the database unit tests.',
+ 'fields' => array(
+ 'id' => array(
+ 'type' => 'serial',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ ),
+ 'name' => array(
+ 'description' => "A person's name",
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'age' => array(
+ 'description' => "The person's age",
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0),
+ 'job' => array(
+ 'description' => "The person's job",
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => 'Undefined',
+ ),
+ ),
+ 'primary key' => array('id'),
+ 'unique keys' => array(
+ 'name' => array('name')
+ ),
+ 'indexes' => array(
+ 'ages' => array('age'),
+ ),
+ );
+
+ // This is an alternate version of the same table that is structured the same
+ // but has a non-serial Primary Key.
+ $schema['test_people'] = array(
+ 'description' => 'A duplicate version of the test table, used for additional tests.',
+ 'fields' => array(
+ 'name' => array(
+ 'description' => "A person's name",
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'age' => array(
+ 'description' => "The person's age",
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'job' => array(
+ 'description' => "The person's job",
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ ),
+ 'primary key' => array('job'),
+ 'indexes' => array(
+ 'ages' => array('age'),
+ ),
+ );
+
+ $schema['test_one_blob'] = array(
+ 'description' => 'A simple table including a BLOB field for testing BLOB behavior.',
+ 'fields' => array(
+ 'id' => array(
+ 'description' => 'Simple unique ID.',
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'blob1' => array(
+ 'description' => 'A BLOB field.',
+ 'type' => 'blob',
+ ),
+ ),
+ 'primary key' => array('id'),
+ );
+
+ $schema['test_two_blobs'] = array(
+ 'description' => 'A simple test table with two BLOB fields.',
+ 'fields' => array(
+ 'id' => array(
+ 'description' => 'Simple unique ID.',
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'blob1' => array(
+ 'description' => 'A dummy BLOB field.',
+ 'type' => 'blob',
+ ),
+ 'blob2' => array(
+ 'description' => 'A second BLOB field.',
+ 'type' => 'blob'
+ ),
+ ),
+ 'primary key' => array('id'),
+ );
+
+ $schema['test_task'] = array(
+ 'description' => 'A task list for people in the test table.',
+ 'fields' => array(
+ 'tid' => array(
+ 'description' => 'Task ID, primary key.',
+ 'type' => 'serial',
+ 'not null' => TRUE,
+ ),
+ 'pid' => array(
+ 'description' => 'The {test_people}.pid, foreign key for the test table.',
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ 'task' => array(
+ 'description' => 'The task to be completed.',
+ 'type' => 'varchar',
+ 'length' => 255,
+ 'not null' => TRUE,
+ 'default' => '',
+ ),
+ 'priority' => array(
+ 'description' => 'The priority of the task.',
+ 'type' => 'int',
+ 'unsigned' => TRUE,
+ 'not null' => TRUE,
+ 'default' => 0,
+ ),
+ ),
+ 'primary key' => array('tid'),
+ );
+
+ return $schema;
+}
+
+/**
+ * Implementation of hook_install().
+ */
+function database_test_install() {
+ drupal_install_schema('database_test');
+}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function database_test_uninstall() {
+ drupal_uninstall_schema('database_test');
+}