Loading core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,22 @@ public function testNodeEditAccess() { // Re-load the node and check the status. $node = Node::load($node->id()); $this->assertTrue($node->isPublished(), 'The node is still published.'); // Try to delete the node and check that we are not redirected to the // conformation form but stay on the content view. $this->assertNotEmpty($this->cssSelect('#views-form-test-node-bulk-form-page-1')); $edit = [ 'node_bulk_form[0]' => TRUE, 'action' => 'node_delete_action', ]; $this->drupalPostForm('test-node-bulk-form', $edit, t('Apply to selected items')); // Test that the action message isn't shown. $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [ '%action' => 'Delete content', '@entity_type_label' => 'Content', '%entity_label' => $node->label(), ])); $this->assertNotEmpty($this->cssSelect('#views-form-test-node-bulk-form-page-1')); } /** Loading core/modules/views/src/Plugin/views/field/BulkForm.php +9 −5 Original line number Diff line number Diff line Loading @@ -402,6 +402,12 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { $entities[$bulk_form_key] = $entity; } // If there were entities selected but the action isn't allowed on any of // them, we don't need to do anything further. if (!$count) { return; } $action->execute($entities); $operation_definition = $action->getPluginDefinition(); Loading @@ -414,14 +420,12 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { else { // Don't display the message unless there are some elements affected and // there is no confirmation form. if ($count) { $this->messenger->addStatus($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [ '%action' => $action->label(), ])); } } } } /** * Returns the message to be displayed when there are no selected items. Loading Loading
core/modules/node/tests/src/Functional/Views/BulkFormAccessTest.php +16 −0 Original line number Diff line number Diff line Loading @@ -128,6 +128,22 @@ public function testNodeEditAccess() { // Re-load the node and check the status. $node = Node::load($node->id()); $this->assertTrue($node->isPublished(), 'The node is still published.'); // Try to delete the node and check that we are not redirected to the // conformation form but stay on the content view. $this->assertNotEmpty($this->cssSelect('#views-form-test-node-bulk-form-page-1')); $edit = [ 'node_bulk_form[0]' => TRUE, 'action' => 'node_delete_action', ]; $this->drupalPostForm('test-node-bulk-form', $edit, t('Apply to selected items')); // Test that the action message isn't shown. $this->assertRaw(new FormattableMarkup('No access to execute %action on the @entity_type_label %entity_label.', [ '%action' => 'Delete content', '@entity_type_label' => 'Content', '%entity_label' => $node->label(), ])); $this->assertNotEmpty($this->cssSelect('#views-form-test-node-bulk-form-page-1')); } /** Loading
core/modules/views/src/Plugin/views/field/BulkForm.php +9 −5 Original line number Diff line number Diff line Loading @@ -402,6 +402,12 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { $entities[$bulk_form_key] = $entity; } // If there were entities selected but the action isn't allowed on any of // them, we don't need to do anything further. if (!$count) { return; } $action->execute($entities); $operation_definition = $action->getPluginDefinition(); Loading @@ -414,14 +420,12 @@ public function viewsFormSubmit(&$form, FormStateInterface $form_state) { else { // Don't display the message unless there are some elements affected and // there is no confirmation form. if ($count) { $this->messenger->addStatus($this->formatPlural($count, '%action was applied to @count item.', '%action was applied to @count items.', [ '%action' => $action->label(), ])); } } } } /** * Returns the message to be displayed when there are no selected items. Loading