You are here

public function MatomoCustomUrlsTest::testMatomoUserPasswordPage in Matomo Analytics 8

Tests if user password page urls are overridden.

File

tests/src/Functional/MatomoCustomUrlsTest.php, line 49

Class

MatomoCustomUrlsTest
Test custom url functionality of Matomo module.

Namespace

Drupal\Tests\matomo\Functional

Code

public function testMatomoUserPasswordPage() {
  $base_path = base_path();
  $site_id = '1';
  $this
    ->config('matomo.settings')
    ->set('site_id', $site_id)
    ->save();
  $this
    ->config('matomo.settings')
    ->set('url_http', 'http://www.example.com/matomo/')
    ->save();
  $this
    ->config('matomo.settings')
    ->set('url_https', 'https://www.example.com/matomo/')
    ->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", "', '[testMatomoCustomUrls]: Custom url not set.');
}