GoogleAnalyticsCustomUrls.php in Google Analytics 8.2
File
tests/src/Functional/GoogleAnalyticsCustomUrls.php
View source
<?php
namespace Drupal\Tests\google_analytics\Functional;
use Drupal\Tests\BrowserTestBase;
class GoogleAnalyticsCustomUrls extends BrowserTestBase {
public static $modules = [
'google_analytics',
];
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$permissions = [
'access administration pages',
'administer google analytics',
'administer modules',
'administer site configuration',
];
$this->admin_user = $this
->drupalCreateUser($permissions);
}
public function testGoogleAnalyticsUserPasswordPage() {
$base_path = base_path();
$ua_code = 'UA-123456-1';
$this
->config('google_analytics.settings')
->set('account', $ua_code)
->save();
$this
->drupalGet('user/password', [
'query' => [
'name' => 'foo',
],
]);
$this
->assertSession()
->responseContains('ga("set", "page", "' . $base_path . 'user/password"');
$this
->drupalGet('user/password', [
'query' => [
'name' => 'foo@example.com',
],
]);
$this
->assertSession()
->responseContains('ga("set", "page", "' . $base_path . 'user/password"');
$this
->drupalGet('user/password');
$this
->assertSession()
->responseNotContains('ga("set", "page",');
}
}