Skip to content

Commit

Permalink
Add tests for get_theme_data()
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Oct 16, 2022
1 parent 012ac0d commit 3a24d08
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions tests/phpunit/tests/theme/wpThemeJsonResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -694,13 +694,27 @@ function test_get_user_data_from_wp_global_styles_filter_state() {
$this->assertSameSets( array(), $post2 );
}

function test_get_core_data() {
$theme_json = WP_Theme_JSON_Resolver::get_core_data();
$this->assertIsObject( $theme_json );
$core_data = $theme_json->get_raw_data();
$this->assertIsArray( $core_data );
$this->assertArrayHasKey( 'version', $core_data );
$this->assertArrayHasKey( 'settings', $core_data );
$this->assertArrayHasKey( 'styles', $core_data );

/**
* @ticket 56835
* @covers WP_Theme_JSON_Resolver::get_theme_data
*/
function test_get_theme_data_theme_supports_overrides_theme_json() {
// Test that get_theme_data() returns a WP_Theme_JSON object.
$theme_json_resolver = new WP_Theme_JSON_Resolver();
$theme_data = $theme_json_resolver->get_theme_data();
$this->assertInstanceOf( 'WP_Theme_JSON', $theme_data );

// Test that wp_theme_json_data_theme filter has been called.
$this->assertGreaterThan( 0, did_filter( 'wp_theme_json_data_default' ) );

// Test that data from theme.json must be backfilled from existing theme supports.
$previous_settings = $theme_data->get_settings();
$previous_line_height = $previous_settings['typography']['lineHeight'];
$this->assertFalse( $previous_line_height );
add_theme_support( 'custom-line-height' );
$current_settings = $theme_json_resolver->get_theme_data()->get_settings();
$line_height = $current_settings['typography']['lineHeight'];
$this->assertTrue( $line_height );
}
}

0 comments on commit 3a24d08

Please sign in to comment.