summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--link.info4
-rw-r--r--tests/link.attribute.test266
-rw-r--r--tests/link.crud.test26
-rw-r--r--tests/link.crud_browser.test48
-rw-r--r--tests/link.test (renamed from tests/link.base-test.inc)10
-rw-r--r--tests/link.token.test107
-rw-r--r--tests/link.validate.test175
7 files changed, 312 insertions, 324 deletions
diff --git a/link.info b/link.info
index 0869698..db082ef 100644
--- a/link.info
+++ b/link.info
@@ -6,9 +6,11 @@ package = Fields
files[] = link.module
files[] = link.install
; Tests
-files[] = tests/link.crud.test
+files[] = tests/link.test
files[] = tests/link.attribute.test
+files[] = tests/link.crud.test
files[] = tests/link.crud_browser.test
+files[] = tests/link.token.test
files[] = tests/link.validate.test
; Views Handlers
diff --git a/tests/link.attribute.test b/tests/link.attribute.test
index 11d3fe1..398713a 100644
--- a/tests/link.attribute.test
+++ b/tests/link.attribute.test
@@ -20,11 +20,11 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'access administration pages',
);
- function getInfo() {
+ public static function getInfo() {
return array(
- 'name' => t('Link Attribute Tests'),
- 'description' => t('Tests the field attributes, making sure they appear in various displayed situations.'),
- 'group' => t('Link'),
+ 'name' => 'Link Attribute Tests',
+ 'description' => 'Tests the field attributes, making sure they appear in various displayed situations.',
+ 'group' => 'Link',
);
}
@@ -61,7 +61,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
function testBasic() {
/*$this->acquireContentTypes(1);
variable_set('node_options_'. $this->content_types[0]->name, array('status', 'promote'));*/
-
+
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
$title = $this->randomName(20);
@@ -70,14 +70,14 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Create the content type.
$this->clickLink(t('Add content type'));
-
+
$edit = array (
'name' => $content_type_friendly,
'type' => $content_type_machine,
);
$this->drupalPost(NULL, $edit, t('Save and add fields'));
$this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
@@ -90,21 +90,21 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
// We'll go with the default settings for this run-through.
$this->drupalPost(NULL, array(), t('Save field settings'));
-
+
// Using all the default settings, so press the button.
$this->drupalPost(NULL, array(), t('Save settings'));
$this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
-
+
// Somehow clicking "save" isn't enough, and we have to do a
// node_types_rebuild().
node_types_rebuild();
menu_rebuild();
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
-
+
$permission = 'create ' . $content_type_machine . ' content';
$permission_edit = 'edit ' . $content_type_machine . ' content';
// Reset the permissions cache.
@@ -115,17 +115,17 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$permissions = array_merge($this->permissions, array($permission));
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
-
+
// Go to page.
$this->drupalGet('node/add/'. $content_type_machine);
-
+
// Add a node.
$edit = array(
'title' => $title,
'field_'. $single_field_name_machine. '[und][0][title]' => 'Link',
'field_'. $single_field_name_machine. '[und][0][url]' => 'http://www.drupal.org/',
);
-
+
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
@@ -151,17 +151,17 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$node->{$single_field_name}['und'][0] = $this->createLink('http://www.example.com', 'Test Link');
node_save($node);
$this->assert('debug', print_r($node, TRUE), 'Debug');*/
-
+
//$this->drupalGet('node/'. $test_nid .'/edit');
$this->drupalGet('node/add/'. $content_type_machine);
-
+
// lets add a node:
$edit = array(
'title' => $title,
'field_' . $single_field_name_machine . '[und][0][url]' => 'http://www.example.com/',
'field_' . $single_field_name_machine . '[und][0][title]' => 'Display',
);
-
+
// Now we can fill in the second item in the multivalue field and save.
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $title)));
@@ -170,13 +170,13 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
//$this->assertText('http://www.example.com/');
$this->assertLinkByHref('http://www.example.com');
}
-
+
private function createNodeType($content_type_machine, $content_type_friendly) {
$this->drupalGet('admin/structure/types');
// Create the content type.
$this->clickLink(t('Add content type'));
-
+
$edit = array (
'name' => $content_type_friendly,
'type' => $content_type_machine,
@@ -184,7 +184,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalPost(NULL, $edit, t('Save and add fields'));
$this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
}
-
+
private function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) {
$edit = array (
'fields[_add_new_field][label]' => $single_field_name_friendly,
@@ -193,14 +193,14 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[_add_new_field][widget_type]' => 'link_field',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
// We'll go with the default settings for this run-through.
$this->drupalPost(NULL, array(), t('Save field settings'));
-
+
// Using all the default settings, so press the button.
$this->drupalPost(NULL, array(), t('Save settings'));
$this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
-
+
// Somehow clicking "save" isn't enough, and we have to do a
// node_types_rebuild().
node_types_rebuild();
@@ -208,7 +208,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
}
-
+
function createNodeTypeUser($content_type_machine) {
$permission = 'create ' . $content_type_machine . ' content';
$permission_edit = 'edit ' . $content_type_machine . ' content';
@@ -221,11 +221,11 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account);
}
-
+
function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') {
// Go to page.
$this->drupalGet('node/add/'. $content_type_machine);
-
+
if (!$node_title) {
$node_title = $this->randomName(20);
}
@@ -238,25 +238,25 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
if ($title) {
$edit['field_' . $single_field_name_machine . '[und][0][title]'] = $title;
}
-
+
// Now we can fill in the second item in the multivalue field and save.
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('@content_type_friendly @title has been created', array('@content_type_friendly' => $content_type_friendly, '@title' => $node_title)));
-
+
}
-
+
function testFormatterPlain() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -264,30 +264,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_url);
$this->assertNoText($link_text);
$this->assertNoLinkByHref($link_url);
}
-
+
function testFormatterPlainWithQuerystring() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -295,30 +295,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/?q=test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_url);
$this->assertNoText($link_text);
$this->assertNoLinkByHref($link_url);
}
-
+
function testFormatterPlainWithFragment() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -326,30 +326,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/#test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_url);
$this->assertNoText($link_text);
$this->assertNoLinkByHref($link_url);
}
-
+
function testFormatterURL() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -357,29 +357,29 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterURLWithQuerystring() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -387,29 +387,29 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/?q=test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterURLWithAnchor() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -417,29 +417,29 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/#test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterShort() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -447,30 +447,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText('Link');
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterShortWithQuerystring() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -478,30 +478,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/?q=test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText('Link');
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterShortWithFragment() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -509,30 +509,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/#test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText('Link');
$this->assertNoText($link_text);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterLabel() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -540,30 +540,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertText($single_field_name_friendly);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterLabelWithQuerystring() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -571,30 +571,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/?q=test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertText($single_field_name_friendly);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterLabelWithFragment() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -602,30 +602,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = 'Display';
$link_url = 'http://www.example.com/#test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertNoText($link_text);
$this->assertText($single_field_name_friendly);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterSeparate() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -633,30 +633,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = $this->randomName(20);
$link_url = 'http://www.example.com/';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_text);
$this->assertLink($link_url);
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterSeparateWithQuerystring() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -664,30 +664,30 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = $this->randomName(20);
$link_url = 'http://www.example.com/?q=test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_text);
$this->assertLink('http://www.example.com/');
$this->assertLinkByHref($link_url);
}
-
+
function testFormatterSeparateWithFragment() {
$content_type_friendly = $this->randomName(20);
$content_type_machine = strtolower($this->randomName(10));
-
+
$this->createNodeType($content_type_machine, $content_type_friendly);
-
+
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
$single_field_name_machine = strtolower($this->randomName(10));
//$single_field_name = 'field_'. $single_field_name_machine;
$this->createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine);
-
+
// Okay, now we want to make sure this display is changed:
$this->drupalGet('admin/structure/types/manage/'. $content_type_machine .'/display');
$edit = array(
@@ -695,13 +695,13 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
$this->createNodeTypeUser($content_type_machine);
-
+
$link_text = $this->randomName(20);
$link_url = 'http://www.example.com/#test';
$this->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
-
+
$this->assertText($link_text);
$this->assertLink('http://www.example.com/');
$this->assertLinkByHref($link_url);
diff --git a/tests/link.crud.test b/tests/link.crud.test
index 9396da1..cdd7fc5 100644
--- a/tests/link.crud.test
+++ b/tests/link.crud.test
@@ -6,20 +6,20 @@
*/
class LinkContentCrudTest extends DrupalWebTestCase {
-
- function getInfo() {
+
+ public static function getInfo() {
return array(
- 'name' => t('Link CRUD - Basic API tests'),
- 'description' => t('Tests the field CRUD (create, read, update, delete) API.'),
- 'group' => t('Link'),
+ 'name' => 'Link CRUD - Basic API tests',
+ 'description' => 'Tests the field CRUD (create, read, update, delete) API.',
+ 'group' => 'Link',
);
}
-
+
function setUp() {
parent::setUp('field_ui', 'link'); // was views?
//$this->loginWithPermissions();
}
-
+
/**
* All we're doing here is creating a content type, creating a simple link field
* on that content type.
@@ -38,14 +38,14 @@ class LinkContentCrudTest extends DrupalWebTestCase {
// Create the content type.
$this->clickLink(t('Add content type'));
-
+
$edit = array (
'name' => $content_type_friendly,
'type' => $content_type_machine,
);
$this->drupalPost(NULL, $edit, t('Save and add fields'));
$this->assertText(t('The content type @name has been added.', array('@name' => $content_type_friendly)));
-
+
//$field = $this->createField(array('type' => 'link', 'widget_type' => 'link'), 0);
// Now add a singleton field.
$single_field_name_friendly = $this->randomName(20);
@@ -58,21 +58,21 @@ class LinkContentCrudTest extends DrupalWebTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
-
+
// We'll go with the default settings for this run-through.
$this->drupalPost(NULL, array(), t('Save field settings'));
-
+
// Using all the default settings, so press the button.
$this->drupalPost(NULL, array(), t('Save settings'));
$this->assertText(t('Saved @name configuration.', array('@name' => $single_field_name_friendly)));
-
+
// Somehow clicking "save" isn't enough, and we have to do a
// node_types_rebuild().
node_types_rebuild();
menu_rebuild();
$type_exists = db_query('SELECT 1 FROM {node_type} WHERE type = :type', array(':type' => $content_type_machine))->fetchField();
$this->assertTrue($type_exists, 'The new content type has been created in the database.');
-
+
/*$table_schema = drupal_get_schema();
$this->assertEqual(1, 1, print_r(array_keys($table_schema), TRUE));
// Check the schema - the values should be in the per-type table.
diff --git a/tests/link.crud_browser.test b/tests/link.crud_browser.test
index 8cb2055..7b01da0 100644
--- a/tests/link.crud_browser.test
+++ b/tests/link.crud_browser.test
@@ -12,33 +12,27 @@ class LinkUITest extends DrupalWebTestcase {
/**
* Link supposed to be good
- */
+ */
const LINK_INPUT_TYPE_GOOD = 0;
/**
* Link supposed to have a bad title
- */
+ */
const LINK_INPUT_TYPE_BAD_TITLE = 1;
/**
* Link supposed to have a bad URL
- */
+ */
const LINK_INPUT_TYPE_BAD_URL = 2;
- /**
- * Implementation of getInfo().
- */
- function getInfo() {
+ public static function getInfo() {
return array(
- 'name' => t('Link CRUD - browser test'),
- 'description' => t('Tests the field CRUD (create, read, update, delete) API 2.'),
- 'group' => t('Link'),
+ 'name' => 'Link CRUD - browser test',
+ 'description' => 'Tests the field CRUD (create, read, update, delete) API 2.',
+ 'group' => 'Link',
);
}
- /**
- * Implementation of setUp().
- */
function setUp() {
parent::setUp('field_ui', 'link');
}
@@ -72,7 +66,7 @@ class LinkUITest extends DrupalWebTestcase {
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
node_types_rebuild();
menu_rebuild();
-
+
$permission = 'create page content';
$this->checkPermissions(array($permission), TRUE);
@@ -129,7 +123,7 @@ class LinkUITest extends DrupalWebTestcase {
);
$test_case['expected_href'] = 'http://'. $test_case['href'];
$input_test_cases[] = $test_case;
-
+
foreach ($input_test_cases as $input) {
$this->drupalLogin($account);
$this->drupalGet('node/add/page');
@@ -153,7 +147,7 @@ class LinkUITest extends DrupalWebTestcase {
// change to anonym user
$this->drupalLogout();
-
+
$this->drupalGet($url);
//debug($this);
// If simpletest starts using something to override the error system, this will flag
@@ -172,7 +166,7 @@ class LinkUITest extends DrupalWebTestcase {
}
//libxml_use_internal_errors(FALSE);
}
-
+
/**
* Creates a link field for the "page" type and creates a page with a link.
* Just like the above test, only here we're turning off the validation on the field.
@@ -199,7 +193,7 @@ class LinkUITest extends DrupalWebTestcase {
_content_type_info(TRUE);
$fields = content_fields();
$this->assertTRUE(0 === $fields['field_'. $name]['validate_url'], 'Make sure validation is off.');
-
+
// create page form
$this->drupalGet('node/add/page');
$field_name = 'field_' . $name;
@@ -267,7 +261,7 @@ class LinkUITest extends DrupalWebTestcase {
// change to anonym user
$this->drupalLogout();
-
+
$this->drupalGet($url);
//debug($this);
// If simpletest starts using something to override the error system, this will flag
@@ -281,7 +275,7 @@ class LinkUITest extends DrupalWebTestcase {
}
//libxml_use_internal_errors(FALSE);
}*/
-
+
/**
* Testing that if you use <strong> in a static title for your link, that the
* title actually displays <strong>.
@@ -311,26 +305,26 @@ class LinkUITest extends DrupalWebTestcase {
// create page form
$this->drupalGet('node/add/page');
$this->assertField($field_name . '[und][0][url]', 'URL found');
-
+
$input = array(
'href' => 'http://example.com/' . $this->randomName()
);
-
+
$edit = array(
'title' => $name,
$field_name . '[und][0][url]' => $input['href'],
);
- $this->drupalPost(NULL, $edit, t('Save'));
-
+ $this->drupalPost(NULL, $edit, t('Save'));
+
$url = $this->getUrl();
// change to anonymous user
- $this->drupalLogout();
+ $this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l('<strong>'. $name .'</strong>', $input['href'], array('html' => TRUE)));
}
-
+
/**
* If we're creating a new field and just hit 'save' on the default options, we want to make
* sure they are set to the expected results.
@@ -373,7 +367,7 @@ class LinkUITest extends DrupalWebTestcase {
$this->assertFalse($instance['settings']['attributes']['rel'], 'Rel should be blank by default.');
$this->assertFalse($instance['settings']['attributes']['class'], 'By default, no class should be set.');
$this->assertFalse($instance['settings']['title_value'], 'By default, no title should be set.');
-
+
//$this->fail('<pre>'. print_r($fields['field_'. $name], TRUE) .'</pre>');
}
}
diff --git a/tests/link.base-test.inc b/tests/link.test
index a2921c7..dfb4dda 100644
--- a/tests/link.base-test.inc
+++ b/tests/link.test
@@ -16,9 +16,9 @@ class LinkBaseTestClass extends DrupalWebTestCase {
'access administration pages',
'create page content',
);
-
+
public $account;
-
+
function setUp($modules = array()) {
if ($modules) {
parent::setUp($modules);
@@ -29,7 +29,7 @@ class LinkBaseTestClass extends DrupalWebTestCase {
$this->account = $this->drupalCreateUser($this->permissions);
$this->drupalLogin($this->account);
}
-
+
function createLinkField($node_type = 'page',
$settings = array()) {
$name = strtolower($this->randomName());
@@ -48,7 +48,7 @@ class LinkBaseTestClass extends DrupalWebTestCase {
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
node_types_rebuild();
menu_rebuild();
-
+
return $field_name;
}
-} \ No newline at end of file
+}
diff --git a/tests/link.token.test b/tests/link.token.test
index b8df05f..d23f46a 100644
--- a/tests/link.token.test
+++ b/tests/link.token.test
@@ -5,30 +5,25 @@
* Contains simpletests making sure token integration works.
*/
-// Let's include the parent class.
-module_load_include('inc', 'link', 'tests/link.base-test');
-
/**
* Testing that tokens can be used in link titles
*/
class LinkTokenTest extends LinkBaseTestClass {
-
- /**
- * Implementation of getInfo().
- */
- function getInfo() {
+
+ public static function getInfo() {
return array(
- 'name' => t('Link tokens - browser test'),
- 'description' => t('Tests including tokens in link titles, making sure they appear in node views. <strong>Requires <a href="@token_link">Token module</a>.</strong>'),
- 'group' => t('Link'),
+ 'name' => 'Link tokens - browser test',
+ 'description' => 'Tests including tokens in link titles, making sure they appear in node views.',
+ 'group' => 'Link',
+ 'dependencies' => array('token'),
);
}
- /**
- * Implementation of setUp().
- */
- function setUp() {
- parent::setUp(array('field_ui', 'link', 'token'));
+ function setUp($modules = array()) {
+ $modules[] = 'field_ui';
+ $modules[] = 'link';
+ $modules[] = 'token';
+ parent::setUp($modules);
}
/**
@@ -56,7 +51,7 @@ class LinkTokenTest extends LinkBaseTestClass {
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName(),
);
-
+
//$this->drupalLogin($account);
$this->drupalGet('node/add/page');
@@ -65,17 +60,17 @@ class LinkTokenTest extends LinkBaseTestClass {
$field_name . '[und][0][title]' => $input['label'] . " [node:content-type:machine-name]",
$field_name . '[und][0][url]' => $input['href'],
);
- $this->drupalPost(NULL, $edit, t('Save'));
+ $this->drupalPost(NULL, $edit, t('Save'));
$url = $this->getUrl();
// change to anonymous user
- $this->drupalLogout();
+ $this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($input['label'] . ' page', $input['href']));
}
-
-
+
+
/**
* Creates a link field with a static title and an admin-entered token.
* Creates a node with a link and checks the title value.
@@ -104,17 +99,17 @@ class LinkTokenTest extends LinkBaseTestClass {
'title' => $name,
$field_name . '[und][0][url]' => $input['href'],
);
- $this->drupalPost(NULL, $edit, t('Save'));
-
+ $this->drupalPost(NULL, $edit, t('Save'));
+
$url = $this->getUrl();
// change to anonymous user
- $this->drupalLogout();
+ $this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($name . ' page', $input['href']));
}
-
+
/**
* Creates a link field with a static title and an admin-entered token.
* Creates a node with a link and checks the title value.
@@ -147,17 +142,17 @@ class LinkTokenTest extends LinkBaseTestClass {
'title' => $name,
$field_name . '[und][0][url]' => $input['href'],
);
- $this->drupalPost(NULL, $edit, t('Save'));
-
+ $this->drupalPost(NULL, $edit, t('Save'));
+
$url = $this->getUrl();
// change to anonymous user
- $this->drupalLogout();
+ $this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($name .' '. $name, $input['href']));
}
-
+
// This test doesn't seem to actually work, due to lack of 'title' in url.
function _test_Link_With_Title_Attribute_token_url_form() {
/* $this->loginWithPermissions($this->permissions);
@@ -173,13 +168,13 @@ class LinkTokenTest extends LinkBaseTestClass {
'title' => '',
),
);
-
+
$field = $this->createField($field_settings, 0);
//$this->fail('<pre>'. print_r($field, TRUE) .'</pre>');
$field_name = $field['field_name'];
$field_db_info = content_database_info($field);
$url_type = str_replace('_', '-', $this->content_types[0]->type);
-
+
$edit = array('attributes[title]' => '['. $field_name .'-url]',
'enable_tokens' => TRUE);
@@ -190,31 +185,31 @@ class LinkTokenTest extends LinkBaseTestClass {
$settings = array(
'instance[settings][attributes][rel]' => 'nofollow',
);
-
+
$field_name = $this->createLinkField('page', $settings);
-
+
// So, having saved this field_name, let's see if it works...
//$this->acquireNodes(1);
-
+
//$node = node_load($this->nodes[0]->nid);
-
+
//$this->drupalGet('node/'. $this->nodes[0]->nid);
-
+
$edit = array();
$test_link_url = 'http://www.example.com/test';
$edit[$field_name .'[und][0][url]'] = $test_link_url;
$title = 'title_'. $this->randomName(20);
$edit[$field_name .'[und][0][title]'] = $title;
$edit['title'] = $name;
-
+
$this->drupalGet('node/add/page');
$this->drupalPost(NULL, $edit, t('Save'));
-
+
// Make sure we get a new version!
//$node = node_load($this->nodes[0]->nid, NULL, TRUE);
$this->assertText(t('Basic page @title has been updated.',
array('@title' => $name)));
-
+
//$this->drupalGet('node/'. $node->nid);
$this->assertText($title, 'Make sure the link title/text shows');
$this->assertRaw(' title="'. $test_link_url .'"', "Do we show the link url as the title attribute?");
@@ -222,7 +217,7 @@ class LinkTokenTest extends LinkBaseTestClass {
$this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.'));
//$this->fail($this->content);
}
-
+
/**
* If the title of the link is set to the title attribute, then the title
* attribute isn't supposed to show.
@@ -241,39 +236,39 @@ class LinkTokenTest extends LinkBaseTestClass {
'title' => '',
),
);
-
+
$field = $this->createField($field_settings, 0);
$field_name = $field['field_name'];
$field_db_info = content_database_info($field);
$url_type = str_replace('_', '-', $this->content_types[0]->type);
-
+
$edit = array('attributes[title]' => '['. $field_name .'-title]',
'enable_tokens' => TRUE);
$this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
$edit, t('Save field settings'));
$this->assertText(t('Saved field @field_name', array('@field_name' => $field['field_name'])));
-
+
// So, having saved this field_name, let's see if it works...
$this->acquireNodes(1);
-
+
$node = node_load($this->nodes[0]->nid);
-
+
$this->drupalGet('node/'. $this->nodes[0]->nid);
-
+
$edit = array();
$edit[$field['field_name'] .'[0][url]'] = 'http://www.example.com/test';
$title = 'title_'. $this->randomName(20);
$edit[$field['field_name'] .'[0][title]'] = $title;
-
+
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
-
+
// Make sure we get a new version!
$node = node_load($this->nodes[0]->nid, NULL, TRUE);
$this->assertText(t('@type @title has been updated.',
array('@title' => $node->title,
'@type' => $this->content_types[0]->name)));
-
+
$this->drupalGet('node/'. $node->nid);
$this->assertText($title, 'Make sure the link title/text shows');
$this->assertNoRaw(' title="'. $title .'"', "We should not show the link title as the title attribute?");
@@ -314,7 +309,7 @@ class LinkTokenTest extends LinkBaseTestClass {
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName(),
);
-
+
$this->drupalLogin($account);
$this->drupalGet('node/add/page');
@@ -323,17 +318,17 @@ class LinkTokenTest extends LinkBaseTestClass {
$field_name . '[0][title]' => $input['label'],
$field_name . '[0][url]' => $input['href'] . "/[type]",
);
- $this->drupalPost(NULL, $edit, t('Save'));
+ $this->drupalPost(NULL, $edit, t('Save'));
$url = $this->getUrl();
// change to anonymous user
- $this->drupalLogout();
+ $this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($input['label'], $input['href'] .'/page'));
//$this->fail($this->content);
}
-
+
/**
* Trying to set the url to contain a token.
*/
@@ -367,7 +362,7 @@ class LinkTokenTest extends LinkBaseTestClass {
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName(),
);
-
+
$this->drupalLogin($account);
$this->drupalGet('node/add/page');
@@ -376,11 +371,11 @@ class LinkTokenTest extends LinkBaseTestClass {
$field_name . '[0][title]' => $input['label'],
$field_name . '[0][url]' => $input['href'] . "/[author-uid]",
);
- $this->drupalPost(NULL, $edit, t('Save'));
+ $this->drupalPost(NULL, $edit, t('Save'));
$url = $this->getUrl();
// change to anonymous user
- $this->drupalLogout();
+ $this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($input['label'], $input['href'] .'/'. $account->uid));
diff --git a/tests/link.validate.test b/tests/link.validate.test
index 7e6e4bd..affa7e9 100644
--- a/tests/link.validate.test
+++ b/tests/link.validate.test
@@ -5,15 +5,12 @@
* Tests that exercise the validation functions in the link module.
*/
-// Let's include the parent class.
-module_load_include('inc', 'link', 'tests/link.base-test');
-
class LinkValidateTestCase extends LinkBaseTestClass {
-
- function setUp() {
- parent::setUp();
+
+ function setUp($modules = array()) {
+ parent::setUp($modules);
}
-
+
function createLink($url, $title, $attributes = array()) {
return array(
'url' => $url,
@@ -21,14 +18,14 @@ class LinkValidateTestCase extends LinkBaseTestClass {
'attributes' => $attributes,
);
}
-
+
/**
* Takes a url, and sees if it can validate that the url is valid.
*/
public function link_test_validate_url($url) {
-
+
$field_name = $this->createLinkField();
-
+
$permission = 'create page content';
$this->checkPermissions(array($permission), TRUE);
@@ -42,29 +39,29 @@ class LinkValidateTestCase extends LinkBaseTestClass {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t(' has been created.'), 'Node created');
-
+
$nid = 1; //$matches[1];
-
+
$node = node_load($nid);
-
+
$this->assertEqual($url, $node->{$field_name}['und'][0]['url']);
}
}
class LinkValidateTest extends LinkValidateTestCase {
-
- function getInfo() {
+
+ public static function getInfo() {
return array(
- 'name' => t('Link Validation Tests'),
- 'description' => t('Tests the field validation.'),
- 'group' => t('Link'),
+ 'name' => 'Link Validation Tests',
+ 'description' => 'Tests the field validation.',
+ 'group' => 'Link',
);
}
-
+
function test_link_validate_basic_url() {
$this->link_test_validate_url('http://www.example.com');
}
-
+
/**
* Test if we're stopped from posting a bad url on default validation.
*/
@@ -93,23 +90,23 @@ class LinkValidateTest extends LinkValidateTestCase {
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
node_types_rebuild();
menu_rebuild();
-
+
// create page form
$this->drupalGet('node/add/page');
$field_name = 'field_' . $name;
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
-
-
+
+
$edit = array(
'title' => 'Simple Title',
$field_name .'[und][0][url]' => 'edik:naw',
);
-
+
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('Not a valid URL.'));
}
-
+
/**
* Test if we're stopped from posting a bad url with validation on.
*/
@@ -138,24 +135,24 @@ class LinkValidateTest extends LinkValidateTestCase {
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
node_types_rebuild();
menu_rebuild();
-
+
// create page form
$this->drupalGet('node/add/page');
$field_name = 'field_' . $name;
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
-
-
+
+
$edit = array(
'title' => 'Simple Title',
$field_name .'[und][0][url]' => 'edik:naw',
);
-
+
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('Not a valid URL.'));
-
+
}
-
+
/**
* Test if we can post a bad url if the validation is expressly turned off.
*/
@@ -179,7 +176,7 @@ class LinkValidateTest extends LinkValidateTestCase {
$this->drupalPost('admin/structure/types/manage/page/fields', $edit, t('Save'));
$this->drupalPost(NULL, array(), t('Save field settings'));
$this->drupalPost(NULL, array('instance[settings][validate_url]' => FALSE), t('Save settings'));
-
+
/*$instance_details = db_query("SELECT * FROM {field_config_instance} WHERE field_name = :field_name AND bundle = 'page'", array(':field_name' => 'field_'. $name))->fetchObject();
$this->fail('<pre>'. print_r($instance_details, TRUE) .'</pre>');
$this->fail('<pre>'. print_r(unserialize($instance_details->data), TRUE) .'</pre>');*/
@@ -188,24 +185,24 @@ class LinkValidateTest extends LinkValidateTestCase {
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
node_types_rebuild();
menu_rebuild();
-
+
// create page form
$this->drupalGet('node/add/page');
$field_name = 'field_' . $name;
$this->assertField('edit-field-'. $name .'-und-0-title', 'Title found');
$this->assertField('edit-field-'. $name .'-und-0-url', 'URL found');
-
-
+
+
$edit = array(
'title' => 'Simple Title',
$field_name .'[und][0][url]' => 'edik:naw',
);
-
+
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertNoText(t('Not a valid URL.'));
-
+
}
-
+
/**
* Test if a bad url can sneak through un-filtered if we play with the validation...
*/
@@ -232,54 +229,54 @@ class LinkValidateTest extends LinkValidateTestCase {
$field_db_info = content_database_info($field);
$this->acquireNodes(2);
-
+
$node = node_load($this->nodes[0]->nid);
-
+
$this->drupalGet('node/'. $this->nodes[0]->nid);
-
+
$edit = array();
$title = $this->randomName();
$url = 'javascript:alert("http://example.com/' . $this->randomName() . '")';
$edit[$field['field_name'] .'[0][url]'] = $url;
$edit[$field['field_name'] .'[0][title]'] = $title;
-
+
$this->drupalPost('node/'. $this->nodes[0]->nid .'/edit', $edit, t('Save'));
//$this->pass($this->content);
$this->assertNoText(t('Not a valid URL.'));
-
+
// Make sure we get a new version!
$node = node_load($this->nodes[0]->nid, NULL, TRUE);
$this->assertEqual($url, $node->{$field['field_name']}[0]['url']);
-
+
$this->drupalGet('node/'. $node->nid);
$this->assertNoRaw($url, 'Make sure Javascript does not display.');
-
+
// Turn the array validation back _on_.
$edit = array('validate_url' => TRUE);
$node_type_link = str_replace('_', '-', $node->type);
//$this->drupalGet('admin/content/node-type/'. $node_type_link .'/fields'); ///'. $field['field_name']);
//$this->fail($this->content);
$this->drupalPost('admin/content/node-type/'. $node_type_link .'/fields/'. $field['field_name'], $edit, t('Save field settings'));
-
+
$this->drupalGet('node/'. $node->nid);
// This actually works because the display_url goes through the core
// url() function. But we should have a test that makes sure it continues
// to work.
$this->assertNoRaw($url, 'Make sure Javascript does not display.');
//$this->fail($this->content);
-
+
}
-
+
// Validate that '<front>' is a valid url.
function test_link_front_url() {
$this->link_test_validate_url('<front>');
}
-
+
// Validate that an internal url would be accepted.
function test_link_internal_url() {
$this->link_test_validate_url('node/32');
}
-
+
// Validate a simple mailto.
function test_link_mailto() {
$this->link_test_validate_url('mailto:jcfiala@gmail.com');
@@ -288,27 +285,27 @@ class LinkValidateTest extends LinkValidateTestCase {
function test_link_external_https() {
$this->link_test_validate_url('https://www.example.com/');
}
-
+
function test_link_ftp() {
$this->link_test_validate_url('ftp://www.example.com/');
}
}
class LinkValidateTestNews extends LinkValidateTestCase {
-
- function getInfo() {
+
+ public static function getInfo() {
return array(
- 'name' => t('Link News Validation Tests'),
- 'description' => t('Tests the field validation for usenet urls.'),
- 'group' => t('Link'),
+ 'name' => 'Link News Validation Tests',
+ 'description' => 'Tests the field validation for usenet urls.',
+ 'group' => 'Link',
);
}
-
+
// Validate a news link to a message group
function test_link_news() {
$this->link_test_validate_url('news:comp.infosystems.www.misc');
}
-
+
// Validate a news link to a message id. Said ID copied off of google groups.
function test_link_news_message() {
$this->link_test_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
@@ -316,35 +313,35 @@ class LinkValidateTestNews extends LinkValidateTestCase {
}
class LinkValidateSpecificURL extends LinkValidateTestCase {
- function getInfo() {
+ public static function getInfo() {
return array(
- 'name' => t('Link Specific URL Validation Tests'),
- 'description' => t('Tests field validation with unusual urls'),
- 'group' => t('Link'),
+ 'name' => 'Link Specific URL Validation Tests',
+ 'description' => 'Tests field validation with unusual urls',
+ 'group' => 'Link',
);
}
-
+
// Lets throw in a lot of umlouts for testing!
function test_umlout_url() {
$this->link_test_validate_url('http://üÜü.exämple.com/nöde');
}
-
+
function test_umlout_mailto() {
$this->link_test_validate_url('mailto:Üser@exÅmple.com');
}
-
+
function test_german_b_url() {
$this->link_test_validate_url('http://www.test.com/ßstuff');
}
-
+
function test_special_n_url() {
$this->link_test_validate_url('http://www.testÑñ.com/');
}
-
+
function test_curly_brackets_in_query() {
$this->link_test_validate_url('http://www.healthyteennetwork.org/index.asp?Type=B_PR&SEC={2AE1D600-4FC6-4B4D-8822-F1D5F072ED7B}&DE={235FD1E7-208D-4363-9854-4E6775EB8A4C}');
}
-
+
/**
* Here, we're testing that a very long url is stored properly in the db.
*
@@ -354,7 +351,7 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
$long_url = 'http://th.wikipedia.org/wiki/%E0%B9%82%E0%B8%A3%E0%B8%87%E0%B9%80%E0%B8%A3%E0%B8%B5%E0%B8%A2%E0%B8%99%E0%B9%80%E0%B8%9A%E0%B8%8D%E0%B8%88%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A%E0%B8%B9%E0%B8%97%E0%B8%B4%E0%B8%A8_%E0%B8%99%E0%B8%84%E0%B8%A3%E0%B8%A8%E0%B8%A3%E0%B8%B5%E0%B8%98%E0%B8%A3%E0%B8%A3%E0%B8%A1%E0%B8%A3%E0%B8%B2%E0%B8%8A';
$this->link_test_validate_url($long_url);
}
-
+
}
/**
@@ -363,20 +360,20 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
* Validation is guided by the rules in http://tools.ietf.org/html/rfc1738 !
*/
class LinkValidateUrlLight extends DrupalWebTestCase {
-
+
//function setUp() {
// do we need to include something here?
//module_load_include('inc', 'link');
//}
-
- function getInfo() {
+
+ public static function getInfo() {
return array(
- 'name' => t('Link Light Validation Tests'),
- 'description' => t('Tests the link_validate_url() function by itself, without invoking the full drupal/cck lifecycle.'),
- 'group' => t('Link'),
+ 'name' => 'Link Light Validation Tests',
+ 'description' => 'Tests the link_validate_url() function by itself, without invoking the full drupal/cck lifecycle.',
+ 'group' => 'Link',
);
}
-
+
/**
* Translates the LINK type constants to english for display and debugging of tests
*/
@@ -398,53 +395,53 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
return "Bad Value:". $type;
}
}
-
+
// Make sure that a link labelled <front> works.
function testValidateFrontLink() {
$valid = link_validate_url('<front>');
$this->assertEqual(LINK_FRONT, $valid, 'Make sure that front link is verfied and identified');
}
-
+
function testValidateEmailLink() {
$valid = link_validate_url('mailto:bob@example.com');
$this->assertEqual(LINK_EMAIL, $valid, "Make sure a basic mailto is verified and identified");
}
-
+
function testValidateEmailLinkBad() {
$valid = link_validate_url(':bob@example.com');
$this->assertEqual(FALSE, $valid, 'Make sure just a bad address is correctly failed');
}
-
+
function testValidateNewsgroupLink() {
$valid = link_validate_url('news:comp.infosystems.www.misc');
$this->assertEqual(LINK_NEWS, $valid, 'Make sure link to newsgroup validates as news.');
}
-
+
function testValidateNewsArticleLink() {
$valid = link_validate_url('news:hj0db8$vrm$1@news.eternal-september.org');
$this->assertEqual(LINK_NEWS, $valid, 'Make sure link to specific article valiates as news.');
}
-
+
function testValidateBadNewsgroupLink() {
$valid = link_validate_url('news:comp.bad_name.misc');
$this->assertEqual(FALSE, $valid, 'newsgroup names can\'t contain underscores, so it should come back as invalid.');
}
-
+
function testValidateInternalLink() {
$valid = link_validate_url('node/5');
$this->assertEqual(LINK_INTERNAL, $valid, 'Test normal internal link.');
}
-
+
function testValidateInternalLinkWithDot() {
$valid = link_validate_url('rss.xml');
$this->assertEqual(LINK_INTERNAL, $valid, 'Test rss.xml internal link.');
}
-
+
function testValidateInternalLinkToFile() {
$valid = link_validate_url('files/test.jpg');
$this->assertEqual(LINK_INTERNAL, $valid, 'Test files/test.jpg internal link.');
}
-
+
function testValidateExternalLinks() {
$links = array(
'http://localhost:8080/',
@@ -485,7 +482,7 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
//$this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");
}
}
-
+
function testInvalidExternalLinks() {
$links = array(
'http://www.ex ample.com/',
@@ -500,5 +497,5 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
$this->assertEqual(FALSE, $valid, 'Testing that '. $link .' is not a valid link.');
}
}
-
-} \ No newline at end of file
+
+}