You are here

function YandexMetricsReportsTestCase::testObtainPageTitle in Yandex.Metrics 7.2

Same name and namespace in other branches
  1. 8.2 yandex_metrics_reports/yandex_metrics_reports.test \YandexMetricsReportsTestCase::testObtainPageTitle()

Test for yandex_metrics_reports_obtain_page_title() function.

See also

yandex_metrics_reports_obtain_page_title()

File

yandex_metrics_reports/yandex_metrics_reports.test, line 48
Tests for Yandex.Metrics Reports module.

Class

YandexMetricsReportsTestCase
Tests of functionality and settings of Yandex.Metrics Counter module.

Code

function testObtainPageTitle() {

  /* Homepage */
  $page_title = yandex_metrics_reports_obtain_page_title('/');
  $this
    ->assertEqual($page_title, variable_get('site_name', t('Front page')), 'Obtain default homepage title.');
  $page_title = yandex_metrics_reports_obtain_page_title(variable_get('site_frontpage', 'node'));
  $this
    ->assertEqual($page_title, variable_get('site_name', t('Front page')), 'Obtain homepage title.');

  /* Simple page */
  $page_title = yandex_metrics_reports_obtain_page_title('/contact');
  $this
    ->assertEqual($page_title, 'contact', 'Obtain page title for contact page.');

  /* Node */
  $this
    ->drupalLogin($this->admin_user);

  // Enable URL language detection and selection.
  $edit = array(
    'language[enabled][locale-url]' => 1,
  );
  $this
    ->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));

  // Create a node.
  $node = $this
    ->drupalCreateNode(array(
    'type' => 'page',
  ));

  // Create a path alias in default language (English).
  $english_path = $this
    ->randomName(8);
  $edit = array(
    'source' => 'node/' . $node->nid,
    'alias' => $english_path,
    'language' => 'en',
  );
  path_save($edit);

  // Get title.
  $page_title = yandex_metrics_reports_obtain_page_title('/' . $english_path);
  $this
    ->assertEqual($page_title, $node->title, 'Check page title for node.');

  // TODO: Taxonomy.
}