public function FacebookTrackingPixelTestTrackingCase::testFacebookTrackingPixelBasePixel in Facebook Tracking Pixel 7
Same name and namespace in other branches
- 8 tests/facebook_tracking_pixel.tracking.test \FacebookTrackingPixelTestTrackingCase::testFacebookTrackingPixelBasePixel()
Test adding basecodes through UI and see they appear on the page.
File
- tests/
facebook_tracking_pixel.tracking.test, line 29
Class
- FacebookTrackingPixelTestTrackingCase
- Test case.
Code
public function testFacebookTrackingPixelBasePixel() {
// Submit a new global basecode.
$edit = [];
$edit['name'] = $this
->randomName(8);
$id1 = 12314512312;
$edit['fbid'] = $id1;
$edit['global'] = TRUE;
$this
->drupalPost('admin/config/system/facebook_tracking_pixel/base_codes', $edit, t('Add'));
$this
->assertText(t('Facebook Base Tracking Code Added'), t('Add new base code through the admin UI'));
// Submit a duplicate item using the same FB basecode ID.
$edit['name'] = $this
->randomName(8);
$this
->drupalPost('admin/config/system/facebook_tracking_pixel/base_codes', $edit, t('Add'));
$this
->assertText(t('You only need to add a base tracking code once.'), t('Add duplicate base code through the admin UI'));
// Submit a second global basecode.
$edit = [];
$edit['name'] = $this
->randomName(8);
$id2 = 789789789;
$edit['fbid'] = $id2;
$this
->drupalPost('admin/config/system/facebook_tracking_pixel/base_codes', $edit, t('Add'));
$this
->assertText(t('Facebook Base Tracking Code Added'), t('Add new base code through the admin UI'));
// Enable all roles for tracking.
$fbHelper = new facebookTrackingPixel\FacebookTrackingPixelTestHelper();
$fbHelper
->enable_tracking_all_roles();
// With two base codes set to global they should both appear on a page.
$this
->drupalGet('');
$this
->assertRaw('facebook_tracking_pixel/fb_tkpx.' . $id1 . '.js', t('Tracking Code 1 Found in Raw Source'), 'FBTrkPx');
$this
->assertRaw('facebook_tracking_pixel/fb_tkpx.' . $id2 . '.js', t('Tracking Code 2 Found in Raw Source'), 'FBTrkPx');
$this
->assertRaw('facebook_tracking_pixel/fb_tkpx.' . $this->baseCodeFBID . '.js', t('Setup Tracking Code Found in Raw Source'), 'FBTrkPx');
}