You are here

public function OptimizelyDefaultProjectTest::testDefaultProjectEnable in Optimizely 8.0

Same name and namespace in other branches
  1. 8.3 src/Tests/OptimizelyDefaultProjectTest.php \Drupal\optimizely\Tests\OptimizelyDefaultProjectTest::testDefaultProjectEnable()
  2. 8 src/Tests/OptimizelyDefaultProjectTest.php \Drupal\optimizely\Tests\OptimizelyDefaultProjectTest::testDefaultProjectEnable()

1. The default project is available but disabled in the project listing page after the module has been enabled.

2. A message in the project listing page directs the administrator to go to the module settings page to enter the Optimizely account value.

5. The default project cannot be enabled until the account number is entered on the settings page.

File

src/Tests/OptimizelyDefaultProjectTest.php, line 90
Contains \Drupal\optimizely\src\Tests\OptimizelyDefaultProjectTest

Class

OptimizelyDefaultProjectTest
Test various aspects of the default project.

Namespace

Drupal\optimizely\Tests

Code

public function testDefaultProjectEnable() {

  // Access with privileged user
  $this
    ->drupalLogin($this->privilegedUser);

  // Look for entry in project listing page
  $this
    ->drupalGet($this->listingPage);
  $this
    ->assertRaw('<td class="project-title-column disabled">Default</td>', '<strong>Default project entry found on project listing page.</strong>', 'Optimizely');

  // Confirm default project is not enabled
  $this
    ->assertRaw('<input id="project-enable-1" name="project-1" type="checkbox" ' . 'value="1" class="form-checkbox" />', '<strong>Default project checkbox exists.</strong>', 'Optimizely');
  $this
    ->assertNoFieldChecked('project-enable-1', '<strong>Default project is not enabled.</strong>', 'Optimizely');

  // Link to complete default project setup available
  $this
    ->assertLink('Account Info', 0, '<strong>Link from default project to module settings page available.</strong>', 'Optimizely');

  // Navigate to Edit form for Default project
  $this
    ->drupalGet($this->updateDefaultProjPage);

  // Title field set to Default, not accessible
  $this
    ->assertPattern(':<input( [^>]*? | )disabled="disabled"( [^>]*? | )id="edit-optimizely-project-title"( [^>]*? | )value="Default"( [^>]*?)?/>:', '<strong>Project title field is not editable and set to "Default"</strong>.', 'Optimizely');

  // Project Code field not set (Undefined), not accessible
  $this
    ->assertPattern(':<input( [^>]*? | )disabled="disabled"( [^>]*? | )id="edit-optimizely-project-code"( [^>]*? | )value="Undefined"( [^>]*?)?/>:', '<strong>Project code field is not editable and set to "Undefined".</strong>', 'Optimizely');

  // Link to settings page to set account / Default project code
  $this
    ->assertLink('Account Info', 0, '<strong>Link to settings page found to set Default project code.</strong>', 'Optimizely');

  // Check default Default project path is set to sitewide wild card
  $this
    ->assertPattern(':<textarea( [^>]*? | )id="edit-optimizely-path"( [^>]*?)?>\\*</textarea>:', '<strong>Default project path set to sitewide wild card "*".</strong>', 'Optimizely');

  // * 5. The default project can not be enabled until the account number is entered on the settings page.
}