Loading modules/simpletest/tests/taxonomy_nodes_test.info 0 → 100644 +6 −0 Original line number Diff line number Diff line name = "Taxonomy module node list tests" description = "Support module for taxonomy node list related testing." package = Testing version = VERSION core = 7.x hidden = TRUE modules/simpletest/tests/taxonomy_nodes_test.module 0 → 100644 +26 −0 Original line number Diff line number Diff line <?php /** * @file * Dummy module implementing hook_query_TAG_alter. */ /** * Implements hook_query_TAG_alter(). */ function taxonomy_nodes_test_query_node_access_alter(QueryAlterableInterface $query) { if (variable_get('taxonomy_nodes_test_query_node_access_alter', FALSE)) { $taxonomy_index = FALSE; foreach ($query->getTables() as $alias => $table) { if ($table['table'] == 'taxonomy_index') { $taxonomy_index = TRUE; } } if ($taxonomy_index) { // Verify that additional data can be added to the default // taxonomy_select_nodes() query by altering it. $query->leftJoin('taxonomy_term_data', 'ttd', 'ttd.tid = t.tid'); } } } modules/taxonomy/taxonomy.module +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = arr } $query = db_select('taxonomy_index', 't'); $query->addTag('node_access'); $query->condition('tid', $tid); $query->condition('t.tid', $tid); if ($pager) { $count_query = clone $query; $count_query->addExpression('COUNT(t.nid)'); Loading modules/taxonomy/taxonomy.test +23 −0 Original line number Diff line number Diff line Loading @@ -1008,6 +1008,29 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertEqual(count($terms), 0, 'No terms loaded when restricted by a non-existing vocabulary.'); } /** * Tests that taxonomy term detail page is working even after the default * taxonomy_select_nodes() query is altered. */ public function testTaxonomySelectNodesAlter() { // Create a new term. $term = $this->createTerm($this->vocabulary); // Create an article. $settings = array( 'type' => 'article', $this->instance['field_name'] => array(LANGUAGE_NONE => array(array('tid' => $term->tid))), ); $this->drupalCreateNode($settings); // Check if the taxonomy term detail page is working. module_enable(array('taxonomy_nodes_test')); variable_set('taxonomy_nodes_test_query_node_access_alter', TRUE); $this->drupalGet('taxonomy/term/' . $term->tid); $this->assertResponse(200, 'The taxonomy term page is working.'); variable_set('taxonomy_nodes_test_query_node_access_alter', FALSE); } } /** Loading Loading
modules/simpletest/tests/taxonomy_nodes_test.info 0 → 100644 +6 −0 Original line number Diff line number Diff line name = "Taxonomy module node list tests" description = "Support module for taxonomy node list related testing." package = Testing version = VERSION core = 7.x hidden = TRUE
modules/simpletest/tests/taxonomy_nodes_test.module 0 → 100644 +26 −0 Original line number Diff line number Diff line <?php /** * @file * Dummy module implementing hook_query_TAG_alter. */ /** * Implements hook_query_TAG_alter(). */ function taxonomy_nodes_test_query_node_access_alter(QueryAlterableInterface $query) { if (variable_get('taxonomy_nodes_test_query_node_access_alter', FALSE)) { $taxonomy_index = FALSE; foreach ($query->getTables() as $alias => $table) { if ($table['table'] == 'taxonomy_index') { $taxonomy_index = TRUE; } } if ($taxonomy_index) { // Verify that additional data can be added to the default // taxonomy_select_nodes() query by altering it. $query->leftJoin('taxonomy_term_data', 'ttd', 'ttd.tid = t.tid'); } } }
modules/taxonomy/taxonomy.module +1 −1 Original line number Diff line number Diff line Loading @@ -207,7 +207,7 @@ function taxonomy_select_nodes($tid, $pager = TRUE, $limit = FALSE, $order = arr } $query = db_select('taxonomy_index', 't'); $query->addTag('node_access'); $query->condition('tid', $tid); $query->condition('t.tid', $tid); if ($pager) { $count_query = clone $query; $count_query->addExpression('COUNT(t.nid)'); Loading
modules/taxonomy/taxonomy.test +23 −0 Original line number Diff line number Diff line Loading @@ -1008,6 +1008,29 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertEqual(count($terms), 0, 'No terms loaded when restricted by a non-existing vocabulary.'); } /** * Tests that taxonomy term detail page is working even after the default * taxonomy_select_nodes() query is altered. */ public function testTaxonomySelectNodesAlter() { // Create a new term. $term = $this->createTerm($this->vocabulary); // Create an article. $settings = array( 'type' => 'article', $this->instance['field_name'] => array(LANGUAGE_NONE => array(array('tid' => $term->tid))), ); $this->drupalCreateNode($settings); // Check if the taxonomy term detail page is working. module_enable(array('taxonomy_nodes_test')); variable_set('taxonomy_nodes_test_query_node_access_alter', TRUE); $this->drupalGet('taxonomy/term/' . $term->tid); $this->assertResponse(200, 'The taxonomy term page is working.'); variable_set('taxonomy_nodes_test_query_node_access_alter', FALSE); } } /** Loading