public function TinyMCEIntegrationTest::testFragmentLink in TinyMCE 1.x
Tests if the fragment link to a textarea works with TinyMCE enabled.
File
- tests/
src/ FunctionalJavascript/ TinyMCEIntegrationTest.php, line 97
Class
- TinyMCEIntegrationTest
- Tests the integration of TinyMCE.
Namespace
Drupal\Tests\tinymce\FunctionalJavascriptCode
public function testFragmentLink() {
$session = $this
->getSession();
$web_assert = $this
->assertSession();
$tinymce_id = '.tox-tinymce';
$before_url = $session
->getCurrentUrl();
$this
->drupalGet('node/add/page');
$session
->getPage();
// Add a bottom margin to the title field to be sure the body field is not
// visible.
$session
->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = window.innerHeight*2 +'px';");
$this
->assertSession()
->waitForElementVisible('css', $tinymce_id);
// Check that the TinyMCE-enabled body field is currently not visible in
// the viewport.
$web_assert
->assertNotVisibleInViewport('css', $tinymce_id, 'topLeft', 'TinyMCE-enabled body field is visible.');
// Reset the title bottom margin to make the body field visible again.
$session
->executeScript("document.getElementById('edit-title-0-value').style.marginBottom = '0px';");
// Check that the TinyMCE-enabled body field is visible in the viewport.
$web_assert
->assertVisibleInViewport('css', $tinymce_id, 'topLeft', 'TinyMCE-enabled body field is not visible.');
// Use JavaScript to go back in the history instead of
// \Behat\Mink\Session::back() because that function doesn't work after a
// hash change.
$session
->executeScript("history.back();");
$after_url = $session
->getCurrentUrl();
// Check that going back in the history worked.
self::assertEquals($before_url, $after_url, 'History back works.');
}