public function NodeCreationTest::testNodeAddWithoutContentTypes in Drupal 8
Same name and namespace in other branches
- 9 core/modules/node/tests/src/Functional/NodeCreationTest.php \Drupal\Tests\node\Functional\NodeCreationTest::testNodeAddWithoutContentTypes()
Check node/add when no node types exist.
File
- core/
modules/ node/ tests/ src/ Functional/ NodeCreationTest.php, line 263
Class
- NodeCreationTest
- Create a node and test saving it.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeAddWithoutContentTypes() {
$this
->drupalGet('node/add');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertNoLinkByHref('/admin/structure/types/add');
// Test /node/add page without content types.
foreach (\Drupal::entityTypeManager()
->getStorage('node_type')
->loadMultiple() as $entity) {
$entity
->delete();
}
$this
->drupalGet('node/add');
$this
->assertSession()
->statusCodeEquals(403);
$admin_content_types = $this
->drupalCreateUser([
'administer content types',
]);
$this
->drupalLogin($admin_content_types);
$this
->drupalGet('node/add');
$this
->assertLinkByHref('/admin/structure/types/add');
}