public function OptimizelyDefaultSettingsTest::testDefaultSettings in Optimizely 8.3
Same name and namespace in other branches
- 8 src/Tests/OptimizelyDefaultSettingsTest.php \Drupal\optimizely\Tests\OptimizelyDefaultSettingsTest::testDefaultSettings()
- 8.0 src/Tests/OptimizelyDefaultSettingsTest.php \Drupal\optimizely\Tests\OptimizelyDefaultSettingsTest::testDefaultSettings()
Test setting the Optimizely account id.
Test enabling & disabling the Default project.
File
- src/
Tests/ OptimizelyDefaultSettingsTest.php, line 55
Class
- OptimizelyDefaultSettingsTest
- Test the account Id and the Default project.
Namespace
Drupal\optimizely\TestsCode
public function testDefaultSettings() {
$this
->drupalLogin($this->privilegedUser);
// --- Add the Optimizely account ID.
$edit = [
'optimizely_id' => rand(0, 10000),
];
$this
->drupalPostForm($this->settingsPage, $edit, t('Submit'));
// The Default project has project id of 1.
$optimizely_id = \Drupal::database()
->query('SELECT project_code FROM {optimizely} WHERE oid = 1')
->fetchField();
$this
->assertEqual($optimizely_id, $edit['optimizely_id'], t('<strong>Optimizely ID number added to Default project.</strong>'), 'Optimizely');
// --- Enable the default project.
$edit = [
'optimizely_enabled' => 1,
];
$this
->drupalPostForm($this->updateDefaultProjPage, $edit, t('Update'));
$enabled = \Drupal::database()
->query('SELECT enabled FROM {optimizely} WHERE oid = 1')
->fetchField();
$this
->assertEqual($enabled, $edit['optimizely_enabled'], t('<strong>The Default project was enabled.</strong>'), 'Optimizely');
// --- Disable the default project.
$edit = [
'optimizely_enabled' => 0,
];
$this
->drupalPostForm($this->updateDefaultProjPage, $edit, t('Update'));
$enabled = \Drupal::database()
->query('SELECT enabled FROM {optimizely} WHERE oid = 1')
->fetchField();
$this
->assertEqual($enabled, $edit['optimizely_enabled'], t('<strong>The Default project was disabled.</strong>'), 'Optimizely');
}