.../src/FunctionalJavascript/ExtlinkAdminTest.php | 25 +++++++ tests/src/FunctionalJavascript/ExtlinkTest.php | 23 +++++++ tests/src/FunctionalJavascript/ExtlinkTestBase.php | 77 ++++++++++++++++++++++ 3 files changed, 125 insertions(+) diff --git a/tests/src/FunctionalJavascript/ExtlinkAdminTest.php b/tests/src/FunctionalJavascript/ExtlinkAdminTest.php new file mode 100644 index 0000000..75556cc --- /dev/null +++ b/tests/src/FunctionalJavascript/ExtlinkAdminTest.php @@ -0,0 +1,25 @@ +drupalLogin($this->normalUser); + $this->drupalGet(self::EXTLINK_ADMIN_PATH); + $this->assertText(t('Access denied'), 'Normal users should not be able to access the External Links admin pages', 'External Links'); + + $this->drupalLogin($this->adminUser); + $this->drupalGet(self::EXTLINK_ADMIN_PATH); + $this->assertNoText(t('Access denied'), 'Admin users should be able to access the External Links admin pages', 'External Links'); + } + +} diff --git a/tests/src/FunctionalJavascript/ExtlinkTest.php b/tests/src/FunctionalJavascript/ExtlinkTest.php new file mode 100644 index 0000000..5682f3b --- /dev/null +++ b/tests/src/FunctionalJavascript/ExtlinkTest.php @@ -0,0 +1,23 @@ +drupalGet(''); + + // Test that the front page has the span. + $this->assertElementVisible('span.ext', 'There should be an External Link on the form.'); + } + +} diff --git a/tests/src/FunctionalJavascript/ExtlinkTestBase.php b/tests/src/FunctionalJavascript/ExtlinkTestBase.php new file mode 100644 index 0000000..1149965 --- /dev/null +++ b/tests/src/FunctionalJavascript/ExtlinkTestBase.php @@ -0,0 +1,77 @@ +normalUser = $this->drupalCreateUser($permissions); + + // Create an admin user. + $permissions[] = 'administer site configuration'; + $permissions[] = 'administer permissions'; + $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() { + if (!empty($this->getSession()->getPage()->find('css', 'span.ext')->getText()))) { + $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'); + } + } + +}