You are here

public function PiwikCustomUrls::testPiwikUserPasswordPage in Piwik Web Analytics 8

Tests if user password page urls are overridden.

File

src/Tests/PiwikCustomUrls.php, line 42

Class

PiwikCustomUrls
Test custom url functionality of Piwik module.

Namespace

Drupal\piwik\Tests

Code

public function testPiwikUserPasswordPage() {
  $base_path = base_path();
  $site_id = '1';
  $this
    ->config('piwik.settings')
    ->set('site_id', $site_id)
    ->save();
  $this
    ->config('piwik.settings')
    ->set('url_http', 'http://www.example.com/piwik/')
    ->save();
  $this
    ->config('piwik.settings')
    ->set('url_https', 'https://www.example.com/piwik/')
    ->save();
  $this
    ->drupalGet('user/password', [
    'query' => [
      'name' => 'foo',
    ],
  ]);
  $this
    ->assertRaw('_paq.push(["setCustomUrl", ' . Json::encode($base_path . 'user/password') . ']);');
  $this
    ->drupalGet('user/password', [
    'query' => [
      'name' => 'foo@example.com',
    ],
  ]);
  $this
    ->assertRaw('_paq.push(["setCustomUrl", ' . Json::encode($base_path . 'user/password') . ']);');
  $this
    ->drupalGet('user/password');
  $this
    ->assertNoRaw('_paq.push(["setCustomUrl", "', '[testPiwikCustomUrls]: Custom url not set.');
}