You are here

public function JsTestWebTestCase::testBase in JS Callback Handler 7

Same name and namespace in other branches
  1. 6 tests/js_test.test \JsTestWebTestCase::testBase()

Test basic JS callbacks.

File

tests/js_test.test, line 30
Testing for the bam template module

Class

JsTestWebTestCase
@file Testing for the bam template module

Code

public function testBase() {

  // Via index.php?q=js.php
  $out = $this
    ->drupalGet('index.php', array(
    'query' => array(
      'q' => 'js/js_test/test_basic',
    ),
  ));
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['filename'], 'js.php', 'Call was routed through js.php.');
  $this
    ->assertEqual($out['response'], 'ok', 'The response to the basic test was ok.');

  // Via clean url (rewrite).
  $out = $this
    ->drupalGet('js/js_test/test_basic');
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['filename'], 'js.php', 'Call was routed through js.php.');
  $this
    ->assertEqual($out['response'], 'ok', 'The response to the basic test was ok.');

  // Test Page arguments.
  $out = $this
    ->drupalGet('js/js_test/test_arguments/value1/value2/value3');
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['response']['argument_1'], 'value1', 'Page argument 1 should be value1.');
  $this
    ->assertEqual($out['response']['argument_2'], 'value3', 'Page argument 2 should be value3.');

  // Test seperate file.
  $out = $this
    ->drupalGet('js/js_test/test_file');
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['response'], 'ok', 'The response to the file test was ok.');

  // Test skip_hook_init.
  $out = $this
    ->drupalGet('js/js_test/test_init');
  $out = drupal_json_decode($out);
  $this
    ->assertEqual($out['hook_init'], FALSE, 'The hook init should have been skipped.');
}