Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8f87db5
Add support to post types
talldan Nov 24, 2021
77a5e68
Add author support to templates REST API controller
talldan Nov 24, 2021
bdb04b3
Update unit tests
talldan Nov 24, 2021
0095e94
Fix linting issue
talldan Nov 25, 2021
39e5f91
Add origin field to templates
talldan Nov 25, 2021
11e1a10
Handle errors from `prepare_item_for_database` in REST templates cont…
talldan Nov 25, 2021
8888852
Update tests to support origin
talldan Nov 25, 2021
63d008a
Address review feedback
talldan Nov 25, 2021
51c768e
Linting fix
talldan Nov 25, 2021
89ea62c
Remove empty lines
talldan Nov 29, 2021
0b939f4
Update @wordpress packages
noisysocks Nov 29, 2021
36bbe07
Changes from lib/class-wp-theme-json-gutenberg.php
noisysocks Nov 29, 2021
2f870e0
Changes from lib/class-wp-theme-json-resolver-gutenberg.php
noisysocks Nov 29, 2021
b494b8e
Changes from lib/class-gutenberg-rest-global-styles-controller.php
noisysocks Nov 29, 2021
ac24a4d
Changes from lib/compat/wordpress-5.9/class-gutenberg-rest-templates-…
noisysocks Nov 29, 2021
c693450
Changes from lib/compat/wordpress-5.9/get-global-styles-and-settings.php
noisysocks Nov 29, 2021
2f4b9c0
Changes from lib/compat/wordpress-5.9/rest-active-global-styles.php
noisysocks Nov 29, 2021
a40c236
Changes from lib/full-site-editing/edit-site-page.php
noisysocks Nov 29, 2021
8177764
Changes from lib/global-styles.php
noisysocks Nov 29, 2021
d7bc3a2
Changes from phpunit/class-gutenberg-rest-template-controller-test.php
noisysocks Nov 29, 2021
0f23bca
Changes from phpunit/class-wp-theme-json-resolver-test.php
noisysocks Nov 29, 2021
7771284
Changes from phpunit/class-wp-theme-json-test.php
noisysocks Nov 29, 2021
c0cc27a
Merge remote-tracking branch 'talldan/add/author-support-to-templates…
noisysocks Nov 29, 2021
f8745dc
Move call to maybe_opt_in_into_settings() to right place
noisysocks Nov 29, 2021
fa3f5c7
Use WP class names
noisysocks Nov 29, 2021
9a4ec9f
Fix 'is_custom' assertions in PHPUnit tests
Mamaduka Nov 29, 2021
df9d23f
Update tests/phpunit/tests/rest-api/wpRestTemplatesController.php
noisysocks Nov 29, 2021
cdabd26
Update tests/phpunit/tests/rest-api/wpRestTemplatesController.php
noisysocks Nov 29, 2021
bd3461a
Update tests/phpunit/tests/rest-api/wpRestTemplatesController.php
noisysocks Nov 29, 2021
00ba632
Sort keys alphabetically so it is easier to compare
oandregal Nov 29, 2021
a633c19
Add missing appearanceTools flag
oandregal Nov 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Changes from phpunit/class-wp-theme-json-resolver-test.php
  • Loading branch information
noisysocks committed Nov 29, 2021
commit 0f23bca5cf0fb078825ec12c2ebf401772b6479c
34 changes: 34 additions & 0 deletions tests/phpunit/tests/theme/wpThemeJsonResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function set_up() {
add_filter( 'theme_root', array( $this, 'filter_set_theme_root' ) );
add_filter( 'stylesheet_root', array( $this, 'filter_set_theme_root' ) );
add_filter( 'template_root', array( $this, 'filter_set_theme_root' ) );
$this->queries = array();
// Clear caches.
wp_clean_themes_cache();
unset( $GLOBALS['wp_themes'] );
Expand All @@ -44,6 +45,13 @@ public function filter_set_locale_to_polish() {
return 'pl_PL';
}

function filter_db_query( $query ) {
if ( preg_match( '#post_type = \'wp_global_styles\'#', $query ) ) {
$this->queries[] = $query;
}
return $query;
}

/**
* @ticket 52991
* @ticket 54336
Expand Down Expand Up @@ -312,4 +320,30 @@ function test_merges_child_theme_json_into_parent_theme_json() {
)
);
}

function test_get_user_data_from_custom_post_type_does_not_use_uncached_queries() {
add_filter( 'query', array( $this, 'filter_db_query' ) );
$query_count = count( $this->queries );
for ( $i = 0; $i < 3; $i++ ) {
WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type( wp_get_theme() );
WP_Theme_JSON_Resolver::clean_cached_data();
}
$query_count = count( $this->queries ) - $query_count;
$this->assertEquals( 1, $query_count, 'Only one SQL query should be peformed for multiple invocations of WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type()' );

$user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type( wp_get_theme() );
$this->assertEmpty( $user_cpt );

$user_cpt = WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type( wp_get_theme(), true );
$this->assertNotEmpty( $user_cpt );

$query_count = count( $this->queries );
for ( $i = 0; $i < 3; $i++ ) {
WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type( wp_get_theme() );
WP_Theme_JSON_Resolver::clean_cached_data();
}
$query_count = count( $this->queries ) - $query_count;
$this->assertEquals( 0, $query_count, 'Unexpected SQL queries detected for the wp_global_style post type' );
remove_filter( 'query', array( $this, 'filter_db_query' ) );
}
}