function TrackerTest::testTrackerAdminUnpublish

Same name and namespace in other branches
  1. 7.x modules/tracker/tracker.test \TrackerTest::testTrackerAdminUnpublish()
  2. 9 core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerAdminUnpublish()
  3. 10 core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerAdminUnpublish()
  4. 11.x core/modules/tracker/tests/src/Functional/TrackerTest.php \Drupal\Tests\tracker\Functional\TrackerTest::testTrackerAdminUnpublish()

Tests that publish/unpublish works at admin/content/node.

File

core/modules/tracker/tests/src/Functional/TrackerTest.php, line 424

Class

TrackerTest
Create and delete nodes and check for their display in the tracker listings.

Namespace

Drupal\Tests\tracker\Functional

Code

public function testTrackerAdminUnpublish() {
    \Drupal::service('module_installer')->install([
        'views',
    ]);
    \Drupal::service('router.builder')->rebuild();
    $admin_user = $this->drupalCreateUser([
        'access content overview',
        'administer nodes',
        'bypass node access',
    ]);
    $this->drupalLogin($admin_user);
    $node = $this->drupalCreateNode([
        'title' => $this->randomMachineName(),
    ]);
    // Assert that the node is displayed.
    $this->drupalGet('activity');
    $this->assertText($node->label(), 'A node is displayed on the tracker listing pages.');
    // Unpublish the node and ensure that it's no longer displayed.
    $edit = [
        'action' => 'node_unpublish_action',
        'node_bulk_form[0]' => $node->id(),
    ];
    $this->drupalPostForm('admin/content', $edit, t('Apply to selected items'));
    $this->drupalGet('activity');
    $this->assertText(t('No content available.'), 'A node is displayed on the tracker listing pages.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.