You are here

public function FacebookTrackingPixelTestCaseCommerce::testCommerceBaseTrackingNoOptions in Facebook Tracking Pixel 7

Same name and namespace in other branches
  1. 8 tests/facebook_tracking_pixel.commerce.test \FacebookTrackingPixelTestCaseCommerce::testCommerceBaseTrackingNoOptions()

Test to make sure nothing fires when no options are selected.

File

tests/facebook_tracking_pixel.commerce.test, line 236

Class

FacebookTrackingPixelTestCaseCommerce
Test case.

Code

public function testCommerceBaseTrackingNoOptions() {
  $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_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.'));

  // Go to checkout.
  $this
    ->drupalGet('checkout');

  // Fill out the address form and submit.
  $edit = [];

  // Using a US address because of familiarity.
  $edit['customer_profile_billing[commerce_customer_address][und][0][country]'] = 'US';
  $this
    ->drupalPostAJAX(NULL, $edit, 'customer_profile_billing[commerce_customer_address][und][0][country]');
  $edit['customer_profile_billing[commerce_customer_address][und][0][name_line]'] = $this
    ->randomString();
  $edit['customer_profile_billing[commerce_customer_address][und][0][thoroughfare]'] = '123 Main Street';
  $edit['customer_profile_billing[commerce_customer_address][und][0][locality]'] = 'Smallville';
  $edit['customer_profile_billing[commerce_customer_address][und][0][administrative_area]'] = 'AK';
  $edit['customer_profile_billing[commerce_customer_address][und][0][postal_code]'] = '12345';
  $this
    ->drupalPost(NULL, $edit, t('Continue to next step'));
  $this
    ->assertText(t('Review order'), t('Arrived on review order page.'));
  $this
    ->drupalPost(NULL, [], t('Continue to next step'));
  $this
    ->assertNoRaw('fbq(\'init\', \'' . $this->baseCodeFBID, t('Checkout tracking code JS NOT found in head.'), 'FBTrkPx');
  $this
    ->assertNoRaw('fbq(\'track\', \'Purchase\'', t('Purchase complete JS NOT found'), 'FBTrkPx');
}