Révision 5136ce55
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/piwik/piwik.test | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
class PiwikBasicTest extends DrupalWebTestCase { |
8 | 8 |
|
9 |
/** |
|
10 |
* User without permissions to edit snippets. |
|
11 |
* |
|
12 |
* @var \StdClass |
|
13 |
*/ |
|
14 |
protected $noSnippetUser; |
|
15 |
|
|
9 | 16 |
public static function getInfo() { |
10 | 17 |
return array( |
11 | 18 |
'name' => t('Piwik basic tests'), |
... | ... | |
23 | 30 |
); |
24 | 31 |
|
25 | 32 |
// User to set up piwik. |
33 |
$this->noSnippetUser = $this->drupalCreateUser($permissions); |
|
34 |
$permissions[] = 'add JS snippets for piwik'; |
|
26 | 35 |
$this->admin_user = $this->drupalCreateUser($permissions); |
27 | 36 |
$this->drupalLogin($this->admin_user); |
28 | 37 |
} |
... | ... | |
36 | 45 |
$edit['piwik_site_id'] = $this->randomName(2); |
37 | 46 |
$this->drupalPost('admin/config/system/piwik', $edit, 'Save configuration'); |
38 | 47 |
$this->assertRaw(t('A valid Piwik site ID is an integer only.'), '[testPiwikConfiguration]: Invalid Piwik site ID number validated.'); |
48 |
|
|
49 |
// User should have access to code snippets. |
|
50 |
$this->assertFieldByName('piwik_codesnippet_before'); |
|
51 |
$this->assertFieldByName('piwik_codesnippet_after'); |
|
52 |
$this->assertNoFieldByXPath("//textarea[@name='piwik_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is enabled.'); |
|
53 |
$this->assertNoFieldByXPath("//textarea[@name='piwik_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is enabled.'); |
|
54 |
|
|
55 |
// Login as user without JS permissions. |
|
56 |
$this->drupalLogin($this->noSnippetUser); |
|
57 |
$this->drupalGet('admin/config/system/piwik'); |
|
58 |
|
|
59 |
// User should *not* have access to snippets, but create fields. |
|
60 |
$this->assertFieldByName('piwik_codesnippet_before'); |
|
61 |
$this->assertFieldByName('piwik_codesnippet_after'); |
|
62 |
$this->assertFieldByXPath("//textarea[@name='piwik_codesnippet_before' and @disabled='disabled']", NULL, '"Code snippet (before)" is disabled.'); |
|
63 |
$this->assertFieldByXPath("//textarea[@name='piwik_codesnippet_after' and @disabled='disabled']", NULL, '"Code snippet (after)" is disabled.'); |
|
39 | 64 |
} |
40 | 65 |
|
41 | 66 |
function testPiwikPageVisibility() { |
Formats disponibles : Unified diff
Weekly update of contrib modules