update drupal

This commit is contained in:
Tessier
2020-10-15 11:59:37 +02:00
parent ebb5db14b5
commit d8b9162932
558 changed files with 5954 additions and 4475 deletions
@@ -63,13 +63,13 @@ class TaxonomyTermPagerTest extends TaxonomyTestBase {
$this->createTerm($this->vocabulary);
}
// Get Page 1.
// Ensure that pager is visible on page 1.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
$this->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 1');
$this->assertPattern('|<nav class="pager" [^>]*>|');
// Get Page 2.
// Ensure that pager is visible on page 2.
$this->drupalGet('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview', ['query' => ['page' => 1]]);
$this->assertPattern('|<nav class="pager" [^>]*>|', 'Pager is visible on page 2');
$this->assertPattern('|<nav class="pager" [^>]*>|');
}
}
@@ -117,10 +117,12 @@ class TermIndexTest extends TaxonomyTestBase {
// Check that the term is indexed, and only once.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$connection = Database::getConnection();
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_1->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed once.');
// Update the article to change one term.
@@ -128,15 +130,19 @@ class TermIndexTest extends TaxonomyTestBase {
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Check that both terms are indexed.
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_1->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed.');
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_2->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed.');
// Update the article to change another term.
@@ -144,15 +150,19 @@ class TermIndexTest extends TaxonomyTestBase {
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
// Check that only one term is indexed.
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_1->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(0, $index_count, 'Term 1 is not indexed.');
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_2->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed once.');
// Redo the above tests without interface.
@@ -164,15 +174,19 @@ class TermIndexTest extends TaxonomyTestBase {
$node->save();
// Check that the index was not changed.
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_1->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(0, $index_count, 'Term 1 is not indexed.');
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_2->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed once.');
// Update the article to change one term.
@@ -180,15 +194,19 @@ class TermIndexTest extends TaxonomyTestBase {
$node->save();
// Check that both terms are indexed.
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_1->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed.');
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_2->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 2 is indexed.');
// Update the article to change another term.
@@ -196,15 +214,19 @@ class TermIndexTest extends TaxonomyTestBase {
$node->save();
// Check that only one term is indexed.
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_1->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_1->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(1, $index_count, 'Term 1 is indexed once.');
$index_count = $connection->query('SELECT COUNT(*) FROM {taxonomy_index} WHERE nid = :nid AND tid = :tid', [
':nid' => $node->id(),
':tid' => $term_2->id(),
])->fetchField();
$index_count = $connection->select('taxonomy_index')
->condition('nid', $node->id())
->condition('tid', $term_2->id())
->countQuery()
->execute()
->fetchField();
$this->assertEqual(0, $index_count, 'Term 2 is not indexed.');
}
@@ -142,7 +142,7 @@ class TermLanguageTest extends TaxonomyTestBase {
// Overview page in the other language shows the translated term
$this->drupalGet('bb/admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/overview');
$this->assertPattern('|<a[^>]*>' . $translated_title . '</a>|', 'The term language is correct');
$this->assertPattern('|<a[^>]*>' . $translated_title . '</a>|');
}
}
@@ -3,6 +3,7 @@
namespace Drupal\Tests\taxonomy\Functional\Views;
use Drupal\views\Views;
use Drupal\views\ViewExecutable;
/**
* Tests the taxonomy term on node relationship handler.
@@ -60,4 +61,52 @@ class RelationshipNodeTermDataTest extends TaxonomyTestBase {
$this->assertIdenticalResultset($view, $expected_result, $column_map);
}
/**
* Tests that the 'taxonomy_term_access' tag is added to the Views query.
*/
public function testTag() {
// Change the view to test relation limited by vocabulary.
$this->config('views.view.test_taxonomy_node_term_data')
->set('display.default.display_options.relationships.term_node_tid.vids', ['views_testing_tags'])
->save();
$view = Views::getView('test_taxonomy_node_term_data');
$this->executeView($view, [$this->term1->id()]);
// By default, view has taxonomy_term_access tag.
$this->assertQueriesTermAccessTag($view, TRUE);
// The term_access tag is not set if disable_sql_rewrite is set.
$view = Views::getView('test_taxonomy_node_term_data');
$display = $view->getDisplay();
$display_options = $display->getOption('query');
$display_options['options']['disable_sql_rewrite'] = TRUE;
$display->setOption('query', $display_options);
$view->save();
$this->executeView($view, [$this->term1->id()]);
$this->assertQueriesTermAccessTag($view, FALSE);
}
/**
* Assert views queries have taxonomy_term_access tag.
*
* @param \Drupal\views\ViewExecutable $view
* The View to check for the term access tag.
* @param bool $hasTag
* The expected existence of taxonomy_term_access tag.
*/
protected function assertQueriesTermAccessTag(ViewExecutable $view, $hasTag) {
$main_query = $view->build_info['query'];
$count_query = $view->build_info['count_query'];
foreach ([$main_query, $count_query] as $query) {
$tables = $query->getTables();
foreach ($tables as $join_table) {
if (is_object($join_table['table'])) {
$this->assertSame($join_table['table']->hasTag('taxonomy_term_access'), $hasTag);
}
}
}
}
}
@@ -231,4 +231,41 @@ class TaxonomyIndexTidUiTest extends UITestBase {
$this->assertTrue(empty($preview), 'No results.');
}
/**
* Tests that an exposed taxonomy filter doesn't show unpublished terms.
*/
public function testExposedUnpublishedFilterOptions() {
$this->terms[1][0]->setUnpublished()->save();
// Expose the filter.
$this->drupalPostForm('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid', [], 'Expose filter');
$edit = ['options[expose_button][checkbox][checkbox]' => TRUE];
$this->drupalPostForm(NULL, $edit, 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
// Make sure the unpublished term is shown to the admin user.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertNotEmpty($this->cssSelect('option[value="' . $this->terms[0][0]->id() . '"]'));
$this->assertNotEmpty($this->cssSelect('option[value="' . $this->terms[1][0]->id() . '"]'));
$this->drupalLogout();
$this->drupalGet('test-filter-taxonomy-index-tid');
// Make sure the unpublished term isn't shown to the anonymous user.
$this->assertNotEmpty($this->cssSelect('option[value="' . $this->terms[0][0]->id() . '"]'));
$this->assertEmpty($this->cssSelect('option[value="' . $this->terms[1][0]->id() . '"]'));
// Tests that the term also isn't shown when not showing hierarchy.
$this->drupalLogin($this->adminUser);
$edit = [
'options[hierarchy]' => FALSE,
];
$this->drupalPostForm('admin/structure/views/nojs/handler-extra/test_filter_taxonomy_index_tid/default/filter/tid', $edit, 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertNotEmpty($this->cssSelect('option[value="' . $this->terms[0][0]->id() . '"]'));
$this->assertNotEmpty($this->cssSelect('option[value="' . $this->terms[1][0]->id() . '"]'));
$this->drupalLogout();
$this->drupalGet('test-filter-taxonomy-index-tid');
// Make sure the unpublished term isn't shown to the anonymous user.
$this->assertNotEmpty($this->cssSelect('option[value="' . $this->terms[0][0]->id() . '"]'));
$this->assertEmpty($this->cssSelect('option[value="' . $this->terms[1][0]->id() . '"]'));
}
}