You are here

public function NodeTypeTest::testNodeTypeNoContentType in Zircon Profile 8

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

Tests for when there are no content types defined.

File

core/modules/node/src/Tests/NodeTypeTest.php, line 220
Contains \Drupal\node\Tests\NodeTypeTest.

Class

NodeTypeTest
Ensures that node type functions work correctly.

Namespace

Drupal\node\Tests

Code

public function testNodeTypeNoContentType() {

  /** @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info */
  $bundle_info = \Drupal::service('entity_type.bundle.info');
  $this
    ->assertEqual(2, count($bundle_info
    ->getBundleInfo('node')), 'The bundle information service has 2 bundles for the Node entity type.');
  $web_user = $this
    ->drupalCreateUser([
    'administer content types',
  ]);
  $this
    ->drupalLogin($web_user);

  // Delete 'article' bundle.
  $this
    ->drupalPostForm('admin/structure/types/manage/article/delete', [], t('Delete'));

  // Delete 'page' bundle.
  $this
    ->drupalPostForm('admin/structure/types/manage/page/delete', [], t('Delete'));

  // Navigate to content type administration screen
  $this
    ->drupalGet('admin/structure/types');
  $this
    ->assertRaw(t('No content types available. <a href=":link">Add content type</a>.', [
    ':link' => Url::fromRoute('node.type_add')
      ->toString(),
  ]), 'Empty text when there are no content types in the system is correct.');
  $bundle_info
    ->clearCachedBundles();
  $this
    ->assertEqual(0, count($bundle_info
    ->getBundleInfo('node')), 'The bundle information service has 0 bundles for the Node entity type.');
}