public function LinkFieldAttributesTest::testFormatterUrl in Link 7
Formatter URL.
File
- tests/
LinkFieldAttributesTest.test, line 326 - Field attributes test.
Class
- LinkFieldAttributesTest
- Field attributes test.
Code
public function testFormatterUrl() {
$content_type_friendly = $this
->randomName(20);
$content_type_machine = strtolower($this
->randomName(10));
$this
->drupalCreateContentType(array(
'type' => $content_type_machine,
'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;.
$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(
'fields[field_' . $single_field_name_machine . '][label]' => 'above',
'fields[field_' . $single_field_name_machine . '][type]' => 'link_url',
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->createNodeTypeUser($content_type_machine);
$link_tests = array(
'plain' => array(
'text' => 'Display',
'url' => 'http://www.example.com/',
),
'query' => array(
'text' => 'Display',
'url' => 'http://www.example.com/?q=test',
),
'fragment' => array(
'text' => 'Display',
'url' => 'http://www.example.com/#test',
),
);
foreach ($link_tests as $link_test) {
$link_text = $link_test['text'];
$link_url = $link_test['url'];
$this
->createNodeForTesting($content_type_machine, $content_type_friendly, $single_field_name_machine, $link_text, $link_url);
$this
->assertNoText($link_text);
$this
->assertLinkByHref($link_url);
}
}