libraries.test 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530
  1. <?php
  2. /**
  3. * @file
  4. * Tests for Libraries API.
  5. */
  6. /**
  7. * Tests basic Libraries API functions.
  8. */
  9. class LibrariesUnitTestCase extends DrupalUnitTestCase {
  10. public static function getInfo() {
  11. return array(
  12. 'name' => 'Libraries API unit tests',
  13. 'description' => 'Tests basic functions provided by Libraries API.',
  14. 'group' => 'Libraries API',
  15. );
  16. }
  17. function setUp() {
  18. drupal_load('module', 'libraries');
  19. parent::setUp();
  20. }
  21. /**
  22. * Tests libraries_get_path().
  23. */
  24. function testLibrariesGetPath() {
  25. // Note that, even though libraries_get_path() doesn't find the 'example'
  26. // library, we are able to make it 'installed' by specifying the 'library
  27. // path' up-front. This is only used for testing purposed and is strongly
  28. // discouraged as it defeats the purpose of Libraries API in the first
  29. // place.
  30. $this->assertEqual(libraries_get_path('example'), FALSE, 'libraries_get_path() returns FALSE for a missing library.');
  31. }
  32. /**
  33. * Tests libraries_prepare_files().
  34. */
  35. function testLibrariesPrepareFiles() {
  36. $expected = array(
  37. 'files' => array(
  38. 'js' => array('example.js' => array()),
  39. 'css' => array('example.css' => array()),
  40. 'php' => array('example.php' => array()),
  41. ),
  42. );
  43. $library = array(
  44. 'files' => array(
  45. 'js' => array('example.js'),
  46. 'css' => array('example.css'),
  47. 'php' => array('example.php'),
  48. ),
  49. );
  50. libraries_prepare_files($library, NULL, NULL);
  51. $this->assertEqual($expected, $library, 'libraries_prepare_files() works correctly.');
  52. }
  53. }
  54. /**
  55. * Tests basic detection and loading of libraries.
  56. */
  57. class LibrariesTestCase extends DrupalWebTestCase {
  58. protected $profile = 'testing';
  59. public static function getInfo() {
  60. return array(
  61. 'name' => 'Libraries detection and loading',
  62. 'description' => 'Tests detection and loading of libraries.',
  63. 'group' => 'Libraries API',
  64. );
  65. }
  66. function setUp() {
  67. parent::setUp('libraries', 'libraries_test');
  68. }
  69. /**
  70. * Tests libraries_detect_dependencies().
  71. */
  72. function testLibrariesDetectDependencies() {
  73. $library = array(
  74. 'name' => 'Example',
  75. 'dependencies' => array('example_missing'),
  76. );
  77. libraries_detect_dependencies($library);
  78. $this->assertEqual($library['error'], 'missing dependency', 'libraries_detect_dependencies() detects missing dependency');
  79. $error_message = t('The %dependency library, which the %library library depends on, is not installed.', array(
  80. '%dependency' => 'Example missing',
  81. '%library' => $library['name'],
  82. ));
  83. $this->verbose("Expected:<br>$error_message");
  84. $this->verbose('Actual:<br>' . $library['error message']);
  85. $this->assertEqual($library['error message'], $error_message, 'Correct error message for a missing dependency');
  86. // Test versioned dependencies.
  87. $version = '1.1';
  88. $compatible = array(
  89. '1.1',
  90. '<=1.1',
  91. '>=1.1',
  92. '<1.2',
  93. '<2.0',
  94. '>1.0',
  95. '>1.0-rc1',
  96. '>1.0-beta2',
  97. '>1.0-alpha3',
  98. '>0.1',
  99. '<1.2, >1.0',
  100. '>0.1, <=1.1',
  101. );
  102. $incompatible = array(
  103. '1.2',
  104. '2.0',
  105. '<1.1',
  106. '>1.1',
  107. '<=1.0',
  108. '<=1.0-rc1',
  109. '<=1.0-beta2',
  110. '<=1.0-alpha3',
  111. '>=1.2',
  112. '<1.1, >0.9',
  113. '>=0.1, <1.1',
  114. );
  115. $library = array(
  116. 'name' => 'Example',
  117. );
  118. foreach ($compatible as $version_string) {
  119. $library['dependencies'][0] = "example_dependency ($version_string)";
  120. // libraries_detect_dependencies() is a post-detect callback, so
  121. // 'installed' is already set, when it is called. It sets the value to
  122. // FALSE for missing or incompatible dependencies.
  123. $library['installed'] = TRUE;
  124. libraries_detect_dependencies($library);
  125. $this->assertTrue($library['installed'], "libraries_detect_dependencies() detects compatible version string: '$version_string' is compatible with '$version'");
  126. }
  127. foreach ($incompatible as $version_string) {
  128. $library['dependencies'][0] = "example_dependency ($version_string)";
  129. $library['installed'] = TRUE;
  130. unset($library['error'], $library['error message']);
  131. libraries_detect_dependencies($library);
  132. $this->assertEqual($library['error'], 'incompatible dependency', "libraries_detect_dependencies() detects incompatible version strings: '$version_string' is incompatible with '$version'");
  133. }
  134. // Instead of repeating this assertion for each version string, we just
  135. // re-use the $library variable from the foreach loop.
  136. $error_message = t('The version %dependency_version of the %dependency library is not compatible with the %library library.', array(
  137. '%dependency_version' => $version,
  138. '%dependency' => 'Example dependency',
  139. '%library' => $library['name'],
  140. ));
  141. $this->verbose("Expected:<br>$error_message");
  142. $this->verbose('Actual:<br>' . $library['error message']);
  143. $this->assertEqual($library['error message'], $error_message, 'Correct error message for an incompatible dependency');
  144. }
  145. /**
  146. * Tests libraries_scan_info_files().
  147. */
  148. function testLibrariesScanInfoFiles() {
  149. $expected = array('example_info_file' => (object) array(
  150. 'uri' => drupal_get_path('module', 'libraries') . '/tests/example/example_info_file.libraries.info',
  151. 'filename' => 'example_info_file.libraries.info',
  152. 'name' => 'example_info_file.libraries',
  153. ));
  154. $this->assertEqual(libraries_scan_info_files(), $expected, 'libraries_scan_info_files() correctly finds the example info file.');
  155. $this->verbose('<pre>' . var_export(libraries_scan_info_files(), TRUE) . '</pre>');
  156. }
  157. /**
  158. * Tests libraries_info().
  159. */
  160. function testLibrariesInfo() {
  161. // Test that library information is found correctly.
  162. $expected = array(
  163. 'name' => 'Example files',
  164. 'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
  165. 'version' => '1',
  166. 'files' => array(
  167. 'js' => array('example_1.js' => array()),
  168. 'css' => array('example_1.css' => array()),
  169. 'php' => array('example_1.php' => array()),
  170. ),
  171. 'module' => 'libraries_test',
  172. );
  173. libraries_info_defaults($expected, 'example_files');
  174. $library = libraries_info('example_files');
  175. $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
  176. $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
  177. $this->assertEqual($library, $expected, 'Library information is correctly gathered.');
  178. // Test a library specified with an .info file gets detected.
  179. $expected = array(
  180. 'name' => 'Example info file',
  181. 'info file' => drupal_get_path('module', 'libraries_test') . '/example/example_info_file.libraries.info',
  182. );
  183. libraries_info_defaults($expected, 'example_info_file');
  184. $library = libraries_info('example_info_file');
  185. // If this module was downloaded from Drupal.org, the Drupal.org packaging
  186. // system has corrupted the test info file.
  187. // @see http://drupal.org/node/1606606
  188. unset($library['core'], $library['datestamp'], $library['project'], $library['version']);
  189. $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
  190. $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
  191. $this->assertEqual($library, $expected, 'Library specified with an .info file found');
  192. }
  193. /**
  194. * Tests libraries_detect().
  195. */
  196. function testLibrariesDetect() {
  197. // Test missing library.
  198. $library = libraries_detect('example_missing');
  199. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  200. $this->assertEqual($library['error'], 'not found', 'Missing library not found.');
  201. $error_message = t('The %library library could not be found.', array(
  202. '%library' => $library['name'],
  203. ));
  204. $this->assertEqual($library['error message'], $error_message, 'Correct error message for a missing library.');
  205. // Test unknown library version.
  206. $library = libraries_detect('example_undetected_version');
  207. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  208. $this->assertEqual($library['error'], 'not detected', 'Undetected version detected as such.');
  209. $error_message = t('The version of the %library library could not be detected.', array(
  210. '%library' => $library['name'],
  211. ));
  212. $this->assertEqual($library['error message'], $error_message, 'Correct error message for a library with an undetected version.');
  213. // Test unsupported library version.
  214. $library = libraries_detect('example_unsupported_version');
  215. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  216. $this->assertEqual($library['error'], 'not supported', 'Unsupported version detected as such.');
  217. $error_message = t('The installed version %version of the %library library is not supported.', array(
  218. '%version' => $library['version'],
  219. '%library' => $library['name'],
  220. ));
  221. $this->assertEqual($library['error message'], $error_message, 'Correct error message for a library with an unsupported version.');
  222. // Test supported library version.
  223. $library = libraries_detect('example_supported_version');
  224. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  225. $this->assertEqual($library['installed'], TRUE, 'Supported library version found.');
  226. // Test libraries_get_version().
  227. $library = libraries_detect('example_default_version_callback');
  228. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  229. $this->assertEqual($library['version'], '1', 'Expected version returned by default version callback.');
  230. // Test a multiple-parameter version callback.
  231. $library = libraries_detect('example_multiple_parameter_version_callback');
  232. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  233. $this->assertEqual($library['version'], '1', 'Expected version returned by multiple parameter version callback.');
  234. // Test a top-level files property.
  235. $library = libraries_detect('example_files');
  236. $files = array(
  237. 'js' => array('example_1.js' => array()),
  238. 'css' => array('example_1.css' => array()),
  239. 'php' => array('example_1.php' => array()),
  240. );
  241. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  242. $this->assertEqual($library['files'], $files, 'Top-level files property works.');
  243. // Test version-specific library files.
  244. $library = libraries_detect('example_versions');
  245. $files = array(
  246. 'js' => array('example_2.js' => array()),
  247. 'css' => array('example_2.css' => array()),
  248. 'php' => array('example_2.php' => array()),
  249. );
  250. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  251. $this->assertEqual($library['files'], $files, 'Version-specific library files found.');
  252. // Test missing variant.
  253. $library = libraries_detect('example_variant_missing');
  254. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  255. $this->assertEqual($library['variants']['example_variant']['error'], 'not found', 'Missing variant not found');
  256. $error_message = t('The %variant variant of the %library library could not be found.', array(
  257. '%variant' => 'example_variant',
  258. '%library' => 'Example variant missing',
  259. ));
  260. $this->assertEqual($library['variants']['example_variant']['error message'], $error_message, 'Correct error message for a missing variant.');
  261. // Test existing variant.
  262. $library = libraries_detect('example_variant');
  263. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  264. $this->assertEqual($library['variants']['example_variant']['installed'], TRUE, 'Existing variant found.');
  265. }
  266. /**
  267. * Tests libraries_load().
  268. */
  269. function testLibrariesLoad() {
  270. // Test dependencies.
  271. $library = libraries_load('example_dependency_missing');
  272. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  273. $this->assertFalse($library['loaded'], 'Library with missing dependency cannot be loaded');
  274. $library = libraries_load('example_dependency_incompatible');
  275. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  276. $this->assertFalse($library['loaded'], 'Library with incompatible dependency cannot be loaded');
  277. $library = libraries_load('example_dependency_compatible');
  278. $this->verbose('<pre>' . var_export($library, TRUE) . '</pre>');
  279. $this->assertEqual($library['loaded'], 1, 'Library with compatible dependency is loaded');
  280. $loaded = &drupal_static('libraries_load');
  281. $this->verbose('<pre>' . var_export($loaded, TRUE) . '</pre>');
  282. $this->assertEqual($loaded['example_dependency']['loaded'], 1, 'Dependency library is also loaded');
  283. }
  284. /**
  285. * Tests the applying of callbacks.
  286. */
  287. function testCallbacks() {
  288. $expected = array(
  289. 'name' => 'Example callback',
  290. 'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
  291. 'version' => '1',
  292. 'versions' => array(
  293. '1' => array(
  294. 'variants' => array(
  295. 'example_variant' => array(
  296. 'info callback' => 'not applied',
  297. 'pre-detect callback' => 'not applied',
  298. 'post-detect callback' => 'not applied',
  299. 'pre-load callback' => 'not applied',
  300. 'post-load callback' => 'not applied',
  301. ),
  302. ),
  303. 'info callback' => 'not applied',
  304. 'pre-detect callback' => 'not applied',
  305. 'post-detect callback' => 'not applied',
  306. 'pre-load callback' => 'not applied',
  307. 'post-load callback' => 'not applied',
  308. ),
  309. ),
  310. 'variants' => array(
  311. 'example_variant' => array(
  312. 'info callback' => 'not applied',
  313. 'pre-detect callback' => 'not applied',
  314. 'post-detect callback' => 'not applied',
  315. 'pre-load callback' => 'not applied',
  316. 'post-load callback' => 'not applied',
  317. ),
  318. ),
  319. 'callbacks' => array(
  320. 'info' => array('_libraries_test_info_callback'),
  321. 'pre-detect' => array('_libraries_test_pre_detect_callback'),
  322. 'post-detect' => array('_libraries_test_post_detect_callback'),
  323. 'pre-load' => array('_libraries_test_pre_load_callback'),
  324. 'post-load' => array('_libraries_test_post_load_callback'),
  325. ),
  326. 'info callback' => 'not applied',
  327. 'pre-detect callback' => 'not applied',
  328. 'post-detect callback' => 'not applied',
  329. 'pre-load callback' => 'not applied',
  330. 'post-load callback' => 'not applied',
  331. 'module' => 'libraries_test',
  332. );
  333. libraries_info_defaults($expected, 'example_callback');
  334. // Test a callback in the 'info' group.
  335. $expected['info callback'] = 'applied (top-level)';
  336. $expected['versions']['1']['info callback'] = 'applied (version 1)';
  337. $expected['versions']['1']['variants']['example_variant']['info callback'] = 'applied (version 1, variant example_variant)';
  338. $expected['variants']['example_variant']['info callback'] = 'applied (variant example_variant)';
  339. $library = libraries_info('example_callback');
  340. $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
  341. $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
  342. $this->assertEqual($library, $expected, 'Prepare callback was applied correctly.');
  343. // Test a callback in the 'pre-detect' and 'post-detect' phases.
  344. // Successfully detected libraries should only contain version information
  345. // for the detected version and thus, be marked as installed.
  346. unset($expected['versions']);
  347. $expected['installed'] = TRUE;
  348. // Additionally, version-specific properties of the detected version are
  349. // supposed to override the corresponding top-level properties.
  350. $expected['info callback'] = 'applied (version 1)';
  351. $expected['variants']['example_variant']['installed'] = TRUE;
  352. $expected['variants']['example_variant']['info callback'] = 'applied (version 1, variant example_variant)';
  353. // Version-overloading takes place after the 'pre-detect' callbacks have
  354. // been applied.
  355. $expected['pre-detect callback'] = 'applied (version 1)';
  356. $expected['post-detect callback'] = 'applied (top-level)';
  357. $expected['variants']['example_variant']['pre-detect callback'] = 'applied (version 1, variant example_variant)';
  358. $expected['variants']['example_variant']['post-detect callback'] = 'applied (variant example_variant)';
  359. $library = libraries_detect('example_callback');
  360. $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
  361. $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
  362. $this->assertEqual($library, $expected, 'Detect callback was applied correctly.');
  363. // Test a callback in the 'pre-load' and 'post-load' phases.
  364. // Successfully loaded libraries should only contain information about the
  365. // already loaded variant.
  366. unset($expected['variants']);
  367. $expected['loaded'] = 0;
  368. $expected['pre-load callback'] = 'applied (top-level)';
  369. $expected['post-load callback'] = 'applied (top-level)';
  370. $library = libraries_load('example_callback');
  371. $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
  372. $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
  373. $this->assertEqual($library, $expected, 'Pre-load and post-load callbacks were applied correctly.');
  374. // This is not recommended usually and is only used for testing purposes.
  375. drupal_static_reset('libraries_load');
  376. // Successfully loaded library variants are supposed to contain the specific
  377. // variant information only.
  378. $expected['info callback'] = 'applied (version 1, variant example_variant)';
  379. $expected['pre-detect callback'] = 'applied (version 1, variant example_variant)';
  380. $expected['post-detect callback'] = 'applied (variant example_variant)';
  381. $library = libraries_load('example_callback', 'example_variant');
  382. $this->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
  383. $this->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
  384. $this->assertEqual($library, $expected, 'Pre-detect and post-detect callbacks were applied correctly to a variant.');
  385. }
  386. /**
  387. * Tests that library files are properly added to the page output.
  388. *
  389. * We check for JavaScript and CSS files directly in the DOM and add a list of
  390. * included PHP files manually to the page output.
  391. *
  392. * @see _libraries_test_load()
  393. */
  394. function testLibrariesOutput() {
  395. // Test loading of a simple library with a top-level files property.
  396. $this->drupalGet('libraries_test/files');
  397. $this->assertLibraryFiles('example_1', 'File loading');
  398. // Test loading of integration files.
  399. $this->drupalGet('libraries_test/integration_files');
  400. $this->assertRaw('libraries_test.js', 'Integration file loading: libraries_test.js found');
  401. $this->assertRaw('libraries_test.css', 'Integration file loading: libraries_test.css found');
  402. $this->assertRaw('libraries_test.inc', 'Integration file loading: libraries_test.inc found');
  403. // Test version overloading.
  404. $this->drupalGet('libraries_test/versions');
  405. $this->assertLibraryFiles('example_2', 'Version overloading');
  406. // Test variant loading.
  407. $this->drupalGet('libraries_test/variant');
  408. $this->assertLibraryFiles('example_3', 'Variant loading');
  409. // Test version overloading and variant loading.
  410. $this->drupalGet('libraries_test/versions_and_variants');
  411. $this->assertLibraryFiles('example_4', 'Concurrent version and variant overloading');
  412. // Test caching.
  413. variable_set('libraries_test_cache', TRUE);
  414. cache_clear_all('example_callback', 'cache_libraries');
  415. // When the library information is not cached, all callback groups should be
  416. // invoked.
  417. $this->drupalGet('libraries_test/cache');
  418. $this->assertRaw('The <em>info</em> callback group was invoked.', 'Info callback invoked for uncached libraries.');
  419. $this->assertRaw('The <em>pre-detect</em> callback group was invoked.', 'Pre-detect callback invoked for uncached libraries.');
  420. $this->assertRaw('The <em>post-detect</em> callback group was invoked.', 'Post-detect callback invoked for uncached libraries.');
  421. $this->assertRaw('The <em>pre-load</em> callback group was invoked.', 'Pre-load callback invoked for uncached libraries.');
  422. $this->assertRaw('The <em>post-load</em> callback group was invoked.', 'Post-load callback invoked for uncached libraries.');
  423. // When the library information is cached only the 'pre-load' and
  424. // 'post-load' callback groups should be invoked.
  425. $this->drupalGet('libraries_test/cache');
  426. $this->assertNoRaw('The <em>info</em> callback group was not invoked.', 'Info callback not invoked for cached libraries.');
  427. $this->assertNoRaw('The <em>pre-detect</em> callback group was not invoked.', 'Pre-detect callback not invoked for cached libraries.');
  428. $this->assertNoRaw('The <em>post-detect</em> callback group was not invoked.', 'Post-detect callback not invoked for cached libraries.');
  429. $this->assertRaw('The <em>pre-load</em> callback group was invoked.', 'Pre-load callback invoked for cached libraries.');
  430. $this->assertRaw('The <em>post-load</em> callback group was invoked.', 'Post-load callback invoked for cached libraries.');
  431. variable_set('libraries_test_cache', FALSE);
  432. }
  433. /**
  434. * Helper function to assert that a library was correctly loaded.
  435. *
  436. * Asserts that all the correct files were loaded and all the incorrect ones
  437. * were not.
  438. *
  439. * @param $name
  440. * The name of the files that should be loaded. The current testing system
  441. * knows of 'example_1', 'example_2', 'example_3' and 'example_4'. Each name
  442. * has an associated JavaScript, CSS and PHP file that will be asserted. All
  443. * other files will be asserted to not be loaded. See
  444. * tests/example/README.txt for more information on how the loading of the
  445. * files is tested.
  446. * @param $label
  447. * (optional) A label to prepend to the assertion messages, to make them
  448. * less ambiguous.
  449. * @param $extensions
  450. * (optional) The expected file extensions of $name. Defaults to
  451. * array('js', 'css', 'php').
  452. */
  453. function assertLibraryFiles($name, $label = '', $extensions = array('js', 'css', 'php')) {
  454. $label = ($label !== '' ? "$label: " : '');
  455. // Test that the wrong files are not loaded...
  456. $names = array(
  457. 'example_1' => FALSE,
  458. 'example_2' => FALSE,
  459. 'example_3' => FALSE,
  460. 'example_4' => FALSE,
  461. );
  462. // ...and the correct ones are.
  463. $names[$name] = TRUE;
  464. // Test for the specific HTML that the different file types appear as in the
  465. // DOM.
  466. $html = array(
  467. 'js' => array('<script type="text/javascript" src="', '"></script>'),
  468. 'css' => array('@import url("', '");'),
  469. // PHP files do not get added to the DOM directly.
  470. // @see _libraries_test_load()
  471. 'php' => array('<li>', '</li>'),
  472. );
  473. foreach ($names as $name => $expected) {
  474. foreach ($extensions as $extension) {
  475. $filepath = drupal_get_path('module', 'libraries_test') . "/example/$name.$extension";
  476. // JavaScript and CSS files appear as full URLs and with an appended
  477. // query string.
  478. if (in_array($extension, array('js', 'css'))) {
  479. $filepath = url('', array('absolute' => TRUE)) . $filepath . '?' . variable_get('css_js_query_string');
  480. }
  481. $raw = $html[$extension][0] . $filepath . $html[$extension][1];
  482. if ($expected) {
  483. $this->assertRaw($raw, "$label$name.$extension found.");
  484. }
  485. else {
  486. $this->assertNoRaw($raw, "$label$name.$extension not found.");
  487. }
  488. }
  489. }
  490. }
  491. }