src/Tests/ExtlinkTest.php | 20 ------
src/Tests/ExtlinkTestBase.php | 24 -------
tests/src/FunctionalJavascript/ExtlinkTest.php | 44 +++++++++++++
tests/src/FunctionalJavascript/ExtlinkTestBase.php | 74 ++++++++++++++++++++++
4 files changed, 118 insertions(+), 44 deletions(-)
diff --git a/src/Tests/ExtlinkTest.php b/src/Tests/ExtlinkTest.php
deleted file mode 100644
index d69f30b..0000000
--- a/src/Tests/ExtlinkTest.php
+++ /dev/null
@@ -1,20 +0,0 @@
-drupalGet('');
- }
-
-}
diff --git a/src/Tests/ExtlinkTestBase.php b/src/Tests/ExtlinkTestBase.php
index a2ea7ab..48fcbc3 100644
--- a/src/Tests/ExtlinkTestBase.php
+++ b/src/Tests/ExtlinkTestBase.php
@@ -48,28 +48,4 @@ abstract class ExtlinkTestBase extends WebTestBase {
$this->adminUser = $this->drupalCreateUser($permissions);
}
- /**
- * Get the nodes value.
- */
- protected function getNodeFormValues() {
- $edit = [
- 'title' => 'node_title ' . $this->randomName(32),
- 'body[' . LANGUAGE_NONE . '][0][value]' => 'node_body ' . $this->randomName(256) . ' Google!',
- ];
- return $edit;
- }
-
- /**
- * Test if External Link is present.
- */
- protected function assertExternalLinkPresence() {
- $elements = $this->xpath('//span[@class="ext"]');
- if (count($elements) > 0) {
- $this->pass('There should be an External Link on the form.', 'External Links');
- }
- else {
- $this->fail('There should be an External Link on the form.', 'External Links');
- }
- }
-
}
diff --git a/tests/src/FunctionalJavascript/ExtlinkTest.php b/tests/src/FunctionalJavascript/ExtlinkTest.php
new file mode 100644
index 0000000..816ee80
--- /dev/null
+++ b/tests/src/FunctionalJavascript/ExtlinkTest.php
@@ -0,0 +1,44 @@
+drupalLogin($this->adminUser);
+
+ // Create a node with an external link.
+ $settings = [
+ 'type' => 'page',
+ 'title' => 'test page',
+ 'body' => [
+ [
+ 'value' => 'Google!',
+ 'format' => $this->emptyFormat->id(),
+ ],
+ ],
+ ];
+ $node = $this->drupalCreateNode($settings);
+
+ // Get the page.
+ $this->drupalGet($node->toUrl());
+ $page = $this->getSession()->getPage();
+ $this->createScreenshot(\Drupal::root() . '/sites/default/files/simpletest/screen.png');
+ $this->assertSession()->statusCodeEquals(200);
+ $this->assertTrue($page->hasLink('Google!'));
+
+ // Test that the page has the external link span.
+ $externalLink = $page->find('css', 'span.ext');
+ $this->assertTrue($externalLink->isVisible(), 'External Link Exists.');
+ }
+
+}
diff --git a/tests/src/FunctionalJavascript/ExtlinkTestBase.php b/tests/src/FunctionalJavascript/ExtlinkTestBase.php
new file mode 100644
index 0000000..db78fe3
--- /dev/null
+++ b/tests/src/FunctionalJavascript/ExtlinkTestBase.php
@@ -0,0 +1,74 @@
+normalUser = $this->drupalCreateUser($permissions);
+
+ // Create an admin user.
+ $permissions[] = 'administer site configuration';
+ $permissions[] = 'administer permissions';
+ $this->adminUser = $this->drupalCreateUser($permissions);
+ $this->adminUser->roles[] = 'administrator';
+ $this->adminUser->save();
+
+ // Create page content type that we will use for testing.
+ $this->drupalCreateContentType(['type' => 'page']);
+
+ // Add a text format with minimum data only.
+ $this->emptyFormat = FilterFormat::create([
+ 'format' => 'empty_format',
+ 'name' => 'Empty format',
+ ]);
+ $this->emptyFormat->save();
+ }
+
+}