pardot.test in Pardot Integration 7.2
Same filename and directory in other branches
Pardot web tests.
File
pardot.testView source
<?php
/**
* @file
* Pardot web tests.
*/
/**
* Basic Pardot Test Case implementation.
*/
class PardotFunctionalityTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Pardot functionality test',
'description' => 'Test basic pardot functionality.',
'group' => 'Pardot',
);
}
public function setUp(array $modules = array()) {
$modules[] = 'webform';
$modules[] = 'pardot';
$modules[] = 'path';
parent::setUp($modules);
// Create an administrator user.
$permissions = array(
'administer pardot',
);
$user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($user);
// Set basic settings.
$options = array(
'pardot_a_id' => 12345,
'pardot_c_id' => 23456,
);
$drupal_settings = $this
->drupalGetSettings();
$drupal_settings += $options;
$this
->drupalSetSettings($drupal_settings);
$this
->drupalPost('admin/config/services/pardot', $options, t('Save configuration'));
$this
->assertRaw(t('The configuration options have been saved.'), t('Pardot configuration saved.'));
}
public function testCampaignJS() {
// Add a campaign.
$this
->drupalPost('admin/config/services/pardot/campaign', array(
'campaign_id' => 34567,
'name' => 'Test 1',
'paths' => 'node',
), t('Add'));
$this
->drupalGet('user');
$this
->assertRaw('pardot.js"', 'Pardot default campaign added to non-campaign page.');
$this
->drupalGet('node');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['pardot_c_id'], '34567', 'Pardot Test 1 campaign added to campaign page.');
// Modify a campaign.
$this
->drupalPost("admin/config/services/pardot/campaign/34567/edit", array(
'name' => 'Test 1',
'paths' => 'user',
), t('Save'));
$this
->drupalGet('user');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['pardot_c_id'], '34567', 'Pardot Test 1 campaign added to capaign page after modification.');
$this
->drupalGet('node');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['pardot_c_id'], '23456', 'Pardot default campaign added to non-campaign page after modification.');
// Delete a campaign.
$this
->drupalPost("admin/config/services/pardot/campaign/34567/delete", array(), t('Delete'));
$this
->drupalGet('user');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['pardot_c_id'], '23456', 'Pardot default campaign added to capaign page after campaign deletion.');
$this
->drupalPost('admin/config/services/pardot/campaign', array(
'campaign_id' => 34567,
'name' => 'node path test',
'paths' => 'pardot_test_1',
), t('Add'));
$this
->drupalCreateNode(array(
'path' => array(
'alias' => 'pardot_test_1',
),
));
$this
->drupalGet('pardot_test_1');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['pardot_c_id'], '34567', 'Pardot campaign added to aliased node.');
}
public function testScoringJS() {
// Add a campaign.
$this
->drupalPost('admin/config/services/pardot/scoring', array(
'path' => 'user',
'score' => '50',
), t('Add'));
$this
->drupalGet('node');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertFalse($drupal_settings['pardot']['score'], 'No Pardot scoring on general page.');
$this
->drupalGet('user');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['score'], '50', 'Pardot scoring found on scored page.');
// Modify a campaign.
$this
->drupalPost("admin/config/services/pardot/scoring/1/edit", array(
'path' => 'user',
'score' => '60',
), t('Save'));
$this
->drupalGet('node');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertFalse($drupal_settings['pardot']['score'], 'No Pardot scoring on general page after modification.');
$this
->drupalGet('user');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertEqual($drupal_settings['pardot']['score'], '60', 'Pardot scoring found on scored page after modification.');
// Delete a campaign.
$this
->drupalPost("admin/config/services/pardot/scoring/1/delete", array(), t('Delete'));
$this
->drupalGet('user');
$drupal_settings = $this
->drupalGetSettings();
$this
->assertFalse($drupal_settings['pardot']['score'], 'Pardot scoring not found on scored page after deletion.');
}
}
Classes
Name | Description |
---|---|
PardotFunctionalityTestCase | Basic Pardot Test Case implementation. |