You are here

function ConfigEntityStatusUITest::testCRUD in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/config/src/Tests/ConfigEntityStatusUITest.php \Drupal\config\Tests\ConfigEntityStatusUITest::testCRUD()

Tests status operations.

File

core/modules/config/src/Tests/ConfigEntityStatusUITest.php, line 29
Contains \Drupal\config\Tests\ConfigEntityStatusUITest.

Class

ConfigEntityStatusUITest
Tests configuration entity status UI functionality.

Namespace

Drupal\config\Tests

Code

function testCRUD() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer site configuration',
  ]));
  $id = strtolower($this
    ->randomMachineName());
  $edit = array(
    'id' => $id,
    'label' => $this
      ->randomMachineName(),
  );
  $this
    ->drupalPostForm('admin/structure/config_test/add', $edit, 'Save');
  $entity = entity_load('config_test', $id);

  // Disable an entity.
  $disable_url = $entity
    ->urlInfo('disable');
  $this
    ->assertLinkByHref($disable_url
    ->toString());
  $this
    ->drupalGet($disable_url);
  $this
    ->assertResponse(200);
  $this
    ->assertNoLinkByHref($disable_url
    ->toString());

  // Enable an entity.
  $enable_url = $entity
    ->urlInfo('enable');
  $this
    ->assertLinkByHref($enable_url
    ->toString());
  $this
    ->drupalGet($enable_url);
  $this
    ->assertResponse(200);
  $this
    ->assertNoLinkByHref($enable_url
    ->toString());
}