#308534 by Dave Reid: Remove stray whitespace core-wide.

merge-requests/26/head
Angie Byron 2008-09-15 20:48:10 +00:00
parent cf987be12d
commit 161a9970f7
25 changed files with 279 additions and 285 deletions

View File

@ -9,13 +9,13 @@
class InsertQuery_mysql extends InsertQuery {
public function execute() {
// Confirm that the user did not try to specify an identical
// field and default field.
if (array_intersect($this->insertFields, $this->defaultFields)) {
throw new PDOException('You may not specify the same field to have a value and a schema-default value.');
}
$last_insert_id = 0;
$max_placeholder = 0;
@ -37,10 +37,10 @@ class InsertQuery_mysql extends InsertQuery {
public function __toString() {
$delay = $this->queryOptions['delay'] ? 'DELAYED' : '';
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
$query = "INSERT $delay INTO {" . $this->table . '} (' . implode(', ', $insert_fields) . ') VALUES ';
$max_placeholder = 0;
@ -48,11 +48,11 @@ class InsertQuery_mysql extends InsertQuery {
if (count($this->insertValues)) {
foreach ($this->insertValues as $insert_values) {
$placeholders = array();
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$new_placeholder = $max_placeholder + count($insert_values);
for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
$placeholders[] = ':db_insert_placeholder_'. $i;
@ -87,7 +87,7 @@ class MergeQuery_mysql extends MergeQuery {
unset($update_fields[$exclude_field]);
}
}
$insert_fields = $this->insertFields + $this->keyFields;
$max_placeholder = 0;
@ -106,7 +106,7 @@ class MergeQuery_mysql extends MergeQuery {
}
unset($update_fields[$field]);
}
// Because we filter $fields the same way here and in __toString(), the
// placeholders will all match up properly.
$max_placeholder = 0;
@ -119,7 +119,7 @@ class MergeQuery_mysql extends MergeQuery {
return $last_insert_id;
}
public function __toString() {
// Set defaults.
@ -134,7 +134,7 @@ class MergeQuery_mysql extends MergeQuery {
unset($update_fields[$exclude_field]);
}
}
$insert_fields = $this->insertFields + $this->keyFields;
$query = "INSERT INTO {" . $this->table . '} (' . implode(', ', array_keys($insert_fields)) . ') VALUES ';
@ -147,7 +147,7 @@ class MergeQuery_mysql extends MergeQuery {
}
$query .= '(' . implode(', ', $values) . ') ON DUPLICATE KEY UPDATE ';
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$max_placeholder = 0;
@ -160,7 +160,7 @@ class MergeQuery_mysql extends MergeQuery {
foreach ($update_fields as $field => $value) {
$update[] = ($field . '=:db_update_placeholder_' . $max_placeholder++);
}
$query .= implode(', ', $update);
return $query;

View File

@ -17,7 +17,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
public function tableExists($table) {
return (bool) $this->connection->query("SHOW TABLES LIKE '{" . $table . "}'", array(), array())->fetchField();
}
public function columnExists($table, $column) {
return (bool) $this->connection->query("SHOW COLUMNS FROM {" . $this->escapeTable($table) . "} LIKE '" . $this->escapeTable($column) . "'", array(), array())->fetchField();
}
@ -37,25 +37,25 @@ class DatabaseSchema_mysql extends DatabaseSchema {
if (empty($table['mysql_suffix'])) {
$table['mysql_suffix'] = "/*!40100 DEFAULT CHARACTER SET UTF8 */";
}
$sql = "CREATE TABLE {" . $name . "} (\n";
// Add the SQL statement for each field.
foreach ($table['fields'] as $field_name => $field) {
$sql .= $this->createFieldSql($field_name, $this->processField($field)) . ", \n";
}
// Process keys & indexes.
$keys = $this->createKeysSql($table);
if (count($keys)) {
$sql .= implode(", \n", $keys) . ", \n";
}
// Remove the last comma and space.
$sql = substr($sql, 0, -3) . "\n) ";
$sql .= $table['mysql_suffix'];
return array($sql);
}
@ -72,40 +72,40 @@ class DatabaseSchema_mysql extends DatabaseSchema {
*/
protected function createFieldSql($name, $spec) {
$sql = "`" . $name . "` " . $spec['mysql_type'];
if (isset($spec['length'])) {
$sql .= '(' . $spec['length'] . ')';
}
elseif (isset($spec['precision']) && isset($spec['scale'])) {
$sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')';
}
if (!empty($spec['unsigned'])) {
$sql .= ' unsigned';
}
if (!empty($spec['not null'])) {
$sql .= ' NOT NULL';
}
if (!empty($spec['auto_increment'])) {
$sql .= ' auto_increment';
}
if (isset($spec['default'])) {
if (is_string($spec['default'])) {
$spec['default'] = "'" . $spec['default'] . "'";
}
$sql .= ' DEFAULT ' . $spec['default'];
}
if (empty($spec['not null']) && !isset($spec['default'])) {
$sql .= ' DEFAULT NULL';
}
return $sql;
}
/**
* Set database-engine specific properties for a field.
*
@ -113,21 +113,21 @@ class DatabaseSchema_mysql extends DatabaseSchema {
* A field description array, as specified in the schema documentation.
*/
protected function processField($field) {
if (!isset($field['size'])) {
$field['size'] = 'normal';
}
// Set the correct database-engine specific datatype.
if (!isset($field['mysql_type'])) {
$map = db_type_map();
$field['mysql_type'] = $map[$field['type'] . ':' . $field['size']];
}
if ($field['type'] == 'serial') {
$field['auto_increment'] = TRUE;
}
return $field;
}
@ -138,41 +138,41 @@ class DatabaseSchema_mysql extends DatabaseSchema {
static $map = array(
'varchar:normal' => 'VARCHAR',
'char:normal' => 'CHAR',
'text:tiny' => 'TINYTEXT',
'text:small' => 'TINYTEXT',
'text:medium' => 'MEDIUMTEXT',
'text:big' => 'LONGTEXT',
'text:normal' => 'TEXT',
'serial:tiny' => 'TINYINT',
'serial:small' => 'SMALLINT',
'serial:medium' => 'MEDIUMINT',
'serial:big' => 'BIGINT',
'serial:normal' => 'INT',
'int:tiny' => 'TINYINT',
'int:small' => 'SMALLINT',
'int:medium' => 'MEDIUMINT',
'int:big' => 'BIGINT',
'int:normal' => 'INT',
'float:tiny' => 'FLOAT',
'float:small' => 'FLOAT',
'float:medium' => 'FLOAT',
'float:big' => 'DOUBLE',
'float:normal' => 'FLOAT',
'numeric:normal' => 'DECIMAL',
'blob:big' => 'LONGBLOB',
'blob:normal' => 'BLOB',
'datetime:normal' => 'DATETIME',
);
return $map;
}
@ -195,7 +195,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
return $keys;
}
protected function createKeySql($fields) {
$ret = array();
foreach ($fields as $field) {
@ -225,7 +225,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
public function renameTable(&$ret, $table, $new_name) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} RENAME TO {' . $new_name . '}');
}
public function dropTable(&$ret, $table) {
$ret[] = update_sql('DROP TABLE {' . $table . '}');
}
@ -265,7 +265,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
else {
$default = is_string($default) ? "'$default'" : $default;
}
$ret[] = update_sql('ALTER TABLE {' . $table . '} ALTER COLUMN ' . $field . ' SET DEFAULT ' . $default);
}
@ -276,7 +276,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
public function addPrimaryKey(&$ret, $table, $fields) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
}
public function dropPrimaryKey(&$ret, $table) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} DROP PRIMARY KEY');
}
@ -288,7 +288,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
public function dropUniqueKey(&$ret, $table, $name) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} DROP KEY ' . $name);
}
public function addIndex(&$ret, $table, $name, $fields) {
$query = 'ALTER TABLE {' . $table . '} ADD INDEX ' . $name . ' (' . $this->createKeySql($fields) . ')';
$ret[] = update_sql($query);
@ -297,7 +297,7 @@ class DatabaseSchema_mysql extends DatabaseSchema {
public function dropIndex(&$ret, $table, $name) {
$ret[] = update_sql('ALTER TABLE {' . $table . '} DROP INDEX ' . $name);
}
public function changeField(&$ret, $table, $field, $field_new, $spec, $keys_new = array()) {
$sql = 'ALTER TABLE {' . $table . '} CHANGE ' . $field . ' ' . $this->createFieldSql($field_new, $this->processField($spec));
if (count($keys_new)) {

View File

@ -33,7 +33,7 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
public function query($query, Array $args = array(), $options = array()) {
$options += $this->defaultOptions();
try {
if ($query instanceof DatabaseStatement) {
$stmt = $query;
@ -43,7 +43,7 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
$stmt = $this->prepareQuery($query);
$stmt->execute($args, $options);
}
switch ($options['return']) {
case Database::RETURN_STATEMENT:
return $stmt;
@ -74,7 +74,7 @@ class DatabaseConnection_pgsql extends DatabaseConnection {
return NULL;
}
}
public function queryRange($query, Array $args, $from, $count, Array $options) {
// Backward compatibility hack, temporary.
$query = str_replace(array('%d' , '%f' , '%b' , "'%s'"), '?', $query);

View File

@ -13,9 +13,9 @@ class InsertQuery_pgsql extends InsertQuery {
parent::__construct($connection, $table, $options);
$this->queryOptions['return'] = Database::RETURN_NULL;
}
public function execute() {
// Confirm that the user did not try to specify an identical
// field and default field.
if (array_intersect($this->insertFields, $this->defaultFields)) {
@ -53,13 +53,13 @@ class InsertQuery_pgsql extends InsertQuery {
// when requesting the last insert ID, so we pass that in via
// the options array.
$options = $this->queryOptions;
if ($schema['fields'][$schema['primary key'][0]]['type'] == 'serial') {
$options['sequence_name'] = $this->connection->makeSequenceName($this->table, $schema['primary key'][0]);
$options['return'] = Database::RETURN_INSERT_ID;
}
$last_insert_id = $this->connection->query($stmt, array(), $options);
// Re-initialize the values array so that we can re-use this query.
$this->insertValues = array();
@ -67,7 +67,7 @@ class InsertQuery_pgsql extends InsertQuery {
}
public function __toString() {
// Default fields are always placed first for consistency.
$insert_fields = array_merge($this->defaultFields, $this->insertFields);
@ -78,11 +78,11 @@ class InsertQuery_pgsql extends InsertQuery {
if (count($this->insertValues)) {
foreach ($this->insertValues as $insert_values) {
$placeholders = array();
// Default fields aren't really placeholders, but this is the most convenient
// way to handle them.
$placeholders = array_pad($placeholders, count($this->defaultFields), 'default');
$new_placeholder = $max_placeholder + count($insert_values);
for ($i = $max_placeholder; $i < $new_placeholder; ++$i) {
$placeholders[] = ':db_insert_placeholder_' . $i;
@ -103,18 +103,18 @@ class InsertQuery_pgsql extends InsertQuery {
}
}
class UpdateQuery_pgsql extends UpdateQuery {
class UpdateQuery_pgsql extends UpdateQuery {
public function execute() {
$max_placeholder = 0;
$blobs = array();
$blob_count = 0;
$schema = drupal_get_schema($this->table);
// Because we filter $fields the same way here and in __toString(), the
// placeholders will all match up properly.
$stmt = $this->connection->prepareQuery((string)$this);
// Expressions take priority over literal fields, so we process those first
// and remove any literal fields that conflict.
$fields = $this->fields;
@ -130,7 +130,7 @@ class UpdateQuery_pgsql extends UpdateQuery {
}
unset($fields[$field]);
}
foreach ($fields as $field => &$value) {
$placeholder = ':db_update_placeholder_' . ($max_placeholder++);
@ -160,7 +160,7 @@ class UpdateQuery_pgsql extends UpdateQuery {
$options = $this->queryOptions;
$options['already_prepared'] = TRUE;
$this->connection->query($stmt, $options);
//$stmt->execute(NULL, $this->queryOptions);
return $stmt->rowCount();
}

View File

@ -16,7 +16,7 @@ class DatabaseSchema_pgsql extends DatabaseSchema {
public function tableExists($table) {
return (bool) db_result(db_query("SELECT COUNT(*) FROM pg_class WHERE relname = '{" . db_escape_table($table) . "}'"));
}
public function columnExists($table, $column) {
return (bool) db_result(db_query("SELECT COUNT(pg_attribute.attname) FROM pg_class, pg_attribute WHERE pg_attribute.attrelid = pg_class.oid AND pg_class.relname = '{" . db_escape_table($table) . "}' AND attname = '" . db_escape_table($column) . "'"));
}

View File

@ -2092,11 +2092,11 @@ function _locale_rebuild_js($langcode = NULL) {
// Construct the array for JavaScript translations.
// We sort on plural so that we have all plural forms before singular forms.
$result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation
FROM {locales_source} s
LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language
WHERE s.location LIKE '%.js%'
AND s.textgroup = 'default'
$result = db_query("SELECT s.lid, s.source, t.plid, t.plural, t.translation
FROM {locales_source} s
LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language
WHERE s.location LIKE '%.js%'
AND s.textgroup = 'default'
ORDER BY t.plural DESC", array(':language' => $language->language));
$translations = $plurals = array();

View File

@ -10,69 +10,69 @@
* - _sess_close()
* - _sess_read()
* - _sess_write()
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP. These functions should not be called directly. Session
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP. These functions should not be called directly. Session
* data should instead be accessed via the $_SESSION superglobal.
*
* The user-level session storage handlers:
* - sess_destroy_sid()
* - sess_gc()
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* are assigned by session_set_save_handler() in bootstrap.inc and are called
* automatically by PHP, but they may safely be called directly.
*/
/**
* Session handler assigned by session_set_save_handler().
*
* This function is used to handle any initialization, such as file paths or
* database connections, that is needed before accessing session data. Drupal
*
* This function is used to handle any initialization, such as file paths or
* database connections, that is needed before accessing session data. Drupal
* does not need to initialize anything in this function.
*
* This function should not be called directly.
*
* @return
* This function will always return TRUE.
*/
*/
function _sess_open() {
return TRUE;
}
/**
* Session handler assigned by session_set_save_handler().
*
* This function is used to close the current session. Because Drupal stores
* session data in the database immediately on write, this function does
*
* This function is used to close the current session. Because Drupal stores
* session data in the database immediately on write, this function does
* not need to do anything.
*
* This function should not be called directly.
*
* @return
* This function will always return TRUE.
*/
*/
function _sess_close() {
return TRUE;
}
/**
* Session handler assigned by session_set_save_handler().
*
* This function will be called by PHP to retrieve the current user's
* session data, which is stored in the database. It also loads the
*
* This function will be called by PHP to retrieve the current user's
* session data, which is stored in the database. It also loads the
* current user's appropriate roles into the user object.
*
* This function should not be called directly. Session data should
* This function should not be called directly. Session data should
* instead be accessed via the $_SESSION superglobal.
*
* @param $key
* Session ID
* @return
* Either an array of the session data, or an empty string, if no data
* Either an array of the session data, or an empty string, if no data
* was found or the user is anonymous.
*/
function _sess_read($key) {
global $user;
// Write and Close handlers are called after destructing objects
// Write and Close handlers are called after destructing objects
// since PHP 5.0.5.
// Thus destructors can use sessions but session handler can't use objects.
// So we are moving session closure before destructing objects.
@ -85,7 +85,7 @@ function _sess_read($key) {
return '';
}
// Otherwise, if the session is still active, we have a record of the
// Otherwise, if the session is still active, we have a record of the
// client's session in the database.
$user = db_fetch_object(db_query("SELECT u.*, s.* FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.sid = '%s'", $key));
@ -102,7 +102,7 @@ function _sess_read($key) {
$user->roles[$role->rid] = $role->name;
}
}
// We didn't find the client's record (session has expired), or they
// We didn't find the client's record (session has expired), or they
// are an anonymous user.
else {
$session = isset($user->session) ? $user->session : '';
@ -114,11 +114,11 @@ function _sess_read($key) {
/**
* Session handler assigned by session_set_save_handler().
*
* This function will be called by PHP to store the current user's
*
* This function will be called by PHP to store the current user's
* session, which Drupal saves to the database.
*
* This function should not be called directly. Session data should
* This function should not be called directly. Session data should
* instead be accessed via the $_SESSION superglobal.
*
* @param $key
@ -177,7 +177,7 @@ function drupal_session_regenerate() {
}
/**
* Counts how many users have sessions. Can count either anonymous sessions,
* Counts how many users have sessions. Can count either anonymous sessions,
* authenticated sessions, or both.
*
* @param int $timestamp
@ -196,7 +196,7 @@ function drupal_session_count($timestamp = 0, $anonymous = true) {
/**
* Session handler assigned by session_set_save_handler().
*
*
* Cleanup a specific session.
*
* @param string $sid
@ -218,7 +218,7 @@ function drupal_session_destroy_uid($uid) {
/**
* Session handler assigned by session_set_save_handler().
*
*
* Cleanup stalled sessions.
*/
function _sess_gc($lifetime) {
@ -235,13 +235,13 @@ function _sess_gc($lifetime) {
/**
* Determine whether to save session data of the current request.
*
* This function allows the caller to temporarily disable writing of
* session data, should the request end while performing potentially
* This function allows the caller to temporarily disable writing of
* session data, should the request end while performing potentially
* dangerous operations, such as manipulating the global $user object.
* See http://drupal.org/node/218104 for usage
*
* @param $status
* Disables writing of session data when FALSE, (re-)enables
* Disables writing of session data when FALSE, (re-)enables
* writing when TRUE.
* @return
* FALSE if writing session data has been disabled. Otherwise, TRUE.

View File

@ -197,8 +197,8 @@ function _init_theme($theme, $base_theme = array(), $registry_callback = '_theme
/**
* Get the theme registry.
* @return
* The theme registry array if it has been stored in memory, NULL otherwise.
* @return
* The theme registry array if it has been stored in memory, NULL otherwise.
*/
function theme_get_registry() {
return _theme_set_registry();
@ -208,16 +208,16 @@ function theme_get_registry() {
* Store the theme registry in memory.
* @param $registry
* A registry array as returned by _theme_build_registry()
* @return
* @return
* The theme registry array stored in memory
*/
function _theme_set_registry($registry = NULL) {
static $theme_registry = NULL;
if (isset($registry)) {
$theme_registry = $registry;
}
return $theme_registry;
}
@ -2001,4 +2001,3 @@ function template_preprocess_block(&$variables) {
$variables['template_files'][] = 'block-' . $variables['block']->module;
$variables['template_files'][] = 'block-' . $variables['block']->module . '-' . $variables['block']->delta;
}

View File

@ -618,7 +618,7 @@ function install_tasks($profile, $task) {
// Bootstrap newly installed Drupal, while preserving existing messages.
$messages = isset($_SESSION['messages']) ? $_SESSION['messages'] : '';
drupal_install_init_database();
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
$_SESSION['messages'] = $messages;
@ -1179,4 +1179,3 @@ function install_configure_form_submit($form, &$form_state) {
// Start the installer.
install_main();

View File

@ -60,7 +60,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com');
$this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0])), '', TRUE);
$this->assertRaw(t('Category %category has been added.', array('%category' => $category)), t('Category successfully added.'));
// Test update contact form category
$categories = $this->getCategories();
$category_id = $this->updateCategory($categories, $category = $this->randomName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomName(30), FALSE);
@ -70,7 +70,7 @@ class ContactSitewideTestCase extends DrupalWebTestCase {
$this->assertEqual($category_array['reply'], $reply);
$this->assertFalse($category_array['selected']);
$this->assertRaw(t('Category %category has been updated.', array('%category' => $category)), t('Category successfully updated.'));
$this->addCategory($category = $this->randomName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE);
$this->assertRaw(t('Category %category has been added.', array('%category' => $category)), t('Category successfully added.'));

View File

@ -315,13 +315,13 @@ function menu_nodeapi(&$node, $op) {
if (isset($node->nid)) {
// Give priority to the default menu
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", array(
':path' => 'node/'. $node->nid,
':path' => 'node/'. $node->nid,
':menu_name' => $menu_name,
), 0, 1));
// Check all menus if a link does not exist in the default menu.
if (!$mlid) {
$mlid = db_result(db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND module = 'menu' ORDER BY mlid ASC", array(
':path' => 'node/'. $node->nid,
':path' => 'node/'. $node->nid,
), 0, 1));
}
if ($mlid) {

View File

@ -478,10 +478,10 @@ function node_admin_nodes() {
// Build the query and load the nodes we want to display.
$filter = node_build_filter_query();
$sort = tablesort_sql($header, '', 'n.changed DESC');
$result = pager_query(db_rewrite_sql('SELECT n.*, u.name FROM {node} n '. $filter['join'] .' INNER JOIN {users} u ON n.uid = u.uid '. $filter['where'] . $sort), 50, 0, NULL, $filter['args']);
// Build the 'Update options' form.
$form['options'] = array(
'#type' => 'fieldset',
@ -608,7 +608,7 @@ function theme_node_admin_nodes($form) {
}
$output .= theme('table', $header, $rows);
if ($form['pager']['#markup']) {
$output .= drupal_render($form['pager']);
}

View File

@ -111,7 +111,7 @@ function profile_autocomplete($field, $string) {
$matches = array();
if (db_result(db_query("SELECT COUNT(*) FROM {profile_fields} WHERE fid = %d AND autocomplete = 1", $field))) {
$result = db_query_range("SELECT value FROM {profile_values} WHERE fid = :fid AND LOWER(value) LIKE LOWER(:value) GROUP BY value ORDER BY value ASC", array(
':fid' => $field,
':fid' => $field,
':value' => $string .'%',
), 0, 10);
while ($data = db_fetch_object($result)) {

View File

@ -113,7 +113,7 @@ class SimpleTestTestCase extends DrupalWebTestCase {
// Call an assert function specific to that class.
$this->assertNothing();
// Generates a warning inside a PHP function.
array_key_exists(NULL, NULL);
}

View File

@ -110,7 +110,7 @@ class BootstrapPageCacheTestCase extends DrupalWebTestCase {
}
class BootstrapVariableTestCase extends DrupalWebTestCase {
/**
* Implementation of setUp().
*/
@ -141,7 +141,7 @@ class BootstrapVariableTestCase extends DrupalWebTestCase {
// Make sure the variable persists across multiple requests.
$this->drupalGet('system-test/variable-get');
$this->assertText($variable, t('Variable persists across multiple requests'));
// Deleting variables.
$default_value = $this->randomName();
variable_del('simpletest_bootstrap_variable_test');

View File

@ -3,7 +3,7 @@
/**
* 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
@ -14,28 +14,28 @@ function database_test_schema() {
'description' => 'Basic test table for the database unit tests.',
'fields' => array(
'id' => array(
'type' => 'serial',
'unsigned' => TRUE,
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
'name' => array(
'description' => "A person's name",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'age' => array(
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0),
'job' => array(
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => 'Undefined',
),
),
@ -47,7 +47,7 @@ function database_test_schema() {
'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(
@ -55,23 +55,23 @@ function database_test_schema() {
'fields' => array(
'name' => array(
'description' => "A person's name",
'type' => 'varchar',
'length' => 255,
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'age' => array(
'description' => "The person's age",
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'job' => array(
'description' => "The person's job",
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
@ -86,7 +86,7 @@ function database_test_schema() {
'fields' => array(
'id' => array(
'description' => 'Simple unique ID.',
'type' => 'serial',
'type' => 'serial',
'not null' => TRUE,
),
'blob1' => array(
@ -102,7 +102,7 @@ function database_test_schema() {
'fields' => array(
'id' => array(
'description' => 'Simple unique ID.',
'type' => 'serial',
'type' => 'serial',
'not null' => TRUE,
),
'blob1' => array(
@ -122,28 +122,28 @@ function database_test_schema() {
'fields' => array(
'tid' => array(
'description' => 'Task ID, primary key.',
'type' => 'serial',
'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,
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'task' => array(
'description' => 'The task to be completed.',
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
'priority' => array(
'description' => 'The priority of the task.',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),

View File

@ -13,26 +13,25 @@ function database_test_query_alter(SelectQuery $query) {
if ($query->hasTag('database_test_alter_remove_range')) {
$query->range();
}
if ($query->hasTag('database_test_alter_add_join')) {
$people_alias = $query->join('test', 'people', "test_task.pid=people.id");
$name_field = $query->addField('people', 'name', 'name');
$query->condition($people_alias . '.id', 2);
}
if ($query->hasTag('database_test_alter_change_conditional')) {
$conditions =& $query->conditions();
$conditions[0]['value'] = 2;
}
if ($query->hasTag('database_test_alter_change_fields')) {
$fields =& $query->getFields();
unset($fields['age']);
}
if ($query->hasTag('database_test_alter_change_expressions')) {
$expressions =& $query->getExpressions();
$expressions['double_age']['expression'] = 'age*3';
}
}
}

View File

@ -7,12 +7,12 @@
* PDO supports using a new instance of an arbitrary class for records
* rather than just a stdClass or array. This class is for testing that
* functionality. (See testQueryFetchClass() below)
*/
*/
class FakeRecord { }
/**
* Base test class for databases.
*
*
* Because all database tests share the same test data, we can centralize that
* here.
*/
@ -27,10 +27,10 @@ class DatabaseTestCase extends DrupalWebTestCase {
$schema['test_one_blob'] = drupal_get_schema('test_one_blob');
$schema['test_two_blobs'] = drupal_get_schema('test_two_blobs');
$schema['test_task'] = drupal_get_schema('test_task');
$ret = array();
// This ends up being a test for table drop and create, too, which is
// This ends up being a test for table drop and create, too, which is
// nice.
foreach ($schema as $name => $data) {
if (db_table_exists($name)) {
@ -38,11 +38,11 @@ class DatabaseTestCase extends DrupalWebTestCase {
}
db_create_table($ret, $name, $data);
}
foreach ($schema as $name => $data) {
$this->assertTrue(db_table_exists($name), t('Table @name created successfully.', array('@name' => $name)));
}
$this->addSampleData();
}
catch (Exception $e) {
@ -53,7 +53,7 @@ class DatabaseTestCase extends DrupalWebTestCase {
/**
* Setup our sample data.
*
* These are added using db_query(), since we're not trying to test the
* These are added using db_query(), since we're not trying to test the
* INSERT operations here, just populate.
*/
function addSampleData() {
@ -69,38 +69,38 @@ class DatabaseTestCase extends DrupalWebTestCase {
db_query("INSERT INTO {test_people} (name, age, job) VALUES ('Meredith', 30, 'Speaker')");
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $john,
':task' => 'eat',
':pid' => $john,
':task' => 'eat',
':priority' => 3,
));
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $john,
':task' => 'sleep',
':pid' => $john,
':task' => 'sleep',
':priority' => 4,
));
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $john,
':task' => 'code',
':pid' => $john,
':task' => 'code',
':priority' => 1,
));
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $george,
':task' => 'sing',
':pid' => $george,
':task' => 'sing',
':priority' => 2,
));
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $george,
':task' => 'sleep',
':pid' => $george,
':task' => 'sleep',
':priority' => 2,
));
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $paul,
':task' => 'found new band',
':pid' => $paul,
':task' => 'found new band',
':priority' => 1,
));
db_query("INSERT INTO {test_task} (pid, task, priority) VALUES (:pid, :task, :priority)", array(
':pid' => $paul,
':task' => 'perform at superbowl',
':pid' => $paul,
':task' => 'perform at superbowl',
':priority' => 3,
));
}
@ -109,11 +109,11 @@ class DatabaseTestCase extends DrupalWebTestCase {
/**
* Test fetch actions, part 1.
*
*
* We get timeout errors if we try to run too many tests at once.
*/
class DatabaseFetchTestCase extends DatabaseTestCase {
function getInfo() {
return array(
'name' => t('Fetch tests'),
@ -191,7 +191,7 @@ class DatabaseFetchTestCase extends DatabaseTestCase {
/**
* Test fetch actions, part 2.
*
*
* We get timeout errors if we try to run too many tests at once.
*/
class DatabaseFetch2TestCase extends DatabaseTestCase {
@ -241,7 +241,7 @@ class DatabaseFetch2TestCase extends DatabaseTestCase {
/**
* Confirm that we can fetch an entire column of a result set at once.
*/
*/
function testQueryFetchCol() {
$records = array();
$result = db_query("SELECT name FROM {test} WHERE age > :age", array(':age' => 25));
@ -276,7 +276,7 @@ class DatabaseInsertTestCase extends DatabaseTestCase {
function testSimpleInsert() {
try {
$num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$query = db_insert('test');
$query->fields(array(
'name' => 'Yoko',
@ -286,7 +286,7 @@ class DatabaseInsertTestCase extends DatabaseTestCase {
$num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$this->assertIdentical($num_records_before + 1, (int)$num_records_after, t('Record inserts correctly.'));
$saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Yoko'))->fetchField();
$this->assertIdentical($saved_age, '29', t('Can retrieve after inserting.'));
}
@ -301,24 +301,24 @@ class DatabaseInsertTestCase extends DatabaseTestCase {
function testMultiInsert() {
try {
$num_records_before = (int) db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$query = db_insert('test');
$query->fields(array(
'name' => 'Larry',
'age' => '30',
));
// We should be able to specify values in any order if named.
$query->values(array(
'age' => '31',
'name' => 'Curly',
));
// We should be able to say "use the field order".
// This is not the recommended mechanism for most cases, but it should work.
$query->values(array('Moe', '32'));
$query->execute();
$num_records_after = (int) db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$this->assertIdentical($num_records_before + 3, $num_records_after, t('Record inserts correctly.'));
$saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Larry'))->fetchField();
@ -339,26 +339,26 @@ class DatabaseInsertTestCase extends DatabaseTestCase {
function testRepeatedInsert() {
try {
$num_records_before = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$query = db_insert('test');
$query->fields(array(
'name' => 'Larry',
'age' => '30',
));
$query->execute(); // This should run the insert, but leave the fields intact.
// We should be able to specify values in any order if named.
$query->values(array(
'age' => '31',
'name' => 'Curly',
));
$query->execute();
// We should be able to say "use the field order".
$query->values(array('Moe', '32'));
$query->execute();
$num_records_after = db_query("SELECT COUNT(*) FROM {test}")->fetchField();
$this->assertIdentical((int) $num_records_before + 3, (int) $num_records_after, t('Record inserts correctly.'));
$saved_age = db_query("SELECT age FROM {test} WHERE name = :name", array(':name' => 'Larry'))->fetchField();
@ -399,7 +399,7 @@ class DatabaseInsertTestCase extends DatabaseTestCase {
'age' => '30',
))
->execute();
$this->assertIdentical($id, '5', t('Auto-increment ID returned successfully.'));
}
catch (Exception $e) {
@ -438,7 +438,7 @@ class DatabaseInsertLOBTestCase extends DatabaseTestCase {
*/
function testInsertMultipleBlob() {
$id = db_insert('test_two_blobs')->fields(array(
'blob1' => 'This is',
'blob1' => 'This is',
'blob2' => 'a test',
))
->execute();
@ -460,7 +460,7 @@ class DatabaseInsertDefaultsTestCase extends DatabaseTestCase {
'group' => t('Database'),
);
}
/**
* Test that we can run a query that is "default values for everything".
*/
@ -468,9 +468,9 @@ class DatabaseInsertDefaultsTestCase extends DatabaseTestCase {
try {
$query = db_insert('test')->useDefaults(array('job'));
$id = $query->execute();
$schema = drupal_get_schema('test');
$job = db_query("SELECT job FROM {test} WHERE id = :id", array(':id' => $id))->fetchField();
$this->assertEqual($job, $schema['fields']['job']['default'], t('Default field value is set.'));
}
@ -486,9 +486,9 @@ class DatabaseInsertDefaultsTestCase extends DatabaseTestCase {
try {
$query = db_insert('test')->fields(array('name' => 'Bob'))->useDefaults(array('job'));
$id = $query->execute();
$schema = drupal_get_schema('test');
$job = db_query("SELECT job FROM {test} WHERE id = :id", array(':id' => $id))->fetchField();
$this->assertEqual($job, $schema['fields']['job']['default'], t('Default field value is set.'));
}
@ -521,7 +521,7 @@ class DatabaseUpdateTestCase extends DatabaseTestCase {
$saved_name = db_query("SELECT name FROM {test} WHERE id = :id", array(':id' => 1))->fetchField();
$this->assertIdentical($saved_name, 'Tiffany', t('Updated name successfully.'));
}
/**
* Confirm that we can update a multiple records successfully.
*/
@ -633,7 +633,7 @@ class DatabaseUpdateComplexTestCase extends DatabaseTestCase {
->condition('age', array(25, 26), 'BETWEEN')
->execute();
$this->assertIdentical($num_updated, 2, t('Updated 2 records.'));
$num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField();
$this->assertIdentical($num_matches, '2', t('Updated fields successfully.'));
}
@ -668,10 +668,10 @@ class DatabaseUpdateComplexTestCase extends DatabaseTestCase {
->expression('age', 'age + :age',array(':age' => 4))
->execute();
$this->assertIdentical($num_updated, 1, t('Updated 1 record.'));
$num_matches = db_query("SELECT count(*) FROM {test} WHERE job = :job", array(':job' => 'Musician'))->fetchField();
$this->assertIdentical($num_matches, '1', t('Updated fields successfully.'));
$person = db_query("SELECT * FROM {test} WHERE name = :name", array(':name' => 'Ringo'))->fetch();
$this->assertEqual($person->name, 'Ringo', t('Name set correctly.'));
$this->assertEqual($person->age, $before_age + 4, t('Age set correctly.'));
@ -712,13 +712,13 @@ class DatabaseUpdateLOBTestCase extends DatabaseTestCase {
$r = db_fetch_array($res);
$this->assertTrue($r['blob1'] === $data, t('Can update a blob: id @id, @data.', array('@id' => $id, '@data' => serialize($r))));
}
/**
* Confirm that we can update two blob columns in the same table.
*/
function testUpdateMultipleBlob() {
$id = db_insert('test_two_blobs')->fields(array(
'blob1' => 'This is',
'blob1' => 'This is',
'blob2' => 'a test')
)
->execute();
@ -782,18 +782,18 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
function testMergeInsert() {
try{
$num_records_before = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField();
db_merge('test_people')
->key(array('job' => 'Presenter'))
->fields(array(
'age' => 31,
'age' => 31,
'name' => 'Tiffany',
))
->execute();
$num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField();
$this->assertEqual($num_records_before + 1, $num_records_after, t('Merge inserted properly.'));
$person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Presenter'))->fetch();
$this->assertEqual($person->name, 'Tiffany', t('Name set correctly.'));
$this->assertEqual($person->age, 31, t('Age set correctly.'));
@ -814,7 +814,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
$num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField();
$this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.'));
$person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch();
$this->assertEqual($person->name, 'Tiffany', t('Name set correctly.'));
$this->assertEqual($person->age, 31, t('Age set correctly.'));
@ -831,7 +831,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
$num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField();
$this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.'));
$person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch();
$this->assertEqual($person->name, 'Tiffany', t('Name set correctly.'));
$this->assertEqual($person->age, 30, t('Age skipped correctly.'));
@ -848,7 +848,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
$num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField();
$this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.'));
$person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch();
$this->assertEqual($person->name, 'Joe', t('Name set correctly.'));
$this->assertEqual($person->age, 30, t('Age skipped correctly.'));
@ -863,7 +863,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
$age_before = db_query("SELECT age FROM {test_people} WHERE job = 'Speaker'")->fetchField();
// This is a very contrived example, as I have no idea why you'd want to
// This is a very contrived example, as I have no idea why you'd want to
// change age this way, but that's beside the point.
// Note that we are also double-setting age here, once as a literal and
// once as an expression. This test will only pass if the expression wins,
@ -876,7 +876,7 @@ class DatabaseMergeTestCase extends DatabaseTestCase {
$num_records_after = db_query("SELECT COUNT(*) FROM {test_people}")->fetchField();
$this->assertEqual($num_records_before, $num_records_after, t('Merge updated properly.'));
$person = db_query("SELECT * FROM {test_people} WHERE job = :job", array(':job' => 'Speaker'))->fetch();
$this->assertEqual($person->name, 'Tiffany', t('Name set correctly.'));
$this->assertEqual($person->age, $age_before + 4, t('Age updated correctly.'));
@ -907,12 +907,12 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
$name_field = $query->addField('test', 'name');
$age_field = $query->addField('test', 'age', 'age');
$result = $query->execute();
$num_records = 0;
foreach ($result as $record) {
$num_records++;
}
$this->assertEqual($num_records, 4, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -929,11 +929,11 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
$age_field = $query->addField('test', 'age', 'age');
$query->condition('age', 27);
$result = $query->execute();
// Check that the aliases are being created the way we want.
$this->assertEqual($name_field, 'test_name', t('Name field alias is correct.'));
$this->assertEqual($age_field, 'age', t('Age field alias is correct.'));
// Ensure that we got the right record.
$record = $result->fetch();
$this->assertEqual($record->$name_field, 'George', t('Fetched name is correct.'));
@ -949,11 +949,11 @@ class DatabaseSelectTestCase extends DatabaseTestCase {
$age_field = $query->addExpression("age*2", 'double_age');
$query->condition('age', 27);
$result = $query->execute();
// Check that the aliases are being created the way we want.
$this->assertEqual($name_field, 'test_name', t('Name field alias is correct.'));
$this->assertEqual($age_field, 'double_age', t('Age field alias is correct.'));
// Ensure that we got the right record.
$record = $result->fetch();
$this->assertEqual($record->$name_field, 'George', t('Fetched name is correct.'));
@ -984,7 +984,7 @@ class DatabaseSelectOrderedTestCase extends DatabaseTestCase {
$age_field = $query->addField('test', 'age', 'age');
$query->orderBy($age_field);
$result = $query->execute();
$num_records = 0;
$last_age = 0;
foreach ($result as $record) {
@ -992,7 +992,7 @@ class DatabaseSelectOrderedTestCase extends DatabaseTestCase {
$this->assertTrue($record->age >= $last_age, t('Results returned in correct order.'));
$last_age = $record->age;
}
$this->assertEqual($num_records, 4, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1012,7 +1012,7 @@ class DatabaseSelectOrderedTestCase extends DatabaseTestCase {
$query->orderBy($job_field);
$query->orderBy($age_field);
$result = $query->execute();
$num_records = 0;
$expected = array(
array('Ringo', 28, 'Drummer'),
@ -1047,7 +1047,7 @@ class DatabaseSelectOrderedTestCase extends DatabaseTestCase {
$age_field = $query->addField('test', 'age', 'age');
$query->orderBy($age_field, 'DESC');
$result = $query->execute();
$num_records = 0;
$last_age = 100000000;
foreach ($result as $record) {
@ -1055,7 +1055,7 @@ class DatabaseSelectOrderedTestCase extends DatabaseTestCase {
$this->assertTrue($record->age <= $last_age, t('Results returned in correct order.'));
$last_age = $record->age;
}
$this->assertEqual($num_records, 4, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1087,10 +1087,10 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$name_field = $query->addField($people_alias, 'name', 'name');
$task_field = $query->addField('t', 'task', 'task');
$priority_field = $query->addField('t', 'priority', 'priority');
$query->orderBy($priority_field);
$result = $query->execute();
$num_records = 0;
$last_priority = 0;
foreach ($result as $record) {
@ -1099,7 +1099,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$this->assertNotEqual($record->$name_field, 'Ringo', t('Taskless person not selected.'));
$last_priority = $record->$priority_field;
}
$this->assertEqual($num_records, 7, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1117,19 +1117,19 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$name_field = $query->addField('p', 'name', 'name');
$task_field = $query->addField($people_alias, 'task', 'task');
$priority_field = $query->addField($people_alias, 'priority', 'priority');
$query->orderBy($name_field);
$result = $query->execute();
$num_records = 0;
$last_name = 0;
foreach ($result as $record) {
$num_records++;
$this->assertTrue(strcmp($record->$name_field, $last_name) >= 0, t('Results returned in correct order.'));
$last_priority = $record->$name_field;
}
$this->assertEqual($num_records, 8, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1148,7 +1148,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$query->orderBy($count_field);
$query->groupBy($task_field);
$result = $query->execute();
$num_records = 0;
$last_count = 0;
$records = array();
@ -1158,7 +1158,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$last_count = $record->$count_field;
$records[$record->$task_field] = $record->$count_field;
}
$correct_results = array(
'eat' => 1,
'sleep' => 2,
@ -1166,7 +1166,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
'found new band' => 1,
'perform at superbowl' => 1,
);
foreach ($correct_results as $task => $count) {
$this->assertEqual($records[$task], $count, t("Correct number of '@task' records found.", array('@task' => $task)));
}
@ -1190,7 +1190,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$query->groupBy($task_field);
$query->havingCondition('COUNT(task)', 2, '>=');
$result = $query->execute();
$num_records = 0;
$last_count = 0;
$records = array();
@ -1201,11 +1201,11 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$last_count = $record->$count_field;
$records[$record->$task_field] = $record->$count_field;
}
$correct_results = array(
'sleep' => 2,
);
foreach ($correct_results as $task => $count) {
$this->assertEqual($records[$task], $count, t("Correct number of '@task' records found.", array('@task' => $task)));
}
@ -1227,12 +1227,12 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$age_field = $query->addField('test', 'age', 'age');
$query->range(0, 2);
$result = $query->execute();
$num_records = 0;
foreach ($result as $record) {
$num_records++;
}
$this->assertEqual($num_records, 2, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1249,12 +1249,12 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$task_field = $query->addField('test_task', 'task');
$query->distinct();
$result = $query->execute();
$num_records = 0;
foreach ($result as $record) {
$num_records++;
}
$this->assertEqual($num_records, 6, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1271,11 +1271,11 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
$name_field = $query->addField('test', 'name');
$age_field = $query->addField('test', 'age', 'age');
$query->orderBy('name');
$count = $query->countQuery()->execute()->fetchField();
$this->assertEqual($count, 4, t('Counted the correct number of records.'));
// Now make sure we didn't break the original query! We should still have
// all of the fields we asked for.
$record = $query->execute()->fetch();
@ -1290,7 +1290,7 @@ class DatabaseSelectComplexTestCase extends DatabaseTestCase {
/**
* Select tagging tests.
*
*
* Tags are a way to flag queries for alter hooks so they know
* what type of query it is, such as "node_access".
*/
@ -1312,9 +1312,9 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
$query = db_select('test');
$query->addField('test', 'name');
$query->addField('test', 'age', 'age');
$query->addTag('test');
$this->assertTrue($query->hasTag('test'), t('hasTag() returned true.'));
$this->assertFalse($query->hasTag('other'), t('hasTag() returned false.'));
}
@ -1331,10 +1331,10 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
$query = db_select('test');
$query->addField('test', 'name');
$query->addField('test', 'age', 'age');
$query->addTag('test');
$query->addTag('other');
$this->assertTrue($query->hasAllTags('test', 'other'), t('hasAllTags() returned true.'));
$this->assertFalse($query->hasAllTags('test', 'stuff'), t('hasAllTags() returned false.'));
}
@ -1351,9 +1351,9 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
$query = db_select('test');
$query->addField('test', 'name');
$query->addField('test', 'age', 'age');
$query->addTag('test');
$this->assertTrue($query->hasAnyTag('test', 'other'), t('hasAnyTag() returned true.'));
$this->assertFalse($query->hasAnyTag('other', 'stuff'), t('hasAnyTag() returned false.'));
}
@ -1364,7 +1364,7 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
/**
* Test that we can attach meta data to a query object.
*
*
* This is how we pass additional context to alter hooks.
*/
function testMetaData() {
@ -1372,17 +1372,17 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
$query = db_select('test');
$query->addField('test', 'name');
$query->addField('test', 'age', 'age');
$data = array(
'a' => 'A',
'b' => 'B',
);
$query->addMetaData('test', $data);
$return = $query->getMetaData('test');
$this->assertEqual($data, $return, t('Corect metadata returned.'));
$return = $query->getMetaData('nothere');
$this->assertNull($return, t('Non-existant key returned NULL.'));
}
@ -1394,7 +1394,7 @@ class DatabaseTaggingTestCase extends DatabaseTestCase {
/**
* Select alter tests.
*
*
* @see database_test_query_alter().
*/
class DatabaseAlterTestCase extends DatabaseTestCase {
@ -1423,7 +1423,7 @@ class DatabaseAlterTestCase extends DatabaseTestCase {
foreach ($result as $record) {
$num_records++;
}
$this->assertEqual($num_records, 2, t('Returned the correct number of rows.'));
}
catch(Exception $e) {
@ -1445,9 +1445,9 @@ class DatabaseAlterTestCase extends DatabaseTestCase {
$result = $query->execute();
$records = $result->fetchAll();
$this->assertEqual(count($records), 2, t('Returned the correct number of rows.'));
$this->assertEqual($records[0]->name, 'George', t('Correct data retrieved.'));
$this->assertEqual($records[0]->$tid_field, 4, t('Correct data retrieved.'));
$this->assertEqual($records[0]->$task_field, 'sing', t('Correct data retrieved.'));
@ -1493,7 +1493,7 @@ class DatabaseAlterTestCase extends DatabaseTestCase {
/**
* Select alter tests, part 2.
*
*
* @see database_test_query_alter().
*/
class DatabaseAlter2TestCase extends DatabaseTestCase {
@ -1516,7 +1516,7 @@ class DatabaseAlter2TestCase extends DatabaseTestCase {
$age_field = $query->addField('test', 'age', 'age');
$query->orderBy('name');
$query->addTag('database_test_alter_change_fields');
$record = $query->execute()->fetch();
$this->assertEqual($record->$name_field, 'George', t('Correct data retrieved.'));
$this->assertFalse(isset($record->$age_field), t('Age field not found, as intended.'));
@ -1537,7 +1537,7 @@ class DatabaseAlter2TestCase extends DatabaseTestCase {
$query->condition('age', 27);
$query->addTag('database_test_alter_change_expressions');
$result = $query->execute();
// Ensure that we got the right record.
$record = $result->fetch();
@ -1569,4 +1569,3 @@ class DatabaseAlter2TestCase extends DatabaseTestCase {
}
}
}

View File

@ -25,7 +25,7 @@ class MenuIncTestCase extends DrupalWebTestCase {
// Enable dummy module that implements hook_menu.
parent::setUp('hook_menu');
}
/**
* Tests for menu_name parameter for hook_menu().
*/

View File

@ -68,12 +68,12 @@ function statistics_exit() {
// Log this page access.
db_insert('accesslog')->fields(array(
'title' => strip_tags(drupal_get_title()),
'path' => $_GET['q'],
'url' => $_SERVER['HTTP_REFERER'],
'hostname' => ip_address(),
'uid' => $user->uid,
'sid' => session_id(),
'timer' => timer_read('page'),
'path' => $_GET['q'],
'url' => $_SERVER['HTTP_REFERER'],
'hostname' => ip_address(),
'uid' => $user->uid,
'sid' => session_id(),
'timer' => timer_read('page'),
'timestamp' => $_SERVER['REQUEST_TIME'],
))->execute();
}

View File

@ -323,7 +323,7 @@ class AdminMetaTagTestCase extends DrupalWebTestCase {
class PageNotFoundTestCase extends DrupalWebTestCase {
protected $admin_user;
/**
* Implementation of getInfo().
*/
@ -334,7 +334,7 @@ class PageNotFoundTestCase extends DrupalWebTestCase {
'group' => t('System')
);
}
/**
* Implementation of setUp().
*/
@ -349,7 +349,7 @@ class PageNotFoundTestCase extends DrupalWebTestCase {
function testPageNotFound() {
$this->drupalGet($this->randomName(10));
$this->assertText(t('Page not found'), t('Found the default 404 page'));
$edit = array(
'title' => $this->randomName(10),
'body' => $this->randomName(100)
@ -358,27 +358,26 @@ class PageNotFoundTestCase extends DrupalWebTestCase {
// Use a custom 404 page.
$this->drupalPost('admin/settings/error-reporting', array('site_404' => 'node/' . $node->nid), t('Save configuration'));
$this->drupalGet($this->randomName(10));
$this->assertText($node->title, t('Found the custom 404 page'));
// Logout and check that the user login block is not shown on custom 404 pages.
$this->drupalLogout();
$this->drupalGet($this->randomName(10));
$this->assertText($node->title, t('Found the custom 404 page'));
$this->assertNoText(t('User login'), t('Blocks are not shown on the custom 404 page'));
// Log back in and remove the custom 404 page.
$this->drupalLogin($this->admin_user);
$this->drupalPost('admin/settings/error-reporting', array(), t('Reset to defaults'));
// Logout and check that the user login block is not shown on default 404 pages.
$this->drupalLogout();
$this->drupalGet($this->randomName(10));
$this->assertText(t('Page not found'), t('Found the default 404 page'));
$this->assertNoText(t('User login'), t('Blocks are not shown on the default 404 page'));
}
}

View File

@ -120,7 +120,7 @@ function taxonomy_autocomplete($vid, $string = '') {
$matches = array();
if ($last_string != '') {
$result = db_query_range(db_rewrite_sql("SELECT t.tid, t.name FROM {term_data} t WHERE t.vid = :vid AND LOWER(t.name) LIKE LOWER(:last_string)", 't', 'tid'), array(
':vid' => $vid,
':vid' => $vid,
':last_string' => '%'. $last_string .'%',
), 0, 10);

View File

@ -474,7 +474,7 @@ class TermEditTestCase extends DrupalWebTestCase {
and that term name and description are saved.'),
'group' => t('Taxonomy'));
}
/**
* Implementation of setUp().
*/
@ -525,4 +525,4 @@ class TermEditTestCase extends DrupalWebTestCase {
$this->assertText($edit['name'], t('The randomly generated term name is present.'));
$this->assertText($edit['description'], t('The randomly generated term description is present.'));
}
}
}

View File

@ -494,7 +494,7 @@ class UserAdminTestCase extends DrupalWebTestCase {
$this->assertText($user_c->name, t('Found user C on admin users page'));
$this->assertText($admin_user->name, t('Found Admin user on admin users page'));
// Filter the users by permission 'administer taxonomy'.
// Filter the users by permission 'administer taxonomy'.
$edit = array();
$edit['filter'] = 'permission';
$edit['permission'] = 'administer taxonomy';
@ -516,4 +516,3 @@ class UserAdminTestCase extends DrupalWebTestCase {
$this->assertEqual($account->status, 0, 'User B blocked');
}
}

View File

@ -136,7 +136,7 @@ function default_profile_tasks(&$task, $url) {
// Create a default vocabulary named "Tags", enabled for the 'article' content type.
$description = st('Use tags to group articles on similar topics into categories.');
$help = st('Enter a comma-separated list of words.');
$vid = db_insert('vocabulary')->fields(array(
'name' => 'Tags',
'description' => $description,
@ -150,7 +150,7 @@ function default_profile_tasks(&$task, $url) {
'weight' => 0,
))->execute();
db_insert('vocabulary_node_types')->fields(array('vid' => $vid, 'type' => 'article'))->execute();
// Update the menu router information.
menu_rebuild();
}