public function EntityAddUITest::testAddPageWithoutBundleEntities in Drupal 8
Same name and namespace in other branches
- 9 core/modules/system/tests/src/Functional/Entity/EntityAddUITest.php \Drupal\Tests\system\Functional\Entity\EntityAddUITest::testAddPageWithoutBundleEntities()
Tests the add page for an entity type not using bundle entities.
File
- core/
modules/ system/ tests/ src/ Functional/ Entity/ EntityAddUITest.php, line 126
Class
- EntityAddUITest
- Tests the /add and /add/{type} controllers.
Namespace
Drupal\Tests\system\Functional\EntityCode
public function testAddPageWithoutBundleEntities() {
$admin_user = $this
->drupalCreateUser([
'administer entity_test content',
]);
$this
->drupalLogin($admin_user);
entity_test_create_bundle('test', 'Test label', 'entity_test_mul');
// Delete the default bundle, so that we can rely on our own.
entity_test_delete_bundle('entity_test_mul', 'entity_test_mul');
// One bundle exists, confirm redirection to the add-form.
$this
->drupalGet('/entity_test_mul/add');
$this
->assertUrl('/entity_test_mul/add/test');
// Two bundles exist, confirm both are shown.
entity_test_create_bundle('test2', 'Test2 label', 'entity_test_mul');
$this
->drupalGet('/entity_test_mul/add');
$this
->assertSession()
->linkExists('Test label');
$this
->assertSession()
->linkExists('Test2 label');
$this
->clickLink('Test2 label');
$this
->drupalGet('/entity_test_mul/add/test2');
$this
->drupalPostForm(NULL, [
'name[0][value]' => 'test name',
], t('Save'));
$entity = EntityTestMul::load(1);
$this
->assertEqual('test name', $entity
->label());
}