summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn C Fiala2011-03-20 22:06:31 (GMT)
committer John C Fiala2011-03-20 22:06:31 (GMT)
commitf95a4dcf3a56ab6023cd6e14f289581e4028403c (patch)
treedbbbf103246352bc92f135a6cac5dfee9a312628
parentb96f896f5f0be723f404b141729776560193af1c (diff)
Issue #438770 by jcfiala:Adding test that makes sure the 'plain url' formatter is working properly with the basic case.
-rw-r--r--tests/link.attribute.test104
1 files changed, 93 insertions, 11 deletions
diff --git a/tests/link.attribute.test b/tests/link.attribute.test
index 6061234..9b64574 100644
--- a/tests/link.attribute.test
+++ b/tests/link.attribute.test
@@ -45,17 +45,6 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
);
}
- private function outputScreenContents($description, $basename) {
- // This is a hack to get a directory that won't be cleaned up by simpletest
- $file_dir = file_directory_path().'/../simpletest_output_pages';
- if (!is_dir($file_dir)) {
- mkdir($file_dir, 0777, TRUE);
- }
- $output_path = "$file_dir/$basename." . $this->randomName(10) . '.html';
- $rv = file_put_contents($output_path, $this->drupalGetContent());
- $this->pass("$description: Contents of result page are ".l('here',$output_path));
- }
-
private function assertLinkOnNode($field_name, $link_value, $message = '', $group = 'Other') {
$this->zebra++;
$zebra_string = ($this->zebra % 2 == 0) ? 'even' : 'odd';
@@ -181,7 +170,100 @@ class LinkAttributeCrudTest extends DrupalWebTestCase {
//$this->assertText('http://www.example.com/');
$this->assertLinkByHref('http://www.example.com');
}
+
+ function testFormatterPlain() {
+ $content_type_friendly = $this->randomName(20);
+ $content_type_machine = strtolower($this->randomName(10));
+ $title = $this->randomName(20);
+
+ $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,
+ );
+ $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));
+ $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',
+ '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();
+ 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.');
+ // Okay, now we want to make sure this display is changed:
+ $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]' => 'plain',
+ );
+ $this->drupalPost(NULL, $edit, t('Save'));
+
+ $permission = 'create ' . $content_type_machine . ' content';
+ $permission_edit = 'edit ' . $content_type_machine . ' content';
+ // Reset the permissions cache.
+ $this->checkPermissions(array($permission), TRUE);
+
+ // Now that we have a new content type, create a user that has privileges
+ // on the content type.
+ $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)));
+
+ $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)));
+
+
+ $this->assertText('http://www.example.com/');
+ $this->assertNoText('Display');
+ $this->assertNoLinkByHref('http://www.example.com');
+ }
/*
$test_nid = 33; // will fail!