You are here

public function LinkFieldAttributesTest::testFormatterSeparate in Link 7

Formatter Separate.

File

tests/LinkFieldAttributesTest.test, line 487
Field attributes test.

Class

LinkFieldAttributesTest
Field attributes test.

Code

public function testFormatterSeparate() {
  $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_separate',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $this
    ->createNodeTypeUser($content_type_machine);
  $plain_url = 'http://www.example.com/';
  $link_tests = array(
    'plain' => array(
      'text' => $this
        ->randomName(20),
      'url' => $plain_url,
    ),
    'query' => array(
      'text' => $this
        ->randomName(20),
      'url' => $plain_url . '?q=test',
    ),
    'fragment' => array(
      'text' => $this
        ->randomName(20),
      'url' => $plain_url . '#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
      ->assertText($link_text);
    $this
      ->assertLink($plain_url);
    $this
      ->assertLinkByHref($link_url);
  }
}