public function CtoolsModuleTestCase::testAttachJs in Chaos Tool Suite (ctools) 7
Test the ctools_attach_js function returns the expected paths.
File
- tests/
ctools.test, line 85 - Test classes for code in the CTools module file.
Class
- CtoolsModuleTestCase
- Test menu links depending on user permissions.
Code
public function testAttachJs() {
$taxonomy_path = drupal_get_path('module', 'taxonomy');
$ctools_path = drupal_get_path('module', 'ctools');
// Func should probably do a different thing but this is current behaviour.
$path = ctools_attach_js('');
$this
->assertEqual($path, $ctools_path . '/js/.js', 'Attach an empty string');
$path = ctools_attach_js('foo');
$this
->assertEqual($path, $ctools_path . '/js/foo.js', 'Attach simple string');
$path = ctools_attach_js('foo', 'ctools', '');
$this
->assertEqual($path, $ctools_path . '//foo.js', 'Attach string with empty subdir');
$path = ctools_attach_js('foo', 'ctools', 'javascript');
$this
->assertEqual($path, $ctools_path . '/javascript/foo.js', 'Attach string with alternate subdir');
$path = ctools_attach_js('foo', 'taxonomy', 'javascript');
$this
->assertEqual($path, $taxonomy_path . '/javascript/foo.js', 'Attach string from different module');
}