Commit 0f77f652 authored by Dries's avatar Dries

- Patch #394524 by Berdir, Damien Tournoud: converted to the new database abstraction layer.

parent 83631203
...@@ -121,7 +121,9 @@ protected function assert($status, $message = '', $group = 'Other', array $calle ...@@ -121,7 +121,9 @@ protected function assert($status, $message = '', $group = 'Other', array $calle
); );
// Store assertion for display after the test has completed. // Store assertion for display after the test has completed.
db_insert('simpletest')->fields($assertion)->execute(); db_insert('simpletest')
->fields($assertion)
->execute();
// Return to testing prefix. // Return to testing prefix.
$db_prefix = $current_db_prefix; $db_prefix = $current_db_prefix;
...@@ -679,7 +681,10 @@ protected function drupalCreateNode($settings = array()) { ...@@ -679,7 +681,10 @@ protected function drupalCreateNode($settings = array()) {
node_save($node); node_save($node);
// small hack to link revisions to our test user // small hack to link revisions to our test user
db_query('UPDATE {node_revision} SET uid = %d WHERE vid = %d', $node->uid, $node->vid); db_update('node_revision')
->fields(array('uid' => $node->uid))
->condition('vid', $node->vid)
->execute();
return $node; return $node;
} }
...@@ -832,15 +837,22 @@ protected function drupalCreateRole(array $permissions) { ...@@ -832,15 +837,22 @@ protected function drupalCreateRole(array $permissions) {
// Create new role. // Create new role.
$role_name = $this->randomName(); $role_name = $this->randomName();
db_query("INSERT INTO {role} (name) VALUES ('%s')", $role_name); db_insert('role')
$role = db_fetch_object(db_query("SELECT * FROM {role} WHERE name = '%s'", $role_name)); ->fields(array('name' => $role_name))
->execute();
$role = db_query('SELECT * FROM {role} WHERE name = :name', array(':name' => $role_name))->fetchObject();
$this->assertTrue($role, t('Created role of name: @role_name, id: @rid', array('@role_name' => $role_name, '@rid' => (isset($role->rid) ? $role->rid : t('-n/a-')))), t('Role')); $this->assertTrue($role, t('Created role of name: @role_name, id: @rid', array('@role_name' => $role_name, '@rid' => (isset($role->rid) ? $role->rid : t('-n/a-')))), t('Role'));
if ($role && !empty($role->rid)) { if ($role && !empty($role->rid)) {
// Assign permissions to role and mark it for clean-up. // Assign permissions to role and mark it for clean-up.
$query = db_insert('role_permission')->fields(array('rid', 'permission'));
foreach ($permissions as $permission_string) { foreach ($permissions as $permission_string) {
db_query("INSERT INTO {role_permission} (rid, permission) VALUES (%d, '%s')", $role->rid, $permission_string); $query->values(array(
'rid' => $role->rid,
'permission' => $permission_string,
));
} }
$count = db_result(db_query("SELECT COUNT(*) FROM {role_permission} WHERE rid = %d", $role->rid)); $query->execute();
$count = db_query('SELECT COUNT(*) FROM {role_permission} WHERE rid = :rid', array(':rid' => $role->rid))->fetchField();
$this->assertTrue($count == count($permissions), t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role')); $this->assertTrue($count == count($permissions), t('Created permissions: @perms', array('@perms' => implode(', ', $permissions))), t('Role'));
return $role->rid; return $role->rid;
} }
......
...@@ -102,7 +102,9 @@ function _simpletest_format_summary_line($summary) { ...@@ -102,7 +102,9 @@ function _simpletest_format_summary_line($summary) {
*/ */
function simpletest_run_tests($test_list, $reporter = 'drupal') { function simpletest_run_tests($test_list, $reporter = 'drupal') {
cache_clear_all(); cache_clear_all();
$test_id = db_insert('simpletest_test_id')->useDefaults(array('test_id'))->execute(); $test_id = db_insert('simpletest_test_id')
->useDefaults(array('test_id'))
->execute();
// Get the info for the first test being run. // Get the info for the first test being run.
$first_test = array_shift($test_list); $first_test = array_shift($test_list);
...@@ -325,7 +327,7 @@ function simpletest_clean_temporary_directories() { ...@@ -325,7 +327,7 @@ function simpletest_clean_temporary_directories() {
function simpletest_clean_results_table($test_id = NULL) { function simpletest_clean_results_table($test_id = NULL) {
if (variable_get('simpletest_clear_results', TRUE)) { if (variable_get('simpletest_clear_results', TRUE)) {
if ($test_id) { if ($test_id) {
$count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))); $count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id} WHERE test_id = :test_id', array(':test_id' => $test_id))->fetchField();
db_delete("simpletest") db_delete("simpletest")
->condition('test_id', $test_id) ->condition('test_id', $test_id)
...@@ -335,7 +337,7 @@ function simpletest_clean_results_table($test_id = NULL) { ...@@ -335,7 +337,7 @@ function simpletest_clean_results_table($test_id = NULL) {
->execute(); ->execute();
} }
else { else {
$count = db_result(db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}')); $count = db_query('SELECT COUNT(test_id) FROM {simpletest_test_id}')->fetchField();
// Clear test results. // Clear test results.
db_delete("simpletest")->execute(); db_delete("simpletest")->execute();
......
...@@ -57,7 +57,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase { ...@@ -57,7 +57,7 @@ class ActionsConfigurationTestCase extends DrupalWebTestCase {
$this->assertRaw(t('Action %action was deleted', array('%action' => $new_action_description)), t('Make sure that we get a delete confirmation message.')); $this->assertRaw(t('Action %action was deleted', array('%action' => $new_action_description)), t('Make sure that we get a delete confirmation message.'));
$this->drupalGet('admin/settings/actions/manage'); $this->drupalGet('admin/settings/actions/manage');
$this->assertNoText($new_action_description, t("Make sure the action description does not appear on the overview page after we've deleted the action.")); $this->assertNoText($new_action_description, t("Make sure the action description does not appear on the overview page after we've deleted the action."));
$exists = db_result(db_query("SELECT aid FROM {actions} WHERE callback = 'drupal_goto_action'")); $exists = db_query('SELECT aid FROM {actions} WHERE callback = :callback', array(':callback' => 'drupal_goto_action'))->fetchField();
$this->assertFalse($exists, t('Make sure the action is gone from the database after being deleted.')); $this->assertFalse($exists, t('Make sure the action is gone from the database after being deleted.'));
} }
} }
...@@ -251,31 +251,31 @@ class HookBootExitTestCase extends DrupalWebTestCase { ...@@ -251,31 +251,31 @@ class HookBootExitTestCase extends DrupalWebTestCase {
variable_set('cache', CACHE_DISABLED); variable_set('cache', CACHE_DISABLED);
$this->drupalGet(''); $this->drupalGet('');
$calls = 1; $calls = 1;
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot called with disabled cache.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot called with disabled cache.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit called with disabled cache.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with disabled cache.'));
// Test with normal cache. Boot and exit should be called. // Test with normal cache. Boot and exit should be called.
variable_set('cache', CACHE_NORMAL); variable_set('cache', CACHE_NORMAL);
$this->drupalGet(''); $this->drupalGet('');
$calls++; $calls++;
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot called with normal cache.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot called with normal cache.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit called with normal cache.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with normal cache.'));
// Test with aggressive cache. Boot and exit should not fire since the // Test with aggressive cache. Boot and exit should not fire since the
// page is cached. // page is cached.
variable_set('cache', CACHE_AGGRESSIVE); variable_set('cache', CACHE_AGGRESSIVE);
$this->assertTrue(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been cached.')); $this->assertTrue(cache_get(url('', array('absolute' => TRUE)), 'cache_page'), t('Page has been cached.'));
$this->drupalGet(''); $this->drupalGet('');
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot not called with agressive cache and a cached page.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot not called with agressive cache and a cached page.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit not called with agressive cache and a cached page.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit not called with agressive cache and a cached page.'));
// Test with aggressive cache and page cache cleared. Boot and exit should // Test with aggressive cache and page cache cleared. Boot and exit should
// be called. // be called.
$this->assertTrue(db_delete('cache_page')->execute(), t('Page cache cleared.')); $this->assertTrue(db_delete('cache_page')->execute(), t('Page cache cleared.'));
$this->drupalGet(''); $this->drupalGet('');
$calls++; $calls++;
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_boot'")->fetchField(), $calls, t('hook_boot called with agressive cache and no cached page.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_boot'))->fetchField(), $calls, t('hook_boot called with agressive cache and no cached page.'));
$this->assertEqual(db_query("SELECT COUNT(*) FROM {watchdog} WHERE type = 'system_test' AND message = 'hook_exit'")->fetchField(), $calls, t('hook_exit called with agressive cache and no cached page.')); $this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message', array(':type' => 'system_test', ':message' => 'hook_exit'))->fetchField(), $calls, t('hook_exit called with agressive cache and no cached page.'));
} }
} }
This diff is collapsed.
...@@ -62,5 +62,5 @@ function error_test_trigger_exception() { ...@@ -62,5 +62,5 @@ function error_test_trigger_exception() {
*/ */
function error_test_trigger_pdo_exception() { function error_test_trigger_pdo_exception() {
define('SIMPLETEST_COLLECT_ERRORS', FALSE); define('SIMPLETEST_COLLECT_ERRORS', FALSE);
db_query("SELECT * FROM bananas_are_awesome"); db_query('SELECT * FROM bananas_are_awesome');
} }
...@@ -568,7 +568,7 @@ class FileSaveUploadTest extends FileHookTestCase { ...@@ -568,7 +568,7 @@ class FileSaveUploadTest extends FileHookTestCase {
* Test the file_save_upload() function. * Test the file_save_upload() function.
*/ */
function testNormal() { function testNormal() {
$max_fid_after = db_result(db_query('SELECT MAX(fid) AS fid FROM {files}')); $max_fid_after = db_query('SELECT MAX(fid) AS fid FROM {files}')->fetchField();
$this->assertTrue($max_fid_after > $this->maxFidBefore, t('A new file was created.')); $this->assertTrue($max_fid_after > $this->maxFidBefore, t('A new file was created.'));
$file1 = file_load($max_fid_after); $file1 = file_load($max_fid_after);
$this->assertTrue($file1, t('Loaded the file.')); $this->assertTrue($file1, t('Loaded the file.'));
......
...@@ -83,14 +83,14 @@ class MenuIncTestCase extends DrupalWebTestCase { ...@@ -83,14 +83,14 @@ class MenuIncTestCase extends DrupalWebTestCase {
$this->drupalLogin($admin_user); $this->drupalLogin($admin_user);
$sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'"; $sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'";
$name = db_result(db_query($sql)); $name = db_query($sql)->fetchField();
$this->assertEqual($name, 'original', t('Menu name is "original".')); $this->assertEqual($name, 'original', t('Menu name is "original".'));
// Force a menu rebuild by going to the modules page. // Force a menu rebuild by going to the modules page.
$this->drupalGet('admin/build/modules', array('query' => array("hook_menu_name" => 'changed'))); $this->drupalGet('admin/build/modules', array('query' => array("hook_menu_name" => 'changed')));
$sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'"; $sql = "SELECT menu_name FROM {menu_links} WHERE router_path = 'menu_name_test'";
$name = db_result(db_query($sql)); $name = db_query($sql)->fetchField();
$this->assertEqual($name, 'changed', t('Menu name was successfully changed after rebuild.')); $this->assertEqual($name, 'changed', t('Menu name was successfully changed after rebuild.'));
} }
...@@ -98,9 +98,9 @@ class MenuIncTestCase extends DrupalWebTestCase { ...@@ -98,9 +98,9 @@ class MenuIncTestCase extends DrupalWebTestCase {
* Tests for menu hiearchy. * Tests for menu hiearchy.
*/ */
function testMenuHiearchy() { function testMenuHiearchy() {
$parent_link = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => 'menu-test/hierarchy/parent'))->fetchAssoc(); $parent_link = db_query('SELECT * FROM {menu_links} WHERE link_path = :link_path', array(':link_path' => 'menu-test/hierarchy/parent'))->fetchAssoc();
$child_link = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => 'menu-test/hierarchy/parent/child'))->fetchAssoc(); $child_link = db_query('SELECT * FROM {menu_links} WHERE link_path = :link_path', array(':link_path' => 'menu-test/hierarchy/parent/child'))->fetchAssoc();
$unattached_child_link = db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path", array(':link_path' => 'menu-test/hierarchy/parent/child2/child'))->fetchAssoc(); $unattached_child_link = db_query('SELECT * FROM {menu_links} WHERE link_path = :link_path', array(':link_path' => 'menu-test/hierarchy/parent/child2/child'))->fetchAssoc();
$this->assertEqual($child_link['plid'], $parent_link['mlid'], t('The parent of a directly attached child is correct.')); $this->assertEqual($child_link['plid'], $parent_link['mlid'], t('The parent of a directly attached child is correct.'));
$this->assertEqual($unattached_child_link['plid'], $parent_link['mlid'], t('The parent of a non-directly attached child is correct.')); $this->assertEqual($unattached_child_link['plid'], $parent_link['mlid'], t('The parent of a non-directly attached child is correct.'));
...@@ -142,14 +142,14 @@ class MenuRebuildTestCase extends DrupalWebTestCase { ...@@ -142,14 +142,14 @@ class MenuRebuildTestCase extends DrupalWebTestCase {
*/ */
function testMenuRebuildByVariable() { function testMenuRebuildByVariable() {
// Check if 'admin' path exists. // Check if 'admin' path exists.
$admin_exists = db_result(db_query("SELECT path from {menu_router} WHERE path = 'admin'")); $admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
$this->assertEqual($admin_exists, 'admin', t("The path 'admin/' exists prior to deleting.")); $this->assertEqual($admin_exists, 'admin', t("The path 'admin/' exists prior to deleting."));
// Delete the path item 'admin', and test that the path doesn't exist in the database. // Delete the path item 'admin', and test that the path doesn't exist in the database.
$delete = db_delete('menu_router') $delete = db_delete('menu_router')
->condition('path', 'admin') ->condition('path', 'admin')
->execute(); ->execute();
$admin_exists = db_result(db_query("SELECT path from {menu_router} WHERE path = 'admin'")); $admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
$this->assertFalse($admin_exists, t("The path 'admin/' has been deleted and doesn't exist in the database.")); $this->assertFalse($admin_exists, t("The path 'admin/' has been deleted and doesn't exist in the database."));
// Now we enable the rebuild variable and trigger menu_execute_active_handler() // Now we enable the rebuild variable and trigger menu_execute_active_handler()
...@@ -157,7 +157,7 @@ class MenuRebuildTestCase extends DrupalWebTestCase { ...@@ -157,7 +157,7 @@ class MenuRebuildTestCase extends DrupalWebTestCase {
variable_set('menu_rebuild_needed', TRUE); variable_set('menu_rebuild_needed', TRUE);
// menu_execute_active_handler() should trigger the rebuild. // menu_execute_active_handler() should trigger the rebuild.
$this->drupalGet('<front>'); $this->drupalGet('<front>');
$admin_exists = db_result(db_query("SELECT path from {menu_router} WHERE path = 'admin'")); $admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
$this->assertEqual($admin_exists, 'admin', t("The menu has been rebuilt, the path 'admin' now exists again.")); $this->assertEqual($admin_exists, 'admin', t("The menu has been rebuilt, the path 'admin' now exists again."));
} }
......
...@@ -37,7 +37,11 @@ class ModuleUnitTest extends DrupalWebTestCase { ...@@ -37,7 +37,11 @@ class ModuleUnitTest extends DrupalWebTestCase {
$this->assertModuleList($base_module_list, t('After adding a module')); $this->assertModuleList($base_module_list, t('After adding a module'));
// Try to mess with the module weights. // Try to mess with the module weights.
db_query("UPDATE {system} SET weight = 20 WHERE name = 'path' AND type = 'module'"); db_update('system')
->fields(array('weight' => 20))
->condition('name', 'path')
->condition('type', 'module')
->execute();
// Reset the module list. // Reset the module list.
module_list(TRUE); module_list(TRUE);
// Move path at the end of the array. // Move path at the end of the array.
......
...@@ -24,7 +24,7 @@ class RegistryParseFileTestCase extends DrupalWebTestCase { ...@@ -24,7 +24,7 @@ class RegistryParseFileTestCase extends DrupalWebTestCase {
function testRegistryParseFile() { function testRegistryParseFile() {
_registry_parse_file($this->fileName, $this->getFileContents()); _registry_parse_file($this->fileName, $this->getFileContents());
foreach (array('functionName', 'className', 'interfaceName') as $resource) { foreach (array('functionName', 'className', 'interfaceName') as $resource) {
$foundName = db_result(db_query("SELECT name FROM {registry} WHERE name = '%s'", $this->$resource)); $foundName = db_query('SELECT name FROM {registry} WHERE name = :name', array(':name' => $this->$resource))->fetchField();
$this->assertTrue($this->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$resource))); $this->assertTrue($this->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$resource)));
} }
} }
...@@ -75,11 +75,22 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase { ...@@ -75,11 +75,22 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
if ($fileType == 'existing_changed') { if ($fileType == 'existing_changed') {
// Insert a record with a dodgy md5. // Insert a record with a dodgy md5.
$this->$fileType->fakeMD5 = md5($this->$fileType->contents . rand()); $this->$fileType->fakeMD5 = md5($this->$fileType->contents . rand());
db_query("INSERT INTO {registry_file} (md5, filename) VALUES ('%s', '%s')", $this->$fileType->fakeMD5, $this->$fileType->fileName); db_insert('registry_file')
->fields(array(
'md5' => $this->$fileType->fakeMD5,
'filename' => $this->$fileType->fileName,
))
->execute();
// Insert some fake resource records. // Insert some fake resource records.
foreach (array('function', 'class', 'interface') as $type) { foreach (array('function', 'class', 'interface') as $type) {
db_query("INSERT INTO {registry} (name, type, filename) VALUES ('%s', '%s', '%s')", $type . md5(rand()), $type, $this->$fileType->fileName); db_insert('registry')
->fields(array(
'name' => $type . md5(rand()),
'type' => $type,
'filename' => $this->$fileType->fileName,
))
->execute();
} }
} }
} }
...@@ -93,11 +104,11 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase { ...@@ -93,11 +104,11 @@ class RegistryParseFilesTestCase extends DrupalWebTestCase {
foreach ($this->fileTypes as $fileType) { foreach ($this->fileTypes as $fileType) {
// Test that we have all the right resources. // Test that we have all the right resources.
foreach (array('functionName', 'className', 'interfaceName') as $resource) { foreach (array('functionName', 'className', 'interfaceName') as $resource) {
$foundName = db_result(db_query("SELECT name FROM {registry} WHERE name = '%s'", $this->$fileType->$resource)); $foundName = db_query('SELECT name FROM {registry} WHERE name = :name', array(':name' => $this->$fileType->$resource))->fetchField();
$this->assertTrue($this->$fileType->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$fileType->$resource))); $this->assertTrue($this->$fileType->$resource == $foundName, t('Resource "@resource" found.', array('@resource' => $this->$fileType->$resource)));
} }
// Test that we have the right md5. // Test that we have the right md5.
$md5 = db_result(db_query("SELECT md5 FROM {registry_file} WHERE filename = '%s'", $this->$fileType->fileName)); $md5 = db_query('SELECT md5 FROM {registry_file} WHERE filename = :filename', array(':filename' => $this->$fileType->fileName))->fetchField();
$this->assertTrue(md5($this->$fileType->contents) == $md5, t('MD5 for "@filename" matched.' . $fileType . $md5, array('@filename' => $this->$fileType->fileName))); $this->assertTrue(md5($this->$fileType->contents) == $md5, t('MD5 for "@filename" matched.' . $fileType . $md5, array('@filename' => $this->$fileType->fileName)));
} }
} }
......
...@@ -103,7 +103,9 @@ class SchemaTestCase extends DrupalWebTestCase { ...@@ -103,7 +103,9 @@ class SchemaTestCase extends DrupalWebTestCase {
function tryInsert($table = 'test_table') { function tryInsert($table = 'test_table') {
try { try {
db_query("INSERT INTO {" . $table . "} (id) VALUES (:id)", array(':id' => mt_rand(10, 20))); db_insert($table)
->fields(array('id' => mt_rand(10, 20)))
->execute();
return TRUE; return TRUE;
} }
catch (Exception $e) { catch (Exception $e) {
......
...@@ -22,7 +22,12 @@ function taxonomy_test_taxonomy_term_insert($term) { ...@@ -22,7 +22,12 @@ function taxonomy_test_taxonomy_term_insert($term) {
if (!empty($term->antonyms)) { if (!empty($term->antonyms)) {
foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) { foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) {
if ($antonym) { if ($antonym) {
db_insert('term_antonym')->fields(array('tid' => $term->tid, 'name' => rtrim($antonym)))->execute(); db_insert('term_antonym')
->fields(array(
'tid' => $term->tid,
'name' => rtrim($antonym),
))
->execute();
} }
} }
} }
...@@ -36,7 +41,12 @@ function taxonomy_test_taxonomy_term_update($term) { ...@@ -36,7 +41,12 @@ function taxonomy_test_taxonomy_term_update($term) {
if (!empty($term->antonyms)) { if (!empty($term->antonyms)) {
foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) { foreach (explode ("\n", str_replace("\r", '', $term->antonyms)) as $antonym) {
if ($antonym) { if ($antonym) {
db_insert('term_antonym')->fields(array('tid' => $term->tid, 'name' => rtrim($antonym)))->execute(); db_insert('term_antonym')
->fields(array(
'tid' => $term->tid,
'name' => rtrim($antonym),
))
->execute();
} }
} }
} }
...@@ -46,7 +56,9 @@ function taxonomy_test_taxonomy_term_update($term) { ...@@ -46,7 +56,9 @@ function taxonomy_test_taxonomy_term_update($term) {
* Implement hook_taxonomy_term_delete(). * Implement hook_taxonomy_term_delete().
*/ */
function taxonomy_test_taxonomy_term_delete($term) { function taxonomy_test_taxonomy_term_delete($term) {
db_delete('term_antonym')->condition('tid', $term->tid)->execute(); db_delete('term_antonym')
->condition('tid', $term->tid)
->execute();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment