PiwikCustomUrls.php in Piwik Web Analytics 8
File
src/Tests/PiwikCustomUrls.php
View source
<?php
namespace Drupal\piwik\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Serialization\Json;
class PiwikCustomUrls extends WebTestBase {
public static $modules = [
'piwik',
];
protected function setUp() {
parent::setUp();
$permissions = [
'access administration pages',
'administer piwik',
'administer modules',
'administer site configuration',
];
$this->admin_user = $this
->drupalCreateUser($permissions);
}
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.');
}
}