non security modules update

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 16:32:07 +02:00
parent 6a8d30db08
commit 37fbabab56
466 changed files with 32690 additions and 9652 deletions

View File

@@ -46,8 +46,8 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
protected function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') {
$this->zebra++;
$zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd';
$cssFieldLocator = 'field-'. str_replace('_', '-', $field_name);
$this->assertPattern('@<div class="field field-type-link '. $cssFieldLocator .'".*<div class="field-item '. $zebra_string .'">\s*'. $link_value .'\s*</div>@is',
$cssFieldLocator = 'field-' . str_replace('_', '-', $field_name);
$this->assertPattern('@<div class="field field-type-link ' . $cssFieldLocator . '".*<div class="field-item ' . $zebra_string . '">\s*' . $link_value . '\s*</div>@is',
$message,
$group);
}
@@ -66,7 +66,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// Create the content type.
$this->clickLink(t('Add content type'));
$edit = array (
$edit = array(
'name' => $content_type_friendly,
'type' => $content_type_machine,
);
@@ -76,8 +76,8 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// 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;
$edit = array (
$single_field_name = 'field_' . $single_field_name_machine;
$edit = array(
'fields[_add_new_field][label]' => $single_field_name_friendly,
'fields[_add_new_field][field_name]' => $single_field_name_machine,
'fields[_add_new_field][type]' => 'link_field',
@@ -112,19 +112,19 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$this->drupalLogin($this->web_user);
// Go to page.
$this->drupalGet('node/add/'. $content_type_machine);
$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/',
'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)));
$this->drupalGet('node/add/'. $content_type_machine);
$this->drupalGet('node/add/' . $content_type_machine);
// Create a node:
$edit = array(
@@ -143,7 +143,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
protected function createSimpleLinkField($single_field_name_machine, $single_field_name_friendly, $content_type_machine) {
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/fields');
$edit = array (
$edit = array(
'fields[_add_new_field][label]' => $single_field_name_friendly,
'fields[_add_new_field][field_name]' => $single_field_name_machine,
'fields[_add_new_field][type]' => 'link_field',
@@ -180,7 +180,7 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
}
protected function createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $title, $url, $node_title = '') {
$this->drupalGet('node/add/'. $content_type_machine);
$this->drupalGet('node/add/' . $content_type_machine);
if (!$node_title) {
$node_title = $this->randomName(20);
@@ -219,10 +219,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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');
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_plain',
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));
@@ -270,10 +270,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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');
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_url',
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_url',
);
$this->drupalPost(NULL, $edit, t('Save'));
@@ -320,10 +320,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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');
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_short',
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_short',
);
$this->drupalPost(NULL, $edit, t('Save'));
@@ -371,10 +371,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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');
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_label',
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_label',
);
$this->drupalPost(NULL, $edit, t('Save'));
@@ -422,10 +422,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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');
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_separate',
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_separate',
);
$this->drupalPost(NULL, $edit, t('Save'));
@@ -474,10 +474,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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');
$this->drupalGet('admin/structure/types/manage/' . $content_type_machine . '/display');
$edit = array(
'fields[field_'. $single_field_name_machine .'][label]' => 'above',
'fields[field_'. $single_field_name_machine .'][type]' => 'link_title_plain',
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_title_plain',
);
$this->drupalPost(NULL, $edit, t('Save'));

View File

@@ -37,18 +37,17 @@ class LinkContentCrudTest extends DrupalWebTestCase {
// Create the content type.
$this->clickLink(t('Add content type'));
$edit = array (
$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);
$single_field_name_machine = strtolower($this->randomName(10));
$edit = array (
$edit = array(
'fields[_add_new_field][label]' => $single_field_name_friendly,
'fields[_add_new_field][field_name]' => $single_field_name_machine,
'fields[_add_new_field][type]' => 'link_field',
@@ -69,14 +68,5 @@ class LinkContentCrudTest extends DrupalWebTestCase {
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.
$this->assertSchemaMatchesTables(array(
'per_type' => array(
$this->content_types[0]->type => array($field['field_name'] => array('url', 'title', 'attributes')),
),
));*/
}
}

View File

@@ -76,8 +76,8 @@ class LinkUITest extends DrupalWebTestcase {
//$this->drupalGet('node/add');
$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');
$this->assertField('edit-field-' . $name . '-und-0-title', 'Title found');
$this->assertField('edit-field-' . $name . '-und-0-url', 'URL found');
$input_test_cases = array(
array(
@@ -104,26 +104,32 @@ class LinkUITest extends DrupalWebTestcase {
'msg' => 'js label',
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
),
array(
array(
'href' => 'http://example.com/' . $this->randomName(),
'label' => $this->randomName() . '\' onmouseover="alert(\'hi\')',
'msg' => 'js label',
'type' => self::LINK_INPUT_TYPE_BAD_TITLE
),
array(
array(
'href' => 'javascript:alert("http://example.com/' . $this->randomName() . '")',
'label' => $this->randomName(),
'msg' => 'js url',
'type' => self::LINK_INPUT_TYPE_BAD_URL
),
array(
'href' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
'label' => 'http://ecs-es.kelkoo.es/ctl/go/sitesearchGo?.ts=1338833010331&.sig=qP9GXeEFH6syBzwmzYkxmsvp1EI-',
'msg' => 'Url with . in querystring',
'type' => self::LINK_INPUT_TYPE_GOOD,
),
);
$test_case = array(
'href' => 'www.example.com/'. $this->randomName(),
'href' => 'www.example.com/' . $this->randomName(),
'label' => $this->randomName(),
'msg' => 'Link found',
'type' => self::LINK_INPUT_TYPE_GOOD,
);
$test_case['expected_href'] = 'http://'. $test_case['href'];
$test_case['expected_href'] = 'http://' . $test_case['href'];
$input_test_cases[] = $test_case;
foreach ($input_test_cases as $input) {
@@ -137,17 +143,17 @@ class LinkUITest extends DrupalWebTestcase {
);
$this->drupalPost(NULL, $edit, t('Save'));
if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
$this->assertRaw(t('The value provided for %field is not a valid URL.', array('%field' => $name)), 'Not a valid URL: ' . $input['href']);
$this->assertRaw(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($input['href']))), 'Not a valid URL: ' . $input['href']);
continue;
}
else {
$this->assertRaw(t(' has been created.',
$this->assertRaw(' ' . t('has been created.',
array('@type' => 'Basic Page', '%title' => $edit['title'])),
'Page created: ' . $input['href']);
}
$url = $this->getUrl();
// change to anonym user
// change to Anonymous user.
$this->drupalLogout();
$this->drupalGet($url);
@@ -156,12 +162,11 @@ class LinkUITest extends DrupalWebTestcase {
// us and let us know it's broken.
$this->assertFalse(libxml_use_internal_errors(TRUE));
if (isset($input['expected_href'])) {
$path = '//a[@href="'. $input['expected_href'] .'" and text()="'. $input['label'] .'"]';
$path = '//a[@href="' . $input['expected_href'] . '" and text()="' . $input['label'] . '"]';
}
else {
$path = '//a[@href="'. $input['href'] .'" and text()="'. $input['label'] .'"]';
$path = '//a[@href="' . $input['href'] . '" and text()="' . $input['label'] . '"]';
}
//$this->pass(htmlentities($path));
$elements = $this->xpath($path);
libxml_use_internal_errors(FALSE);
$this->assertIdentical(isset($elements[0]), $input['type'] == self::LINK_INPUT_TYPE_GOOD, $input['msg']);
@@ -179,7 +184,7 @@ class LinkUITest extends DrupalWebTestcase {
// create field
$name = strtolower($this->randomName());
$field_name = 'field_'. $name;
$field_name = 'field_' . $name;
$edit = array(
'fields[_add_new_field][label]' => $name,
'fields[_add_new_field][field_name]' => $name,
@@ -190,7 +195,7 @@ class LinkUITest extends DrupalWebTestcase {
$this->drupalPost(NULL, array(), t('Save field settings'));
$this->drupalPost(NULL, array(
'instance[settings][title]' => 'value',
'instance[settings][title_value]' => '<strong>'. $name .'</strong>'), t('Save settings'));
'instance[settings][title_value]' => '<strong>' . $name . '</strong>'), t('Save settings'));
// Is field created?
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
@@ -215,7 +220,57 @@ class LinkUITest extends DrupalWebTestcase {
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l('<strong>'. $name .'</strong>', $input['href'], array('html' => TRUE)));
$this->assertRaw(l('<strong>' . $name . '</strong>', $input['href'], array('html' => TRUE)));
}
/**
* Testing that if you have the title but no url, the title is not sanitized twice.
*/
function testCRUDTitleOnlyTitleNoLink() {
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
$this->drupalLogin($this->web_user);
// create field
$name = strtolower($this->randomName());
$field_name = 'field_' . $name;
$edit = array(
'fields[_add_new_field][label]' => $name,
'fields[_add_new_field][field_name]' => $name,
'fields[_add_new_field][type]' => 'link_field',
'fields[_add_new_field][widget_type]' => 'link_field',
);
$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][url]' => 1,
), t('Save settings'));
// Is field created?
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
// create page form
$this->drupalGet('node/add/page');
$this->assertField($field_name . '[und][0][url]', 'URL found');
$input = array(
'title' => 'This & That',
'href' => '',
);
$edit = array(
'title' => $name,
$field_name . '[und][0][title]' => $input['title'],
$field_name . '[und][0][url]' => $input['href'],
);
$this->drupalPost(NULL, $edit, t('Save'));
$url = $this->getUrl();
// change to anonymous user
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw('This &amp; That');
}
/**
@@ -242,25 +297,19 @@ class LinkUITest extends DrupalWebTestcase {
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
node_types_rebuild();
menu_rebuild();
//_content_type_info(TRUE);
//$fields = content_fields();
//$field = $fields['field_'. $name];
//$field = field_info_field('field_'. $name);
_field_info_collate_fields(TRUE);
$instances = field_info_instances('node', 'page');
//$this->debug($instances);
//$this->assert('debug', '<pre>'. print_r($instances, TRUE) .'</pre>', 'Debug');
$instance = $instances['field_'. $name];
//$this->assertTrue(1 === $instance['validate_url'], 'Make sure validation is on.');
$instance = $instances['field_' . $name];
$this->assertFalse($instance['required'], 'Make sure field is not required.');
$this->assertEqual($instance['settings']['title'], 'optional', 'Title should be optional by default.');
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be off by default.');
$this->assertTrue($instance['settings']['validate_url'], 'Make sure validation is on.');
$this->assertTrue($instance['settings']['enable_tokens'], 'Enable Tokens should be on by default.');
$this->assertEqual($instance['settings']['display']['url_cutoff'], 80, 'Url cutoff should be at 80 characters.');
$this->assertEqual($instance['settings']['attributes']['target'], 'default', 'Target should be "default"');
$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>');
}
}

View File

@@ -36,8 +36,8 @@ class LinkBaseTestClass extends DrupalWebTestCase {
'fields[_add_new_field][type]' => 'link_field',
'fields[_add_new_field][widget_type]' => 'link_field',
);
$field_name = 'field_'. $name;
$this->drupalPost('admin/structure/types/manage/'. $node_type .'/fields', $edit, t('Save'));
$field_name = 'field_' . $name;
$this->drupalPost('admin/structure/types/manage/' . $node_type . '/fields', $edit, t('Save'));
$this->drupalPost(NULL, array(), t('Save field settings'));
$this->drupalPost(NULL, $settings, t('Save settings'));

View File

@@ -75,7 +75,7 @@ class LinkTokenTest extends LinkBaseTestClass {
$name = $this->randomName();
$settings = array(
'instance[settings][title]' => 'value',
'instance[settings][title_value]' => $name .' [node:content-type:machine-name]');
'instance[settings][title_value]' => $name . ' [node:content-type:machine-name]');
$field_name = $this->createLinkField('page', $settings);
// create page form
@@ -118,7 +118,7 @@ class LinkTokenTest extends LinkBaseTestClass {
$name = $this->randomName();
$settings = array(
'instance[settings][title]' => 'value',
'instance[settings][title_value]' => $name .' [node:title]');
'instance[settings][title_value]' => $name . ' [node:title]');
$field_name = $this->createLinkField('page', $settings);
// create page form
@@ -144,7 +144,7 @@ class LinkTokenTest extends LinkBaseTestClass {
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($name .' '. $name, $input['href']));
$this->assertRaw(l($name . ' ' . $name, $input['href']));
}
// This test doesn't seem to actually work, due to lack of 'title' in url.
@@ -191,9 +191,9 @@ class LinkTokenTest extends LinkBaseTestClass {
$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[$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');
@@ -206,8 +206,8 @@ class LinkTokenTest extends LinkBaseTestClass {
//$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?");
$this->assertNoRaw(' title="['. $field_name .'-url]"');
$this->assertRaw(' title="' . $test_link_url . '"', "Do we show the link url as the title attribute?");
$this->assertNoRaw(' title="[' . $field_name . '-url]"');
$this->assertTrue(module_exists('token'), t('Assure that Token Module is enabled.'));
//$this->fail($this->content);
}
@@ -236,10 +236,10 @@ class LinkTokenTest extends LinkBaseTestClass {
$field_db_info = content_database_info($field);
$url_type = str_replace('_', '-', $this->content_types[0]->type);
$edit = array('attributes[title]' => '['. $field_name .'-title]',
$edit = array('attributes[title]' => '[' . $field_name . '-title]',
'enable_tokens' => TRUE);
$this->drupalPost('admin/content/node-type/'. $url_type .'/fields/'. $field['field_name'],
$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'])));
@@ -248,14 +248,14 @@ class LinkTokenTest extends LinkBaseTestClass {
$node = node_load($this->nodes[0]->nid);
$this->drupalGet('node/'. $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;
$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'));
$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);
@@ -263,10 +263,10 @@ class LinkTokenTest extends LinkBaseTestClass {
array('@title' => $node->title,
'@type' => $this->content_types[0]->name)));
$this->drupalGet('node/'. $node->nid);
$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?");
$this->assertNoRaw(' title="['. $field_name .'-title]"');
$this->assertNoRaw(' title="' . $title . '"', "We should not show the link title as the title attribute?");
$this->assertNoRaw(' title="[' . $field_name . '-title]"');
//$this->fail($this->content);
}
@@ -319,7 +319,7 @@ class LinkTokenTest extends LinkBaseTestClass {
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($input['label'], $input['href'] .'/page'));
$this->assertRaw(l($input['label'], $input['href'] . '/page'));
//$this->fail($this->content);
}
@@ -372,6 +372,58 @@ class LinkTokenTest extends LinkBaseTestClass {
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw(l($input['label'], $input['href'] .'/'. $this->web_user->uid));
$this->assertRaw(l($input['label'], $input['href'] . '/' . $this->web_user->uid));
}
/**
* Test that if you have a title and no url on a field which does not have tokens enabled,
* that the title is sanitized once.
*/
function testCRUDTitleOnlyTitleNoLink2() {
$this->web_user = $this->drupalCreateUser(array('administer content types', 'access content', 'create page content'));
$this->drupalLogin($this->web_user);
// create field
$name = strtolower($this->randomName());
$field_name = 'field_' . $name;
$edit = array(
'fields[_add_new_field][label]' => $name,
'fields[_add_new_field][field_name]' => $name,
'fields[_add_new_field][type]' => 'link_field',
'fields[_add_new_field][widget_type]' => 'link_field',
);
$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][url]' => 1,
'instance[settings][enable_tokens]' => 0,
), t('Save settings'));
// Is field created?
$this->assertRaw(t('Saved %label configuration', array('%label' => $name)), 'Field added');
// create page form
$this->drupalGet('node/add/page');
$this->assertField($field_name . '[und][0][url]', 'URL found');
$input = array(
'title' => 'This & That',
'href' => '',
);
$edit = array(
'title' => $name,
$field_name . '[und][0][title]' => $input['title'],
$field_name . '[und][0][url]' => $input['href'],
);
$this->drupalPost(NULL, $edit, t('Save'));
$url = $this->getUrl();
// change to anonymous user
$this->drupalLogout();
$this->drupalGet($url);
$this->assertRaw('This &amp; That');
}
}

View File

@@ -34,7 +34,7 @@ class LinkValidateTestCase extends LinkBaseTestClass {
$field_name . '[und][0][url]' => $url,
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertRaw(t(' has been created.'), 'Node created');
$this->assertRaw(' has been created.', 'Node created');
$nid = 1; //$matches[1];
@@ -90,17 +90,17 @@ class LinkValidateTest extends LinkValidateTestCase {
// 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');
$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',
$field_name . '[und][0][url]' => 'edik:naw',
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@value' => 'edik:naw', '@field' => $name)));
}
/**
@@ -135,17 +135,17 @@ class LinkValidateTest extends LinkValidateTestCase {
// 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');
$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',
$field_name . '[und][0][url]' => 'edik:naw',
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@field' => $name, '@value' => 'edik:naw')));
}
@@ -185,17 +185,17 @@ class LinkValidateTest extends LinkValidateTestCase {
// 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');
$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',
$field_name . '[und][0][url]' => 'edik:naw',
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertNoText(t('The value provided for @field is not a valid URL.', array('@field' => $name)));
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => 'edik:naw')));
}
/**
@@ -207,10 +207,10 @@ class LinkValidateTest extends LinkValidateTestCase {
'administer nodes',
'access administration pages',
'access content',
'create '. $this->content_types[0]->type .' content',
'edit any '. $this->content_types[0]->type .' content'));
'create ' . $this->content_types[0]->type . ' content',
'edit any ' . $this->content_types[0]->type . ' content'));
$this->drupalLogin($this->web_user);
variable_set('node_options_'. $this->content_types[0]->name, array('status', 'promote'));
variable_set('node_options_' . $this->content_types[0]->name, array('status', 'promote'));
$field_settings = array(
'type' => 'link',
'widget_type' => 'link',
@@ -227,23 +227,23 @@ class LinkValidateTest extends LinkValidateTestCase {
$node = node_load($this->nodes[0]->nid);
$this->drupalGet('node/'. $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;
$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->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
//$this->pass($this->content);
$this->assertNoText(t('The value provided for %field is not a valid URL.', array('%field' => $name)));
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($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->drupalGet('node/' . $node->nid);
$this->assertNoRaw($url, 'Make sure Javascript does not display.');
// Turn the array validation back _on_.
@@ -251,9 +251,9 @@ class LinkValidateTest extends LinkValidateTestCase {
$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->drupalPost('admin/content/node-type/' . $node_type_link . '/fields/' . $field['field_name'], $edit, t('Save field settings'));
$this->drupalGet('node/'. $node->nid);
$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.
@@ -382,7 +382,7 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
case FALSE:
return "Invalid Link";
default:
return "Bad Value:". $type;
return "Bad Value:" . $type;
}
}
@@ -460,12 +460,12 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
$allowed_protocols = variable_get('filter_allowed_protocols', array('http', 'https', 'ftp', 'news', 'nntp', 'telnet', 'mailto', 'irc', 'ssh', 'sftp', 'webcal'));
foreach ($allowed_protocols as $protocol) {
if ($protocol !== 'news' && $protocol !== 'mailto') {
$links[] = $protocol .'://www.example.com';
$links[] = $protocol . '://www.example.com';
}
}
foreach ($links as $link) {
$valid = link_validate_url($link);
$this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that '. $link .' is a valid external link.');
$this->assertEqual(LINK_EXTERNAL, $valid, 'Testing that ' . $link . ' is a valid external link.');
// The following two lines are commented out and only used for comparisons.
//$valid2 = valid_url($link, TRUE);
//$this->assertEqual(TRUE, $valid2, "Using valid_url() on $link.");
@@ -488,7 +488,7 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
);
foreach ($links as $link) {
$valid = link_validate_url($link);
$this->assertEqual(FALSE, $valid, 'Testing that '. $link .' is not a valid link.');
$this->assertEqual(FALSE, $valid, 'Testing that ' . $link . ' is not a valid link.');
}
}
}