public function OptimizelyTestDefaultProjectTestCase::testOptimizelyTestDefaultProjectListingAJAX in Optimizely 7.2
Same name and namespace in other branches
- 7.3 optimizely.test \OptimizelyTestDefaultProjectTestCase::testOptimizelyTestDefaultProjectListingAJAX()
File
- ./
optimizely.test, line 296 - Optimizely Tests
Class
- OptimizelyTestDefaultProjectTestCase
- OptimizelyTestDefaultProjectTestCase: Test that:
Code
public function testOptimizelyTestDefaultProjectListingAJAX() {
// Access with privileged user
$this
->drupalLogin($this->privileged_user);
// Access general module settings page
$this
->drupalGet('admin/config/system/optimizely/settings');
// Add Optimizely account setting so that Default Project can be enabled.
$this->optimizelyAccountId = rand(1000000, 9999999);
$edit = array(
'optimizely_id' => $this->optimizelyAccountId,
);
$this
->drupalPost($this->settingsPage, $edit, t('Submit'));
// Confirm default project is disabled.
$this
->assertNoFieldChecked('project-enable-1', '<strong>Default project is disabled on project listing page.</strong>', 'Optimizely');
$protocol = empty($_SERVER['HTTPS']) ? 'http' : 'https';
$domain = $_SERVER['SERVER_NAME'];
// Test that Ajax call succeeds.
$params = array(
'target_oid' => 1,
// 1 == Default Project
'target_enable' => 1,
);
$curlParams = array(
CURLOPT_URL => $protocol . '://' . $domain . ':' . $_SERVER['SERVER_PORT'] . '/' . $this->ajaxCallbackUrl,
CURLOPT_POST => TRUE,
CURLOPT_POSTFIELDS => drupal_http_build_query($params),
CURLOPT_HTTPHEADER => array(
"Accept: application/json",
),
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_VERBOSE => TRUE,
);
$ajaxResults = $this
->curlExec($curlParams, TRUE);
$ajaxResponse = json_decode($ajaxResults);
$this
->assertEqual($ajaxResponse->status, 'updated', '<strong>AJAX call to /admin/config/system/optimizely/ajax returned status is "updated"</strong>', 'Optimizely');
$this
->assertEqual($ajaxResponse->message, '', '<strong>AJAX call to /admin/config/system/optimizely/ajax returned message as blank</strong>', 'Optimizely');
// Go to project listings page
$this
->drupalGet('admin/config/system/optimizely');
// Confirm default project is enabled.
$this
->assertFieldChecked('project-enable-1', '<strong>Default project is enabled on project listing page.</strong>', 'Optimizely');
}