js_test.test in JS Callback Handler 6
Same filename and directory in other branches
Testing for the bam template module
File
tests/js_test.testView source
<?php
/**
* @file
* Testing for the bam template module
*/
class JsTestWebTestCase extends DrupalWebTestCase {
protected $privileged_user;
public static function getInfo() {
return array(
'name' => 'JS Test',
'description' => 'JavaScript Callback Handler',
'group' => 'JS',
);
}
public function setUp() {
parent::setUp(array(
'js',
'js_test',
'locale',
));
}
/**
* Test basic JS callbacks.
*/
public function testBase() {
// Via clean url (rewrite).
$out = $this
->drupalGet('js/js_test/test_basic');
$out = (array) 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');
$out = (array) json_decode($out);
$this
->assertEqual($out['response']->argument_1, 'value1', 'Page argument 1 should be value1 and is ' . $out['response']->argument_1 . '.');
$this
->assertEqual($out['response']->argument_2, 'value2', 'Page argument 2 should be value2 and is ' . $out['response']->argument_2 . '.');
// Test seperate file.
$out = $this
->drupalGet('js/js_test/test_file');
$out = (array) json_decode($out);
$this
->assertEqual($out['response'], 'ok', 'The response to the file test was ok.');
}
}
Classes
Name | Description |
---|---|
JsTestWebTestCase | @file Testing for the bam template module |