public function FootnotesCkeditorPluginTest::testUi in Footnotes 8.2
Tests CKEditor plugin functionality for body field.
File
- tests/
src/ FunctionalJavascript/ FootnotesCkeditorPluginTest.php, line 129
Class
- FootnotesCkeditorPluginTest
- Contains Footnotes CKEditor plugin functionality tests.
Namespace
Drupal\Tests\footnotes\FunctionalJavascriptCode
public function testUi() {
$session = $this
->getSession();
$assert_session = $this
->assertSession();
$this
->drupalGet("node/add/page");
$page = $session
->getPage();
$this
->waitForEditor();
$this
->pressEditorButton('footnotes');
$this
->assertNotEmpty($assert_session
->waitForElementVisible('css', '.cke_1.cke_editor_edit-body-0-value_dialog'));
$assert_session
->elementTextContains('css', 'table.cke_dialog .cke_dialog_title', $this
->t('Footnotes Dialog'));
$assert_session
->elementTextContains('css', '.cke_dialog_page_contents table tr:first-child', $this
->t('Footnote text :'));
$assert_session
->elementTextContains('css', '.cke_dialog_page_contents table tr:last-child', $this
->t('Value :'));
$page
->find('css', 'a.cke_dialog_ui_button_cancel')
->click();
$this
->assertEmpty($assert_session
->elementExists('css', '.cke_1.cke_editor_edit-body-0-value_dialog')
->isVisible());
$texts = [
'Text one.',
'Text two.',
'Text tree',
'Text four',
'Text five',
];
foreach ($texts as $key => $value) {
$this
->pressEditorButton('footnotes');
$this
->assertNotEmpty($assert_session
->waitForElementVisible('css', '.cke_1.cke_editor_edit-body-0-value_dialog'));
$assert_session
->elementExists('css', '.cke_dialog_page_contents table tr:last-child input')
->setValue($key);
$assert_session
->elementExists('css', '.cke_dialog_page_contents table tr:first-child input')
->setValue($value);
$page
->find('css', 'a.cke_dialog_ui_button_ok')
->click();
$this
->assertEmpty($assert_session
->elementExists('css', '.cke_1.cke_editor_edit-body-0-value_dialog')
->isVisible());
}
$this
->pressEditorButton('source');
$body_value = $assert_session
->elementExists('css', '.cke .cke_contents .cke_source')
->getValue();
$body_value = str_replace([
"\r\n",
"\r",
"\n",
], "", $body_value);
$body_value = trim($body_value);
$expected_value = '<p>';
foreach ($texts as $key => $value) {
$expected_value .= '<fn value="' . $key . '">' . $value . '</fn>';
}
$expected_value .= '</p>';
$this
->assertEqual($body_value, $expected_value, $this
->t('String, formed by CKEditor, is correct.'));
}