public function FacebookTrackingPixelTestCaseCommerce::testCommerceBaseTrackingCheckoutStart in Facebook Tracking Pixel 7
Same name and namespace in other branches
- 8 tests/facebook_tracking_pixel.commerce.test \FacebookTrackingPixelTestCaseCommerce::testCommerceBaseTrackingCheckoutStart()
Test tracking based on starting checkout.
File
- tests/
facebook_tracking_pixel.commerce.test, line 172
Class
- FacebookTrackingPixelTestCaseCommerce
- Test case.
Code
public function testCommerceBaseTrackingCheckoutStart() {
$this
->drupalLogin($this->admin_user);
$edit = [];
$this
->drupalGet('admin/config/system/facebook_tracking_pixel/commercetracking');
$edit['facebook_tracking_pixel_commerce_tracking_enable'] = TRUE;
$this
->drupalPostAJAX(NULL, $edit, 'facebook_tracking_pixel_commerce_tracking_enable');
$edit['facebook_tracking_pixel_commerce_tracking_options_selection[checkoutstart]'] = TRUE;
$edit['facebook_tracking_pixel_commerce_tracking_basecode'] = $this->baseCodeID;
$this
->drupalPost(NULL, $edit, t('Save configuration'));
$this
->assertText(t('Commerce Tracking Settings Saved.'), t('Commerce checkout start settings saved.'), 'FBTrkPx');
// Order must be created via the UI and not programatically.
// Access the product display node.
$this
->drupalGet('node/' . $this->product_node_nid);
// Add product to the shopping cart.
$edit = [];
$this
->drupalPost(NULL, $edit, t('Add to cart'));
$this
->assertText(t($this->product_name . ' added to your cart'), t('Product added to cart successfully.'));
$this
->drupalGet('checkout');
$this
->assertRaw('facebook_tracking_pixel/commercetracking/fb_trk_checkoutstart_' . $this->baseCodeFBID . '.js', t('Checkout start tracking code JS found in head.'), 'FBTrkPx');
}