public function OptimizelyDefaultProjectTest::testDefaultProjectSettings in Optimizely 8
Same name and namespace in other branches
- 8.3 src/Tests/OptimizelyDefaultProjectTest.php \Drupal\optimizely\Tests\OptimizelyDefaultProjectTest::testDefaultProjectSettings()
- 8.0 src/Tests/OptimizelyDefaultProjectTest.php \Drupal\optimizely\Tests\OptimizelyDefaultProjectTest::testDefaultProjectSettings()
Test settings for Default project.
3. Accessing the account setting page should be blank by default with a message informing the user that the account setting will be used for the default project number.
4. Test that adding the account setting redirects to the project listing page with the account number listed as the disabled project dumber for the default project entry.
File
- src/
Tests/ OptimizelyDefaultProjectTest.php, line 156
Class
- OptimizelyDefaultProjectTest
- Test various aspects of the default project.
Namespace
Drupal\optimizely\TestsCode
public function testDefaultProjectSettings() {
// Access with privileged user.
$this
->drupalLogin($this->privilegedUser);
// Access generate module settings page.
$this
->drupalGet($this->settingsPage);
// Check for blank setting (default)
$this
->assertFieldByName('optimizely_id', NULL, '<strong>The Optimizely ID field is blank on Account Info page</strong>', 'Optimizely');
// Add Optimizely account setting.
$this->optimizelyAccountId = rand(1000000, 9999999);
// N.B. Must use name attribute, not Id.
$edit = [
'optimizely_id' => $this->optimizelyAccountId,
];
$this
->drupalPostForm($this->settingsPage, $edit, t('Submit'));
// Check that redirect to project page worked after entering
// Optimizely account ID in setting page
// $this->assertUrl('/admin/config/system/optimizely', $options = array(),
// 'Redirected to project listing page -> /admin/config/system/optimizely
// after submitting Optimizely account ID on setting page.');.
$this
->drupalGet($this->listingPage);
// Check that the newly entered Optimizely ID is now listed
// as the project ID for the Default project.
$this
->assertRaw('<td class="project-code-column disabled">' . $this->optimizelyAccountId . '</td>', '<strong>Default project is using the Optimizely account ID for project ID -> ' . $this->optimizelyAccountId . '.</strong>', 'Optimizely');
// Access add / edit project page for default project.
$this
->drupalGet($this->updateDefaultProjPage);
// Check the project ID setting matches the Optimizely Account ID setting.
$this
->assertFieldByName('optimizely_project_code', $this->optimizelyAccountId, '<strong>The Optimizely Project Code matches the Optimizely account ID setting.</strong>', 'Optimizely');
// Enable the Default project.
$edit = [
'optimizely_enabled' => 1,
];
$this
->drupalPostForm($this->updateDefaultProjPage, $edit, t('Update'));
// Go to project listings page.
$this
->drupalGet($this->listingPage);
// Confirm default project *is* enabled.
$this
->assertRaw('<input id="project-enable-1" name="project-1" checked="checked" ' . 'type="checkbox" value="1" class="form-checkbox" />', '<strong>Default project *is* enabled on project listing page.</strong>', 'Optimizely');
}