- Timestamp:
- 01/24/2024 10:37:54 AM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/script-modules/wpScriptModules.php
r57327 r57345 518 518 519 519 /** 520 * Tests that it can print the enqueued script modules multiple times, and it521 * will only print the script modules that have not been printed before.522 *523 * @ticket 56313524 *525 * @covers ::register()526 * @covers ::enqueue()527 * @covers ::print_enqueued_script_modules()528 */529 public function test_print_enqueued_script_modules_can_be_called_multiple_times() {530 $this->script_modules->register( 'foo', '/foo.js' );531 $this->script_modules->register( 'bar', '/bar.js' );532 $this->script_modules->enqueue( 'foo' );533 534 $enqueued_script_modules = $this->get_enqueued_script_modules();535 $this->assertCount( 1, $enqueued_script_modules );536 $this->assertTrue( isset( $enqueued_script_modules['foo'] ) );537 538 $this->script_modules->enqueue( 'bar' );539 540 $enqueued_script_modules = $this->get_enqueued_script_modules();541 $this->assertCount( 1, $enqueued_script_modules );542 $this->assertTrue( isset( $enqueued_script_modules['bar'] ) );543 544 $enqueued_script_modules = $this->get_enqueued_script_modules();545 $this->assertCount( 0, $enqueued_script_modules );546 }547 548 /**549 * Tests that it can print the preloaded script modules multiple times, and it550 * will only print the script modules that have not been printed before.551 *552 * @ticket 56313553 *554 * @covers ::register()555 * @covers ::enqueue()556 * @covers ::print_script_module_preloads()557 */558 public function test_print_preloaded_script_modules_can_be_called_multiple_times() {559 $this->script_modules->register( 'foo', '/foo.js', array( 'static-dep-1', 'static-dep-2' ) );560 $this->script_modules->register( 'bar', '/bar.js', array( 'static-dep-3' ) );561 $this->script_modules->register( 'static-dep-1', '/static-dep-1.js' );562 $this->script_modules->register( 'static-dep-3', '/static-dep-3.js' );563 $this->script_modules->enqueue( 'foo' );564 565 $preloaded_script_modules = $this->get_preloaded_script_modules();566 $this->assertCount( 1, $preloaded_script_modules );567 $this->assertTrue( isset( $preloaded_script_modules['static-dep-1'] ) );568 569 $this->script_modules->register( 'static-dep-2', '/static-dep-2.js' );570 $this->script_modules->enqueue( 'bar' );571 572 $preloaded_script_modules = $this->get_preloaded_script_modules();573 $this->assertCount( 2, $preloaded_script_modules );574 $this->assertTrue( isset( $preloaded_script_modules['static-dep-2'] ) );575 $this->assertTrue( isset( $preloaded_script_modules['static-dep-3'] ) );576 577 $preloaded_script_modules = $this->get_preloaded_script_modules();578 $this->assertCount( 0, $preloaded_script_modules );579 }580 581 /**582 520 * Tests that a script module is not registered when calling enqueue without a 583 521 * valid src.
Note: See TracChangeset
for help on using the changeset viewer.