You are here

function ViewsBaseUrlTestCase::testViewsBaseUrlField in Views base url 7

Test views base url field.

File

tests/views_base_url.test, line 53
Views base url test functions.

Class

ViewsBaseUrlTestCase
@file Views base url test functions.

Code

function testViewsBaseUrlField() {
  global $base_url;
  $this
    ->drupalGet('views-base-url-test');
  $this
    ->assertResponse(200);

  // Check whether there are ten rows.
  $rows = $this
    ->xpath('//div[contains(@class,"view-views-base-url-test")]/div[@class="view-content"]/div[contains(@class,"views-row")]');
  $this
    ->assertEqual(count($rows), 10, t('There are 10 rows'));

  // We check for at least one views result that link is properly rendered as
  // image.
  $node = $this->nodes[1];
  $image = theme('image', array(
    'path' => $node->field_image[LANGUAGE_NONE][0]['uri'],
    'width' => $node->field_image[LANGUAGE_NONE][0]['width'],
    'height' => $node->field_image[LANGUAGE_NONE][0]['height'],
    'alt' => $node->field_image[LANGUAGE_NONE][0]['alt'],
  ));
  $link = l($image, $base_url . '/' . drupal_get_path_alias('node/' . $node->nid), array(
    'attributes' => array(
      'class' => 'views-base-url-test',
      'title' => $node->title,
      'rel' => 'rel-attribute',
      'target' => '_blank',
    ),
    'fragment' => 'new',
    'query' => array(
      'destination' => 'node',
    ),
    'html' => TRUE,
  ));
  $this
    ->assertRaw($link, t('Views base url rendered as link image'));
}