Commit eed0cf14 authored by pifagor's avatar pifagor
Browse files

Issue #2945128: Fix coding standard test parts

parent c13b3726
......@@ -9,6 +9,7 @@
* Attribute Crud Test.
*/
class LinkAttributeCrudTest extends DrupalWebTestCase {
private $zebra;
protected $permissions = array(
......@@ -40,7 +41,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
parent::setup('field_ui', 'link');
$this->zebra = 0;
// Create and login user.
$this->web_user = $this->drupalCreateUser(array('administer content types', 'administer fields'));
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
'administer fields',
));
$this->drupalLogin($this->web_user);
}
......@@ -63,8 +67,8 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
$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',
$message,
$group);
$message,
$group);
}
/**
......@@ -140,7 +144,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
);
$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->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);
......@@ -153,7 +160,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
// 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)));
$this->assertText(t('@content_type_friendly @title has been created', array(
'@content_type_friendly' => $content_type_friendly,
'@title' => $title,
)));
$this->assertText('Display');
$this->assertLinkByHref('http://www.example.com');
......@@ -222,7 +232,10 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
}
$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)));
$this->assertText(t('@content_type_friendly @title has been created', array(
'@content_type_friendly' => $content_type_friendly,
'@title' => $node_title,
)));
}
......
......@@ -45,7 +45,10 @@ class LinkContentCrudTest extends DrupalWebTestCase {
$content_type_machine = strtolower($this->randomName(10));
// Create and login user.
$this->web_user = $this->drupalCreateUser(array('administer content types', 'administer fields'));
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
'administer fields',
));
$this->drupalLogin($this->web_user);
$this->drupalGet('admin/structure/types');
......
......@@ -150,13 +150,16 @@ class LinkUITest extends DrupalWebTestcase {
);
$this->drupalPost(NULL, $edit, t('Save'));
if ($input['type'] == self::LINK_INPUT_TYPE_BAD_URL) {
$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']);
$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.',
array('@type' => 'Basic Page', '%title' => $edit['title'])),
'Page created: ' . $input['href']);
array('@type' => 'Basic Page', '%title' => $edit['title'])),
'Page created: ' . $input['href']);
}
$url = $this->getUrl();
......
......@@ -38,7 +38,7 @@ class LinkEntityTokenTest extends LinkBaseTestClass {
'instance[settings][enable_tokens]' => 0,
);
$field_name = $this->createLinkField('page',
$settings);
$settings);
// Create page form.
$this->drupalGet('node/add/page');
......@@ -88,7 +88,7 @@ class LinkEntityTokenTest extends LinkBaseTestClass {
$this->assertEqual($node->nid, $index, "Test that we have a node.");
$token_name = '[node:' . str_replace('_', '-', $field_name) . ':url]';
$assert_data = token_replace($token_name,
array('node' => $node));
array('node' => $node));
$this->assertEqual($input2['href'], $assert_data, "Test that the url token has been set to " . $input2['href'] . ' - ' . $assert_data);
}
}
......@@ -105,7 +105,7 @@ class LinkEntityTokenTest extends LinkBaseTestClass {
'instance[settings][enable_tokens]' => 0,
);
$field_name = $this->createLinkField('page',
$settings);
$settings);
// Create page form.
$this->drupalGet('node/add/page');
......@@ -156,7 +156,7 @@ class LinkEntityTokenTest extends LinkBaseTestClass {
$this->assertEqual($node->nid, $index, "Test that we have a node.");
$token_name = '[node:' . str_replace('_', '-', $field_name) . ':url]';
$assert_data = token_replace($token_name,
array('node' => $node));
array('node' => $node));
$this->assertEqual($input2['href'], $assert_data, "Test that the url token has been set to " . $input2['href'] . ' - ' . $assert_data);
}
}
......
......@@ -9,6 +9,7 @@
* Base Test Class.
*/
class LinkBaseTestClass extends DrupalWebTestCase {
protected $permissions = array(
'access content',
'administer content types',
......
......@@ -40,7 +40,7 @@ class LinkTokenTest extends LinkBaseTestClass {
'instance[settings][enable_tokens]' => 1,
);
$field_name = $this->createLinkField('page',
$settings);
$settings);
// Create page form.
$this->drupalGet('node/add/page');
......@@ -214,7 +214,7 @@ class LinkTokenTest extends LinkBaseTestClass {
// 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)));
array('@title' => $name)));
// $this->drupalGet('node/'. $node->nid);.
$this->assertText($title, 'Make sure the link title/text shows');
......@@ -258,7 +258,7 @@ class LinkTokenTest extends LinkBaseTestClass {
);
$this->drupalPost('admin/content/node-type/' . $url_type . '/fields/' . $field['field_name'],
$edit, t('Save field settings'));
$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...
......@@ -278,10 +278,10 @@ class LinkTokenTest extends LinkBaseTestClass {
// 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,
)));
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');
......
......@@ -52,6 +52,7 @@ class LinkValidateTestCase extends LinkBaseTestClass {
}
}
/**
* Class for Validate Test.
*/
......@@ -85,7 +86,8 @@ class LinkValidateTest extends LinkValidateTestCase {
*/
public function test_link_validate_bad_url_validate_default() {
// @codingStandardsIgnoreEnd
$this->web_user = $this->drupalCreateUser(array('administer content types',
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
'administer fields',
'administer nodes',
'administer filters',
......@@ -124,7 +126,10 @@ class LinkValidateTest extends LinkValidateTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@value' => 'edik:naw', '@field' => $name)));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array(
'@value' => 'edik:naw',
'@field' => $name,
)));
}
/**
......@@ -134,7 +139,8 @@ class LinkValidateTest extends LinkValidateTestCase {
*/
public function test_link_validate_bad_url_validate_on() {
// @codingStandardsIgnoreEnd
$this->web_user = $this->drupalCreateUser(array('administer content types',
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
'administer fields',
'administer nodes',
'administer filters',
......@@ -173,7 +179,10 @@ class LinkValidateTest extends LinkValidateTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array('@field' => $name, '@value' => 'edik:naw')));
$this->assertText(t('The value @value provided for @field is not a valid URL.', array(
'@field' => $name,
'@value' => 'edik:naw',
)));
}
......@@ -184,7 +193,8 @@ class LinkValidateTest extends LinkValidateTestCase {
*/
public function test_link_validate_bad_url_validate_off() {
// @codingStandardsIgnoreEnd
$this->web_user = $this->drupalCreateUser(array('administer content types',
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
'administer fields',
'administer nodes',
'administer filters',
......@@ -228,7 +238,10 @@ class LinkValidateTest extends LinkValidateTestCase {
);
$this->drupalPost(NULL, $edit, t('Save'));
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => 'edik:naw')));
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array(
'%field' => $name,
'%value' => 'edik:naw',
)));
}
/**
......@@ -242,7 +255,8 @@ class LinkValidateTest extends LinkValidateTestCase {
public function x_test_link_validate_switching_between_validation_status() {
// @codingStandardsIgnoreEnd
$this->acquireContentTypes(1);
$this->web_user = $this->drupalCreateUser(array('administer content types',
$this->web_user = $this->drupalCreateUser(array(
'administer content types',
'administer fields',
'administer nodes',
'access administration pages',
......@@ -251,12 +265,15 @@ class LinkValidateTest extends LinkValidateTestCase {
'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',
'type_name' => $this->content_types[0]->name,
// <-- This is needed or we have an error.
// <-- This is needed or we have an error.
'attributes' => array(),
'validate_url' => 0,
);
......@@ -278,7 +295,10 @@ class LinkValidateTest extends LinkValidateTestCase {
$this->drupalPost('node/' . $this->nodes[0]->nid . '/edit', $edit, t('Save'));
// $this->pass($this->content);.
// @codingStandardsIgnoreLine
$this->assertNoText(t('The value %value provided for %field is not a valid URL.', array('%field' => $name, '%value' => trim($url))));
$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);
......@@ -360,6 +380,7 @@ class LinkValidateTest extends LinkValidateTestCase {
}
}
/**
* Validate Test News.
*/
......@@ -389,7 +410,7 @@ class LinkValidateTestNews extends LinkValidateTestCase {
/**
* Validate a news link to a message id. Said ID copied off of google groups.
*
* @codingStandardsIgnoreStart
* @codingStandardsIgnoreStart
*/
public function test_link_news_message() {
// @codingStandardsIgnoreEnd
......@@ -397,6 +418,7 @@ class LinkValidateTestNews extends LinkValidateTestCase {
}
}
/**
* Validate Specific URL.
*/
......@@ -467,6 +489,7 @@ class LinkValidateSpecificURL extends LinkValidateTestCase {
* Here, we're testing that a very long url is stored properly in the db.
*
* Basically, trying to test http://drupal.org/node/376818
*
* @codingStandardsIgnoreStart
*/
public function testLinkURLFieldIsBig() {
......@@ -672,12 +695,12 @@ class LinkValidateUrlLight extends DrupalWebTestCase {
public function testInvalidExternalLinks() {
$links = array(
'http://www.ex ample.com/',
// Bad ip!
// Bad ip!
'http://25.0.0/',
'http://4827.0.0.2/',
// ß not allowed in domain names!
// ß not allowed in domain names!
'http://www.testß.com/',
// Bad TLD.
// Bad TLD.
'http://.www.foo.bar./',
// Domains can't have sections starting with a dash.
// 'http://www.-fudge.com/',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment