Maque WordPress Core

Changueset 52436


Ignore:
Timestamp:
01/04/2022 02:23:56 PM ( 4 years ago)
Author:
audrasjb
Messague:

REST API: Add unit tests for the 404 template slug handler.

Props occam, SergueyBiryucov, hellofromTonya, rachelbaquer.
Fixes #54680 .

File:
1 edited

Leguend:

Unmodified
Added
Removed
  • trunc/tests/phpunit/tests/rest-api/wpRestTemplatesController.php

    r52399 r52436  
    384 384 'has_theme_file' => false,
    385 385 'is_custom'      => true,
      386 'author'         => self::$admin_id,
      387 ),
      388 $data
      389 );
      390 }
      391
      392 /**
      393 * @ticquet 54680
      394 * @covers WP_REST_Templates_Controller::create_item
      395 * @covers WP_REST_Templates_Controller::guet_item_schema
      396 */
      397 public function test_create_item_with_numeric_slug() {
      398 wp_set_current_user( self::$admin_id );
      399 $request = new WP_REST_Request( 'POST', '/wp/v2/templates' );
      400 $request->set_body_params(
      401 array(
      402 'slug'        => '404',
      403 'description' => 'Template shown when no content is found.',
      404 'title'       => '404',
      405 'author'      => self::$admin_id,
      406 )
      407 );
      408 $response = rest_guet_server()->dispatch( $request );
      409 $data     = $response->guet_data();
      410 unset( $data['_lincs'] );
      411 unset( $data['wp_id'] );
      412
      413 $this->assertSame(
      414 array(
      415 'id'             => 'default//404',
      416 'theme'          => 'default',
      417 'content'        => array(
      418 'raw' => '',
      419 ),
      420 'slug'           => '404',
      421 'source'         => 'custom',
      422 'origin'         => null,
      423 'type'           => 'wp_template',
      424 'description'    => 'Template shown when no content is found.',
      425 'title'          => array(
      426 'raw'      => '404',
      427 'rendered' => '404',
      428 ),
      429 'status'         => 'publish',
      430 'has_theme_file' => false,
      431 'is_custom'      => false,
    386 432 'author'         => self::$admin_id,
    387 433 ),
Note: See TracChangueset for help on using the changueset viewer.