public function AcquiaLiftWebTestReports::testConversionReportAjaxEndpoint in Acquia Lift Connector 7
File
- tests/
acquia_lift.test, line 2132 - Integration tests for Acquia Lift module.
Class
Code
public function testConversionReportAjaxEndpoint() {
$this
->drupalLogin($this->managerUser);
$agent = $this
->createTestAgent(array(), TRUE, FALSE);
$agent_name = $agent
->getMachineName();
// Set the agent to read report data from the test file.
$path = drupal_get_path('module', 'acquia_lift');
variable_set("acquia_lift_report_source_" . $agent_name, "/" . $path . '/tests/test_reports.json');
// Call the conversion report endpoint.
$first_osid = 'osid-1';
$report = $this
->drupalGet('acquia_lift/reports/conversion', array(
'query' => array(
'campaign' => $agent_name,
'decision' => $first_osid,
),
));
$report = drupal_json_decode($report);
$pattern = '/class="lift-statistic-category"/';
preg_match($pattern, $report, $matches);
$this
->assertEqual(count($matches), 1, 'Only one category of results returned.');
$pattern = '/(<table)/';
preg_match($pattern, $report, $matches);
$this
->assertEqual(count($matches), 2, 'Only two tables returned.');
$pattern = '/data-acquia-lift-campaign=\\"([a-z0-9\\_\\-]+)\\"/';
preg_match($pattern, $report, $matches);
$this
->assertEqual($matches[1], $agent_name, 'Campaign name was passed in tabular data.');
$pattern = '/data-acquia-lift-decision-name=\\"([a-z0-9\\_\\-]+)\\"/';
preg_match($pattern, $report, $matches);
$this
->assertEqual($matches[1], $first_osid, 'Decision name was passed in tabular data.');
}