You are here

rules_admin_minimal_profile.test in Rules 7.2

Rules UI tests.

File

rules_admin/tests/rules_admin_minimal_profile.test
View source
<?php

/**
 * @file
 * Rules UI tests.
 */

/**
 * UI test cases for the minimal profile.
 *
 * The minimal profile is useful for testing because it has fewer dependencies
 * so the tests run faster. Also, removing the profile-specific configuration
 * reveals assumptions in the code. For example, the minimal profile doesn't
 * define any content types, so when Rules expects to have content types to
 * operate on that assumption may cause errors.
 */
class RulesAdminMinimalProfileTestCase extends DrupalWebTestCase {

  /**
   * {@inheritdoc}
   */
  protected $profile = 'minimal';

  /**
   * Declares test metadata.
   */
  public static function getInfo() {
    return array(
      'name' => 'Rules UI Minimal Profile Tests ',
      'description' => 'Tests UI support for minimal profile.',
      'group' => 'Rules',
    );
  }

  /**
   * Overrides DrupalWebTestCase::setUp().
   */
  protected function setUp() {
    parent::setUp('rules', 'rules_admin');
    RulesLog::logger()
      ->clear();
    variable_set('rules_debug_log', TRUE);
  }

  /**
   * Tests node event UI without content types.
   *
   * @see https://www.drupal.org/project/rules/issues/2267341
   */
  public function testNodeEventUi() {

    // Create a simple user account with permission to create a rule.
    $user = $this
      ->drupalCreateUser(array(
      'access administration pages',
      'administer rules',
    ));
    $this
      ->drupalLogin($user);
    $this
      ->drupalGet('admin/config/workflow/rules/reaction/add');
    $edit = array(
      'settings[label]' => 'Test node event',
      'settings[name]' => 'test_node_event',
      'event' => 'node_insert',
    );
    $this
      ->drupalPostAJAX(NULL, $edit, 'event');
    $this
      ->assertText('Restrict by type', 'Restrict by type selection is visible.');
    $this
      ->drupalPost(NULL, $edit, 'Save');
    $this
      ->assertText('Editing reaction rule', 'Rule edit page is shown.');
  }

}

Classes

Namesort descending Description
RulesAdminMinimalProfileTestCase UI test cases for the minimal profile.