public function EntityEmbedDialogTest::testEntityEmbedButtonMarkup in Entity Embed 8
Same name in this branch
- 8 tests/src/Functional/EntityEmbedDialogTest.php \Drupal\Tests\entity_embed\Functional\EntityEmbedDialogTest::testEntityEmbedButtonMarkup()
- 8 tests/src/FunctionalJavascript/EntityEmbedDialogTest.php \Drupal\Tests\entity_embed\FunctionalJavascript\EntityEmbedDialogTest::testEntityEmbedButtonMarkup()
Tests the entity embed button markup.
File
- tests/
src/ Functional/ EntityEmbedDialogTest.php, line 74
Class
- EntityEmbedDialogTest
- Tests the entity_embed dialog controller and route.
Namespace
Drupal\Tests\entity_embed\FunctionalCode
public function testEntityEmbedButtonMarkup() {
// Ensure that the route is not accessible with text format without the
// button configured.
$this
->drupalGet('/entity-embed/dialog/plain_text/node');
// Verify embed dialog is not accessible with a filter that does not have
// an editor configuration.
$this
->assertSession()
->statusCodeEquals(404);
// Add an empty configuration for the plain_text editor configuration.
$editor = Editor::create([
'format' => 'plain_text',
'editor' => 'ckeditor',
]);
$editor
->save();
$this
->drupalGet('/entity-embed/dialog/plain_text/node');
// Verify embed dialog is not accessible with a filter that does not have
// the embed button assigned to it.
$this
->assertSession()
->statusCodeEquals(403);
// Ensure that the route is accessible with a valid embed button.
// 'Node' embed button is provided by default by the module and hence the
// request must be successful.
$this
->drupalGet('/entity-embed/dialog/custom_format/node');
// Verify embed dialog is accessible with correct filter format
// and embed button.
$this
->assertSession()
->statusCodeEquals(200);
// Ensure form structure of the 'select' step and submit form.
$this
->assertSession()
->fieldExists('entity_id');
// Check that 'Next' is a primary button.
$this
->assertSession()
->elementExists('xpath', '//input[contains(@class, "button--primary")]');
}