public function FacebookTrackingPixelTestTrackingCase::testFacebookTrackingPixelPathItemNodes in Facebook Tracking Pixel 7
Same name and namespace in other branches
- 8 tests/facebook_tracking_pixel.tracking.test \FacebookTrackingPixelTestTrackingCase::testFacebookTrackingPixelPathItemNodes()
Attempt to add a path tracking item to the node created using path alias.
File
- tests/
facebook_tracking_pixel.tracking.test, line 66
Class
- FacebookTrackingPixelTestTrackingCase
- Test case.
Code
public function testFacebookTrackingPixelPathItemNodes() {
// Test to add a path item to the existing node created in the setup.
$edit = [];
$edit['event_name'] = $this
->randomName(8);
$edit['event_path'] = 'node/' . $this->nodeID;
$edit['event_base_code_id'] = $this->baseCodeID;
$edit['event_type[addtocart]'] = TRUE;
$edit['event_type[lead]'] = TRUE;
$this
->drupalPost('admin/config/system/facebook_tracking_pixel/path/add', $edit, t('Save'));
$this
->assertText(t('Path tracking entry added.'), t('Path tracking text confirmation on page displayed after form submit. Path name %name added', [
'%name' => $edit['event_name'],
]), 'FBTrkPx');
// Attempt to add a path item for the same path as above using alias path.
$edit = [];
$edit['event_name'] = $this
->randomName(8);
$edit['event_path'] = $this->testFacebookTrackingPixelNodeAlias;
$edit['event_base_code_id'] = $this->baseCodeID;
$edit['event_type[search]'] = TRUE;
$edit['event_type[registration]'] = TRUE;
$this
->drupalPost('admin/config/system/facebook_tracking_pixel/path/add', $edit, t('Save'));
$this
->assertText(t('The tracker event you are trying to add is the resolved path in Drupal as the event with name'), t('Adding path with same alias should fail. This test should pass.'), 'FBTrkPx');
// Attempt to add a path item for the same path as above using system path.
$edit = [];
$edit['event_name'] = $this
->randomName(8);
$this
->assert(TRUE, 'Using Node ID ' . $this->nodeID, 'FBTrkPx');
$path = 'node/' . $this->nodeID;
$edit['event_path'] = $path;
$edit['event_base_code_id'] = $this->baseCodeID;
$edit['event_type[search]'] = TRUE;
$edit['event_type[registration]'] = TRUE;
$this
->drupalPost('admin/config/system/facebook_tracking_pixel/path/add', $edit, t('Save'));
$this
->assertText(t('You cannot add a duplicate event to the same path and base code.'), t('Adding path with same system path should fail. This test should pass.'), 'FBTrkPx');
}