Make WordPress Core

Changeset 59869


Ignore:
Timestamp:
02/25/2025 10:05:12 PM (19 months ago)
Author:
audrasjb
Message:

Build/Test Tools: Add tests for theme-related body classes.

This changeset adds new unit test cases following [59698].

Props sukhendu2002.
Fixes #19736.

Location:
trunk/tests/phpunit/tests
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/getBodyClass.php

    r59689 r59869  
    259259                $this->assertContains( "page-id-{$page_id}", $class );
    260260        }
     261
     262        /**
     263         * Test theme-related body classes.
     264         *
     265         * @ticket 19736
     266         */
     267        public function test_theme_body_classes() {
     268                $original_theme = wp_get_theme();
     269
     270                switch_theme( 'block-theme' );
     271                do_action( 'setup_theme' );
     272                do_action( 'after_setup_theme' );
     273
     274                $classes = get_body_class();
     275                $this->assertContains( 'wp-theme-block-theme', $classes, 'Parent theme body class not found' );
     276
     277                switch_theme( 'block-theme-child' );
     278                do_action( 'setup_theme' );
     279                do_action( 'after_setup_theme' );
     280
     281                $classes = get_body_class();
     282                $this->assertContains( 'wp-theme-block-theme', $classes, 'Parent theme body class not found in child theme context' );
     283                $this->assertContains( 'wp-child-theme-block-theme-child', $classes, 'Child theme body class not found' );
     284
     285                switch_theme( $original_theme->get_stylesheet() );
     286                do_action( 'setup_theme' );
     287                do_action( 'after_setup_theme' );
     288        }
    261289}
Note: See TracChangeset for help on using the changeset viewer.