class BoxesBasicAjaxTestCase

  1. nittany7 modules/contrib/boxes/tests/boxes.test BoxesBasicAjaxTestCase
  2. cis7 modules/contrib/boxes/tests/boxes.test BoxesBasicAjaxTestCase
  3. mooc7 modules/contrib/boxes/tests/boxes.test BoxesBasicAjaxTestCase

Hierarchy

Expanded class hierarchy of BoxesBasicAjaxTestCase

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
BoxesAjaxTestCase::ajaxLoadBoxesBlock function Load a block via the context ajax callback and set the payload as the content for simpletest.
BoxesAjaxTestCase::parseJSON function Parse JSON that was generated by drupal_to_js
BoxesBasicAjaxTestCase::getInfo public static function Implementation of getInfo().
BoxesBasicAjaxTestCase::setUp function Implementation of setUp().
BoxesBasicAjaxTestCase::testAjaxBoxes function Test creating and deleting a box.

File

modules/contrib/boxes/tests/boxes.test, line 113

View source
class BoxesBasicAjaxTestCase extends BoxesAjaxTestCase {
  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Boxes Ajax functionality'),
      'description' => t('Add a custom boxes with AJAX.'),
      'group' => t('Boxes'),
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    parent::setUp('ctools', 'context', 'boxes');

    // Create and login user
    $admin_user = $this->drupalCreateUser(array('administer blocks', 'administer boxes'));
    $this->drupalLogin($admin_user);
  }

  /**
   * Test creating and deleting a box.
   */
  function testAjaxBoxes() {
    $this->ajaxLoadBoxesBlock('boxes_add__simple');
    $this->assertText(t('Add custom box'), 'Found box add form');

    $edit = array(
      'description' => $this->randomName(),
      'title' => $this->randomName(),
      'body[value]' => $this->randomName(32),
    );
    $this->drupalPost(NULL, $edit, t('Save'), array('query' => array('boxes_delta' => 'boxes_add__simple')));
    $response = $this->parseJSON();
    $delta = NULL;
    foreach ($response as $command) {
      if ($command->command == 'getBlock') {
        $delta = $command->delta;
        break;
      }
    }
    if (!$delta) {
      $this->fail('AJAX block submission failed');
    }

    $this->ajaxLoadBoxesBlock($delta);
    $this->assertText($edit['title'], 'Found box');
  }
}