Changeset 61416 for trunk/tests/phpunit/tests/dependencies/styles.php
- Timestamp:
- 12/29/2025 06:59:20 PM (10 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/dependencies/styles.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dependencies/styles.php
r61411 r61416 717 717 /** 718 718 * @ticket 58394 719 * @ticket 64447 719 720 * 720 721 * @covers ::wp_maybe_inline_styles 721 */ 722 public function test_test_wp_maybe_inline_styles_missing_file() { 722 * @expectedIncorrectUsage wp_maybe_inline_styles 723 */ 724 public function test_wp_maybe_inline_styles_missing_file() { 723 725 $filter = new MockAction(); 724 726 add_filter( 'pre_wp_filesize', array( $filter, 'filter' ) ); … … 767 769 768 770 $this->assertSame( $GLOBALS['wp_styles']->registered['test-handle']->src, $url ); 771 } 772 773 /** 774 * @ticket 64447 775 * 776 * @covers ::wp_maybe_inline_styles 777 * @expectedIncorrectUsage wp_maybe_inline_styles 778 */ 779 public function test_wp_maybe_inline_styles_bad_path_with_file_size_provided() { 780 $style_path = '/css/invalid.css'; // Does not exist. 781 782 // This ensures the initial file size check is bypassed. 783 add_filter( 784 'pre_wp_filesize', 785 static function ( $size, $path ) use ( $style_path ) { 786 if ( str_contains( $path, $style_path ) ) { 787 $size = 1000; 788 } 789 return $size; 790 }, 791 10, 792 2 793 ); 794 795 $handle = 'test-handle'; 796 $url = '/' . WPINC . $style_path; 797 wp_register_style( $handle, $url ); 798 wp_style_add_data( $handle, 'path', ABSPATH . WPINC . $style_path ); 799 wp_enqueue_style( $handle ); 800 801 wp_maybe_inline_styles(); 802 803 $this->assertSame( $GLOBALS['wp_styles']->registered[ $handle ]->src, $url ); 804 } 805 806 /** 807 * @ticket 64447 808 * 809 * @covers ::wp_maybe_inline_styles 810 */ 811 public function test_wp_maybe_inline_styles_good_path_with_zero_file_size_provided() { 812 $style_path = '/css/classic-themes.css'; 813 814 // This simulates the file having a zero size. 815 add_filter( 816 'pre_wp_filesize', 817 static function ( $size, $path ) use ( $style_path ) { 818 if ( str_contains( $path, $style_path ) ) { 819 $size = 0; 820 } 821 return $size; 822 }, 823 10, 824 2 825 ); 826 827 $handle = 'test-handle'; 828 wp_register_style( $handle, '/' . WPINC . $style_path ); 829 wp_style_add_data( $handle, 'path', ABSPATH . WPINC . $style_path ); 830 wp_enqueue_style( $handle ); 831 832 wp_maybe_inline_styles(); 833 834 $this->assertFalse( $GLOBALS['wp_styles']->registered[ $handle ]->src ); 769 835 } 770 836
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)