You are here

function BoxesBasicAjaxTestCase::testAjaxBoxes in Boxes 6

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

Test creating and deleting a box.

File

tests/boxes.test, line 133

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' => $this
      ->randomName(32),
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));
  $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');
}