You are here

function BoxesBasicAjaxTestCase::testAjaxBoxes in Boxes 7

Same name and namespace in other branches
  1. 6 tests/boxes.test \BoxesBasicAjaxTestCase::testAjaxBoxes()

Test creating and deleting a box.

File

tests/boxes.test, line 139

Class

BoxesBasicAjaxTestCase

Code

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');
}