Skip to content
Snippets Groups Projects

Issue #2707689: NodeForm::actions() checks for delete access on new entities

4 files
+ 109
35
Compare changes
  • Side-by-side
  • Inline
Files
4
@@ -33,7 +33,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
protected $defaultTheme = 'stark';
/**
* Modules to enable.
@@ -169,9 +169,20 @@ public function testExposedFilter() {
// Only the nodes with the selected term should be shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertSession()->elementsCount('xpath', '//div[@class="view-content"]//a', 2);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node2->toUrl()->toString()}']", 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node3->toUrl()->toString()}']", 1);
$this->assertSession()->pageTextNotContains($node1->getTitle());
$this->assertSession()->linkByHrefNotExists($node1->toUrl()->toString());
$xpath_node2_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node2->toUrl()->toString(),
':label' => $node2->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node2_link, 1);
$xpath_node3_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node3->toUrl()->toString(),
':label' => $node3->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node3_link, 1);
$this->assertSession()->pageTextNotContains($node4->getTitle());
$this->assertSession()->linkByHrefNotExists($node4->toUrl()->toString());
// Expose the filter.
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
@@ -187,8 +198,17 @@ public function testExposedFilter() {
// After switching to 'empty' operator, the node without a term should be
// shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertSession()->elementsCount('xpath', '//div[@class="view-content"]//a', 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node1->toUrl()->toString()}']", 1);
$xpath_node1_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node1->toUrl()->toString(),
':label' => $node1->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node1_link, 1);
$this->assertSession()->pageTextNotContains($node2->getTitle());
$this->assertSession()->linkByHrefNotExists($node2->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node3->getTitle());
$this->assertSession()->linkByHrefNotExists($node3->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node4->getTitle());
$this->assertSession()->linkByHrefNotExists($node4->toUrl()->toString());
// Set the operator to 'not empty'.
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
@@ -199,10 +219,23 @@ public function testExposedFilter() {
// After switching to 'not empty' operator, all nodes with terms should be
// shown.
$this->drupalGet('test-filter-taxonomy-index-tid');
$this->assertSession()->elementsCount('xpath', '//div[@class="view-content"]//a', 3);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node2->toUrl()->toString()}']", 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node3->toUrl()->toString()}']", 1);
$this->assertSession()->elementsCount('xpath', "//div[@class='view-content']//a[@href='{$node4->toUrl()->toString()}']", 1);
$this->assertSession()->pageTextNotContains($node1->getTitle());
$this->assertSession()->linkByHrefNotExists($node1->toUrl()->toString());
$xpath_node2_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node2->toUrl()->toString(),
':label' => $node2->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node2_link, 1);
$xpath_node3_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node3->toUrl()->toString(),
':label' => $node3->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node3_link, 1);
$xpath_node4_link = $this->assertSession()->buildXPathQuery('//div[@class="views-row"]//a[@href=:url and text()=:label]', [
':url' => $node4->toUrl()->toString(),
':label' => $node4->label(),
]);
$this->assertSession()->elementsCount('xpath', $xpath_node4_link, 1);
// Select 'Term ID' as the field to be displayed.
$edit = ['name[taxonomy_term_field_data.tid]' => TRUE];
@@ -231,7 +264,15 @@ public function testExposedFilter() {
$this->drupalGet('admin/structure/views/view/test_taxonomy_term_name/edit/default');
$this->submitForm([], 'Save');
$this->submitForm([], 'Update preview');
$this->assertSession()->elementNotExists('xpath', "//div[@class='view-content']");
$this->assertSession()->pageTextNotContains($node1->getTitle());
$this->assertSession()->linkByHrefNotExists($node1->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node2->getTitle());
$this->assertSession()->linkByHrefNotExists($node2->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node3->getTitle());
$this->assertSession()->linkByHrefNotExists($node3->toUrl()->toString());
$this->assertSession()->pageTextNotContains($node4->getTitle());
$this->assertSession()->linkByHrefNotExists($node4->toUrl()->toString());
$this->assertSession()->elementNotExists('xpath', "//div[@class='views-row']");
}
/**
Loading