You are here

function PiwikBasicTest::testPiwikConfiguration in Piwik Web Analytics 7.2

Same name and namespace in other branches
  1. 6.2 piwik.test \PiwikBasicTest::testPiwikConfiguration()

File

./piwik.test, line 39
Test file for Piwik module.

Class

PiwikBasicTest
@file Test file for Piwik module.

Code

function testPiwikConfiguration() {

  // Check for setting page's presence.
  $this
    ->drupalGet('admin/config/system/piwik');
  $this
    ->assertRaw(t('Piwik site ID'), '[testPiwikConfiguration]: Settings page displayed.');

  // Check for account code validation.
  $edit['piwik_site_id'] = $this
    ->randomName(2);
  $this
    ->drupalPost('admin/config/system/piwik', $edit, 'Save configuration');
  $this
    ->assertRaw(t('A valid Piwik site ID is an integer only.'), '[testPiwikConfiguration]: Invalid Piwik site ID number validated.');

  // User should have access to code snippets.
  $this
    ->assertFieldByName('piwik_codesnippet_before');
  $this
    ->assertFieldByName('piwik_codesnippet_after');
  $this
    ->assertNoFieldByXPath("//textarea[@name='piwik_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.');
  $this
    ->assertNoFieldByXPath("//textarea[@name='piwik_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.');

  // Login as user without JS permissions.
  $this
    ->drupalLogin($this->noSnippetUser);
  $this
    ->drupalGet('admin/config/system/piwik');

  // User should *not* have access to snippets, but create fields.
  $this
    ->assertFieldByName('piwik_codesnippet_before');
  $this
    ->assertFieldByName('piwik_codesnippet_after');
  $this
    ->assertFieldByXPath("//textarea[@name='piwik_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.');
  $this
    ->assertFieldByXPath("//textarea[@name='piwik_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.');
}