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-gutenberg-rest-template-controller-test.php
  • Loading branch information
noisysocks committed Nov 29, 2021
commit d7bc3a217959dacac1650a239004ecdd7555d355
66 changes: 66 additions & 0 deletions tests/phpunit/tests/rest-api/wpRestTemplatesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public function test_get_items() {
'status' => 'publish',
'wp_id' => self::$post->ID,
'has_theme_file' => false,
'is_custom' => false,
),
$this->find_and_normalize_template_by_id( $data, 'default//my_template' )
);
Expand Down Expand Up @@ -143,11 +144,75 @@ public function test_get_item() {
'status' => 'publish',
'wp_id' => self::$post->ID,
'has_theme_file' => false,
'is_custom' => false,
),
$data
);
}

/**
* @ticket 54507
* @dataProvider get_template_endpoint_urls
*/
public function test_get_item_works_with_a_single_slash( $endpoint_url ) {
wp_set_current_user( self::$admin_id );
$request = new WP_REST_Request( 'GET', $endpoint_url );
$response = rest_get_server()->dispatch( $request );

$data = $response->get_data();
unset( $data['content'] );
unset( $data['_links'] );

$this->assertEquals(
array(
'id' => 'tt1-blocks//index',
'theme' => 'tt1-blocks',
'slug' => 'index',
'title' => array(
'raw' => 'Index',
'rendered' => 'Index',
),
'description' => 'The default template used when no other template is available. This is a required template in WordPress.',
'status' => 'publish',
'source' => 'theme',
'type' => 'wp_template',
'wp_id' => null,
'has_theme_file' => true,
'is_custom' => false,
),
$data
);
}

public function get_template_endpoint_urls() {
return array(
array( '/wp/v2/templates/tt1-blocks/index' ),
array( '/wp/v2/templates/tt1-blocks//index' ),
);
}

/**
* @ticket 54507
* @dataProvider get_template_ids_to_sanitize
*/
public function test_sanitize_template_id( $input_id, $sanitized_id ) {
$endpoint = new Gutenberg_REST_Templates_Controller( 'wp_template' );
$this->assertEquals(
$sanitized_id,
$endpoint->_sanitize_template_id( $input_id )
);
}

public function get_template_ids_to_sanitize() {
return array(
array( 'tt1-blocks/index', 'tt1-blocks//index' ),
array( 'tt1-blocks//index', 'tt1-blocks//index' ),

array( 'theme-experiments/tt1-blocks/index', 'theme-experiments/tt1-blocks//index' ),
array( 'theme-experiments/tt1-blocks//index', 'theme-experiments/tt1-blocks//index' ),
);
}

/**
* @ticket 54422
* @covers WP_REST_Templates_Controller::create_item
Expand Down Expand Up @@ -185,6 +250,7 @@ public function test_create_item() {
),
'status' => 'publish',
'has_theme_file' => false,
'is_custom' => true,
),
$data
);
Expand Down