1 |
2c8c2b87
|
Assos Assos
|
<?php
|
2 |
|
|
/**
|
3 |
|
|
* @file
|
4 |
|
|
* Class to test the AddThis Js functionality.
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
/**
|
8 |
|
|
* AddThisJsTest tests
|
9 |
|
|
*/
|
10 |
|
|
class AddThisJsTest extends DrupalWebTestCase {
|
11 |
|
|
|
12 |
|
|
/**
|
13 |
|
|
* Simple test info
|
14 |
|
|
*/
|
15 |
|
|
public static function getInfo() {
|
16 |
|
|
return array(
|
17 |
|
|
'name' => 'Javascript test',
|
18 |
|
|
'description' => 'Testing the Javascript output',
|
19 |
|
|
'group' => 'AddThis',
|
20 |
|
|
);
|
21 |
|
|
}
|
22 |
|
|
|
23 |
|
|
/**
|
24 |
|
|
* Setup the test environment.
|
25 |
|
|
*/
|
26 |
|
|
public function setUp() {
|
27 |
|
|
parent::setUp(array('addthis', 'addthis_test'));
|
28 |
|
|
}
|
29 |
|
|
|
30 |
|
|
/**
|
31 |
|
|
* Test the presense of certain Javascript elements.
|
32 |
|
|
*/
|
33 |
|
|
public function testJavascriptPresent() {
|
34 |
|
|
$this->drupalGet('<front>');
|
35 |
|
|
|
36 |
|
|
// AddThis settings are not present.
|
37 |
|
|
$settings = $this->drupalGetSettings();
|
38 |
|
|
$this->assertTrue(empty($settings['addthis']), 'Drupal.settings.addthis is not present.');
|
39 |
|
|
|
40 |
|
|
// AddThis settings are not present.
|
41 |
|
|
$this->drupalGet('addthis/test/1');
|
42 |
|
|
$settings = $this->drupalGetSettings();
|
43 |
|
|
$this->assertTrue(empty($settings['addthis']), 'Drupal.settings.addthis is not present on test page.');
|
44 |
|
|
|
45 |
|
|
// AddThis settings is present.
|
46 |
|
|
$this->drupalGet('addthis/test/2');
|
47 |
|
|
$settings = $this->drupalGetSettings();
|
48 |
|
|
$this->assertTrue(!empty($settings['addthis']), 'Drupal.settings.addthis is present on test page and loaded on hook_page_build().');
|
49 |
|
|
|
50 |
|
|
}
|
51 |
|
|
|
52 |
|
|
/**
|
53 |
|
|
*
|
54 |
|
|
* 1. Setup with include always, load at DOM ready.
|
55 |
|
|
* - Settings should be there
|
56 |
|
|
*
|
57 |
|
|
* 2. Setup with include never
|
58 |
|
|
*
|
59 |
|
|
*/
|
60 |
|
|
|
61 |
|
|
} |