function FacebookTrackingPixelTestCaseUser::setUp in Facebook Tracking Pixel 7
Same name and namespace in other branches
- 8 tests/facebook_tracking_pixel.user.test \FacebookTrackingPixelTestCaseUser::setUp()
Sets up a Drupal site for running functional and integration tests.
Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.
After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.
Parameters
...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.
Overrides FacebookTrackingPixelTestCase::setUp
See also
DrupalWebTestCase::prepareDatabasePrefix()
DrupalWebTestCase::changeDatabasePrefix()
DrupalWebTestCase::prepareEnvironment()
File
- tests/
facebook_tracking_pixel.user.test, line 46 - Contains tests for the Facebook Tracking Pixel module.
Class
Code
function setUp() {
parent::setUp();
// Enable all roles for tracking.
$fbHelper = new facebookTrackingPixel\FacebookTrackingPixelTestHelper();
$fbHelper
->enable_tracking_all_roles();
// Create a non-global base code to test with user tracking.
// Test Basecode ID.
db_insert('facebook_tracking_pixel_base_codes')
->fields([
'base_code_name' => 'Test Basecode 2',
'base_code_fbid' => $this->userBaseCodeFBID,
'base_code_global' => 0,
'weight' => 20,
])
->execute();
// Retreieve the base id created.
$this->userBaseCodeID = db_select('facebook_tracking_pixel_base_codes', 'c')
->fields('c', [
'base_code_id',
])
->condition('base_code_fbid', $this->userBaseCodeFBID, '=')
->execute()
->fetchField();
}