public function DrupalNbspTest::testButton in CKEditor Non-breaking space Plugin ( ) 8
Same name and namespace in other branches
- 8.2 tests/src/FunctionalJavascript/DrupalNbspTest.php \Drupal\Tests\nbsp\FunctionalJavascript\DrupalNbspTest::testButton()
Tests using DurpalNbsp button to add non-breaking space into CKEditor.
File
- tests/
src/ FunctionalJavascript/ DrupalNbspTest.php, line 201
Class
- DrupalNbspTest
- Ensure the NBSP CKeditor dialog works.
Namespace
Drupal\Tests\nbsp\FunctionalJavascriptCode
public function testButton() {
$this
->drupalGet('node/add/page');
$this
->waitForEditor();
$this
->pressEditorButton('drupalnbsp');
$this
->pressEditorButton('source');
$assert_session = $this
->assertSession();
$value = $assert_session
->elementExists('css', 'textarea.cke_source')
->getValue();
$dom = Html::load($value);
$xpath = new \DOMXPath($dom);
$nbsp = $xpath
->query('//span')[0];
$expected_attributes = [
'class' => 'nbsp',
];
foreach ($expected_attributes as $name => $expected) {
$this
->assertSame($expected, $nbsp
->getAttribute($name));
}
$this
->assertEquals(" ", $nbsp->firstChild->nodeValue);
}