public function OptimizelyDefaultProjectTest::testDefaultProjectListingAjax in Optimizely 8
Same name and namespace in other branches
- 8.3 src/Tests/OptimizelyDefaultProjectTest.php \Drupal\optimizely\Tests\OptimizelyDefaultProjectTest::testDefaultProjectListingAjax()
- 8.0 src/Tests/OptimizelyDefaultProjectTest.php \Drupal\optimizely\Tests\OptimizelyDefaultProjectTest::testDefaultProjectListingAjax()
Test use of Ajax to enable Default project.
File
- src/
Tests/ OptimizelyDefaultProjectTest.php, line 220
Class
- OptimizelyDefaultProjectTest
- Test various aspects of the default project.
Namespace
Drupal\optimizely\TestsCode
public function testDefaultProjectListingAjax() {
// Access with privileged user.
$this
->drupalLogin($this->privilegedUser);
// Add Optimizely account setting so that Default Project can be enabled.
$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'));
// Go to project listings page.
$this
->drupalGet($this->listingPage);
// Confirm default project is disabled.
$this
->assertNoFieldChecked('project-enable-1', '<strong>Default project is disabled on project listing page.</strong>', 'Optimizely');
// Test that Ajax call succeeds. 1 == Default Project.
$params = [
'target_oid' => 1,
'target_enable' => 1,
];
$json_response = $this
->drupalPost($this->ajaxCallbackUrl, 'application/json', $params);
$resp_obj = json_decode($json_response);
$this
->assertEqual($resp_obj->status, 'updated', '<strong>Ajax returned status is "updated"</strong>', 'Optimizely');
$this
->assertEqual($resp_obj->message, '', '<strong>Ajax returned message is blank</strong>', 'Optimizely');
}