class GAPushUnitTestCase in GA Push 7
Same name and namespace in other branches
- 8 test/ga_push.test \GAPushUnitTestCase
Functional tests for the GA Push module.
Hierarchy
- class \DrupalTestCase
- class \DrupalUnitTestCase
- class \GAPushUnitTestCase
- class \DrupalUnitTestCase
Expanded class hierarchy of GAPushUnitTestCase
File
- test/
ga_push.test, line 13 - Test case for testing the GA Push module.
View source
class GAPushUnitTestCase extends DrupalUnitTestCase {
protected $pushes;
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'GA Push functionality',
'description' => 'Test the JS push types output.',
'group' => 'GA Push',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp('ga_push', 'googleanalytics');
// $ua_code = 'UA-123456-1';
// variable_set('googleanalytics_account', $ua_code);
// Get defined vars:
module_load_include('module', 'ga_push');
// Common pushes:
$this->pushes = array();
// Events:
$this->pushes[GA_PUSH_TYPE_EVENT]['calv'] = array(
'eventCategory' => 'Videos',
'eventAction' => 'Play',
'eventLabel' => 'Gone With the Wind',
'eventValue' => 1,
'nonInteraction' => FALSE,
);
$this->pushes[GA_PUSH_TYPE_EVENT]['calvn'] = array(
'eventCategory' => 'Videos',
'eventAction' => 'Play',
'eventLabel' => 'Gone With the Wind',
'eventValue' => 1,
'nonInteraction' => TRUE,
);
$this->pushes[GA_PUSH_TYPE_EVENT]['ca'] = array(
'eventCategory' => 'Videos',
'eventAction' => 'Play',
);
// Social:
$this->pushes[GA_PUSH_TYPE_SOCIAL]['nat'] = array(
'socialNetwork' => 'facebook',
'socialAction' => 'like',
'socialTarget' => 'http://mycoolpage.com',
);
$this->pushes[GA_PUSH_TYPE_SOCIAL]['n'] = array(
'socialNetwork' => 'facebook',
);
}
/**
* Unit test for ga_push_method_analytics_js_push_script(): Ecommerce.
*/
public function testGaPushMethodAnalyticsJSPushScriptEcommerce() {
$type = GA_PUSH_TYPE_ECOMMERCE;
// @TODO!
}
/**
* Unit test for ga_push_method_analytics_js_push_script(): Event.
*/
public function testGaPushMethodAnalyticsJSPushScriptEvent() {
$type = GA_PUSH_TYPE_EVENT;
// Load library:
module_load_include('inc', 'ga_push', 'inc/ga_push.analytics_js');
$push = $this->pushes[$type]['calv'];
$script = ga_push_method_analytics_js_push_script($push, $type);
$expected = 'ga(\'send\', {"eventCategory":"Videos","eventAction":"Play","eventLabel":"Gone With the Wind","eventValue":1,"hitType":"event"});' . "\n";
$this
->assertTrue($expected === $script, 'GA Push Analytics js: event (calv)');
$push = $this->pushes[$type]['calvn'];
$script = ga_push_method_analytics_js_push_script($push, $type);
$expected = 'ga(\'send\', {"eventCategory":"Videos","eventAction":"Play","eventLabel":"Gone With the Wind","eventValue":1,"nonInteraction":true,"hitType":"event"});' . "\n";
$this
->assertTrue($expected === $script, 'GA Push Analytics js: event (calvn)');
$push = $this->pushes[$type]['ca'];
$script = ga_push_method_analytics_js_push_script($push, $type);
$expected = 'ga(\'send\', {"eventCategory":"Videos","eventAction":"Play","eventValue":1,"hitType":"event"});' . "\n";
$this
->assertTrue($expected === $script, 'GA Push Analytics js: event (ca)');
}
/**
* Unit test for ga_push_method_analytics_js_push_script(): Exception.
*/
public function testGaPushMethodAnalyticsJSPushScriptException() {
$type = GA_PUSH_TYPE_EXCEPTION;
// @TODO!
}
/**
* Unit test for ga_push_method_analytics_js_push_script(): Pageview.
*/
public function testGaPushMethodAnalyticsJSPushScriptPageview() {
$type = GA_PUSH_TYPE_PAGEVIEW;
// @TODO!
}
/**
* Unit test for ga_push_method_analytics_js_push_script(): Social.
*/
public function testGaPushMethodAnalyticsJSPushScriptSocial() {
$type = GA_PUSH_TYPE_SOCIAL;
// Load library:
module_load_include('inc', 'ga_push', 'inc/ga_push.analytics_js');
$push = $this->pushes[$type]['nat'];
$script = ga_push_method_analytics_js_push_script($push, $type);
$expected = 'ga(\'send\', {"socialNetwork":"facebook","socialAction":"like","socialTarget":"http:\\/\\/mycoolpage.com","hitType":"social"});' . "\n";
$this
->assertTrue($expected === $script, 'GA Push Analytics js: social (nat)');
$push = $this->pushes[$type]['n'];
$script = ga_push_method_analytics_js_push_script($push, $type);
$expected = 'ga(\'send\', {"socialNetwork":"facebook","hitType":"social"});' . "\n";
$this
->assertTrue($expected === $script, 'GA Push Analytics js: social (n)');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DrupalTestCase:: |
protected | property | Assertions thrown in that test case. | |
DrupalTestCase:: |
protected | property | The database prefix of this test run. | |
DrupalTestCase:: |
protected | property | The original file directory, before it was changed for testing purposes. | |
DrupalTestCase:: |
public | property | Current results of this test case. | |
DrupalTestCase:: |
protected | property | Flag to indicate whether the test has been set up. | |
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | ||
DrupalTestCase:: |
protected | property | This class is skipped when looking for the source of an assertion. | |
DrupalTestCase:: |
protected | property | The test run ID. | |
DrupalTestCase:: |
protected | property | Time limit for the test. | |
DrupalTestCase:: |
public | property | Whether to cache the installation part of the setUp() method. | |
DrupalTestCase:: |
public | property | Whether to cache the modules installation part of the setUp() method. | |
DrupalTestCase:: |
protected | property | URL to the verbose output file directory. | |
DrupalTestCase:: |
protected | function | Internal helper: stores the assert. | |
DrupalTestCase:: |
protected | function | Check to see if two values are equal. | |
DrupalTestCase:: |
protected | function | Check to see if a value is false (an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
protected | function | Check to see if two values are identical. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not equal. | |
DrupalTestCase:: |
protected | function | Check to see if two values are not identical. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is NULL. | |
DrupalTestCase:: |
protected | function | Check to see if a value is not false (not an empty string, 0, NULL, or FALSE). | |
DrupalTestCase:: |
public static | function | Delete an assertion record by message ID. | |
DrupalTestCase:: |
protected | function | Fire an error assertion. | 1 |
DrupalTestCase:: |
public | function | Handle errors during test runs. | 1 |
DrupalTestCase:: |
protected | function | Handle exceptions. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always negative. | |
DrupalTestCase:: |
public static | function | Converts a list of possible parameters into a stack of permutations. | |
DrupalTestCase:: |
protected | function | Cycles through backtrace until the first non-assertion method is found. | |
DrupalTestCase:: |
public static | function | Returns the database connection to the site running Simpletest. | |
DrupalTestCase:: |
public static | function | Store an assertion from outside the testing context. | |
DrupalTestCase:: |
protected | function | Fire an assertion that is always positive. | |
DrupalTestCase:: |
public static | function | Generates a random string containing letters and numbers. | |
DrupalTestCase:: |
public static | function | Generates a random string of ASCII characters of codes 32 to 126. | |
DrupalTestCase:: |
public | function | Run all tests in this class. | |
DrupalTestCase:: |
protected | function | Logs a verbose message in a text file. | |
DrupalUnitTestCase:: |
protected | function | 1 | |
DrupalUnitTestCase:: |
function |
Constructor for DrupalUnitTestCase. Overrides DrupalTestCase:: |
||
GAPushUnitTestCase:: |
protected | property | ||
GAPushUnitTestCase:: |
public static | function | ||
GAPushUnitTestCase:: |
public | function |
Sets up unit test environment. Overrides DrupalUnitTestCase:: |
|
GAPushUnitTestCase:: |
public | function | Unit test for ga_push_method_analytics_js_push_script(): Ecommerce. | |
GAPushUnitTestCase:: |
public | function | Unit test for ga_push_method_analytics_js_push_script(): Event. | |
GAPushUnitTestCase:: |
public | function | Unit test for ga_push_method_analytics_js_push_script(): Exception. | |
GAPushUnitTestCase:: |
public | function | Unit test for ga_push_method_analytics_js_push_script(): Pageview. | |
GAPushUnitTestCase:: |
public | function | Unit test for ga_push_method_analytics_js_push_script(): Social. |