function FacebookTrackingPixelTestCaseCommerce::setUp in Facebook Tracking Pixel 8
Same name and namespace in other branches
- 7 tests/facebook_tracking_pixel.commerce.test \FacebookTrackingPixelTestCaseCommerce::setUp()
File
- tests/
facebook_tracking_pixel.commerce.test, line 85
Class
- FacebookTrackingPixelTestCaseCommerce
- Test case.
Code
function setUp() {
// Setup the modules needed for testing.
$modules = parent::setUpHelper('all', [
'facebook_tracking_pixel',
]);
parent::setUp($modules);
// Enable all roles for tracking.
$fbHelper = new facebookTrackingPixel\FacebookTrackingPixelTestHelper();
$fbHelper
->enable_tracking_all_roles();
$permissions = array_merge($this
->permissionBuilder('store admin'), [
'administer facebook tracking pixels',
'access content',
'create page content',
'edit own page content',
'administer url aliases',
'create url aliases',
'administer users',
'administer permissions',
]);
$this->admin_user = $this
->drupalCreateUser($permissions);
$this->store_customer = $this
->createStoreCustomer();
// Create a Dummy product type for testing.
$this->product_type = $this
->createDummyProductType();
// Create a Dummy product using the product type just created with SKU 555.
$this->product = $this
->createDummyProduct($this->product_sku, $this->product_name, -1, 'USD', 1, $this->product_type['type']);
// Create a product display content type and attach a product field to it.
$this
->createDummyProductDisplayContentType();
// Create a product display node using the testing SKU.
$node = $this
->createDummyProductNode([
$this->product->product_id,
], 'Test Product Page');
$this->product_node_nid = $node->nid;
// Just in case, we clear all caches.
cache_clear_all();
// Test Basecode ID.
db_insert('facebook_tracking_pixel_base_codes')
->fields([
'base_code_name' => 'Test Basecode',
'base_code_fbid' => $this->baseCodeFBID,
'base_code_global' => 1,
'weight' => 10,
])
->execute();
// Retreieve the base id created.
$this->baseCodeID = db_select('facebook_tracking_pixel_base_codes', 'c')
->fields('c', [
'base_code_id',
])
->condition('base_code_fbid', $this->baseCodeFBID, '=')
->execute()
->fetchField();
}