You are here

function NodeCreationTest::testNodeAddWithoutContentTypes in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/Tests/NodeCreationTest.php \Drupal\node\Tests\NodeCreationTest::testNodeAddWithoutContentTypes()

Check node/add when no node types exist.

File

core/modules/node/src/Tests/NodeCreationTest.php, line 171
Contains \Drupal\node\Tests\NodeCreationTest.

Class

NodeCreationTest
Create a node and test saving it.

Namespace

Drupal\node\Tests

Code

function testNodeAddWithoutContentTypes() {
  $this
    ->drupalGet('node/add');
  $this
    ->assertResponse(200);
  $this
    ->assertNoLinkByHref('/admin/structure/types/add');

  // Test /node/add page without content types.
  foreach (\Drupal::entityManager()
    ->getStorage('node_type')
    ->loadMultiple() as $entity) {
    $entity
      ->delete();
  }
  $this
    ->drupalGet('node/add');
  $this
    ->assertResponse(403);
  $admin_content_types = $this
    ->drupalCreateUser(array(
    'administer content types',
  ));
  $this
    ->drupalLogin($admin_content_types);
  $this
    ->drupalGet('node/add');
  $this
    ->assertLinkByHref('/admin/structure/types/add');
}