You are here

function BoxesAjaxTestCase::ajaxLoadBoxesBlock in Boxes 7

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

Load a block via the context ajax callback and set the payload as the content for simpletest.

2 calls to BoxesAjaxTestCase::ajaxLoadBoxesBlock()
BoxesBasicAjaxTestCase::testAjaxBoxes in tests/boxes.test
Test creating and deleting a box.
BoxesSpacesTestCase::runTest in tests/boxes_spaces.test

File

tests/boxes.test, line 90

Class

BoxesAjaxTestCase

Code

function ajaxLoadBoxesBlock($delta, $path = 'node') {
  $this
    ->drupalGet($path, array(
    'query' => array(
      'boxes_delta' => $delta,
    ),
  ));
  $response = $this
    ->parseJSON();
  $block = NULL;
  foreach ($response as $command) {
    if ($command->command == 'insert' && $command->method == 'replaceWith') {
      $block = $command->data;
      break;
    }
  }
  if ($block) {
    $this
      ->pass("Loaded block");

    // Replace contents of the reponse with the decoded JSON
    $this->content = $block;
  }
  else {
    $this
      ->fail('Failed to load block');
  }
}