function NodeTypeTest::testNodeTypeNoContentType
Same name in other branches
- 9 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeNoContentType()
- 10 core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeNoContentType()
- 11.x core/modules/node/tests/src/Functional/NodeTypeTest.php \Drupal\Tests\node\Functional\NodeTypeTest::testNodeTypeNoContentType()
Tests for when there are no content types defined.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeTypeTest.php, line 260
Class
- NodeTypeTest
- Ensures that node type functions work correctly.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeTypeNoContentType() {
/** @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface $bundle_info */
$bundle_info = \Drupal::service('entity_type.bundle.info');
$this->assertCount(2, $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->assertCount(0, $bundle_info->getBundleInfo('node'), 'The bundle information service has 0 bundles for the Node entity type.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.