function FacebookTrackingPixelTestCase::setUp in Facebook Tracking Pixel 8
Same name and namespace in other branches
- 7 tests/facebook_tracking_pixel.test \FacebookTrackingPixelTestCase::setUp()
1 call to FacebookTrackingPixelTestCase::setUp()
- FacebookTrackingPixelTestCaseUser::setUp in tests/facebook_tracking_pixel.user.test
1 method overrides FacebookTrackingPixelTestCase::setUp()
- FacebookTrackingPixelTestCaseUser::setUp in tests/facebook_tracking_pixel.user.test
File
- tests/facebook_tracking_pixel.test, line 62
- Contains tests for the Facebook Tracking Pixel module.
Class
- FacebookTrackingPixelTestCase
- Test case.
Code
function setUp() {
$modules[] = 'facebook_tracking_pixel';
parent::setUp($modules);
if ($testrid = $this
->drupalCreateRole([], 'fb pixel tester')) {
$this->webUser = $this
->drupalCreateUser([
'access content',
]);
$edit = [
'roles' => [
$testrid => 'fb pixel tester',
],
];
user_save($this->webUser, $edit);
}
$this->adminUser = $this
->drupalCreateUser([
'administer facebook tracking pixels',
'access content',
'create page content',
'edit own page content',
'administer url aliases',
'create url aliases',
'administer users',
'administer permissions',
]);
$this
->drupalLogin($this->adminUser);
$this
->drupalPost('user/' . $this->adminUser->uid . '/edit', [
'roles[3]' => TRUE,
], t('Save'));
$this->baseCodeFBID = '123123123';
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();
$this->baseCodeID = db_select('facebook_tracking_pixel_base_codes', 'c')
->fields('c', [
'base_code_id',
])
->condition('base_code_fbid', $this->baseCodeFBID, '=')
->execute()
->fetchField();
$node = $this
->drupalCreateNode();
$this->nodeTitle = $node->title;
$this
->assertTrue(!empty($node->nid), t('A basic page has been created with node ID %nid and title %title and path alias', [
'%nid' => $node->nid,
'%title' => $node->title,
]), t('FBTrkPx'));
$edit = [];
$edit['source'] = 'node/' . $node->nid;
$edit['alias'] = 'nodetest';
$this
->drupalPost('admin/config/search/path/add', $edit, t('Save'));
$this->testFacebookTrackingPixelNodeAlias = $edit['alias'];
$this->nodeID = $node->nid;
cache_clear_all('*', 'cache_path', TRUE);
$this
->drupalGet($edit['source']);
$this
->assertTrue(cache_get($edit['source'], 'cache_path'), 'Cache entry was created.');
cache_clear_all('*', 'cache_path', TRUE);
$this
->drupalGet($edit['alias']);
$this
->assertTrue(cache_get($edit['source'], 'cache_path'), 'Cache entry was created.');
}