WordPress.org

Make WordPress Core

Ticket #38975: 38975.diff

File 38975.diff, 3.8 KB (added by jnylen0, 4 years ago)
  • tests/phpunit/tests/rest-api/rest-posts-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-posts-controller.php b/tests/phpunit/tests/rest-api/rest-posts-controller.php
    index 26af946..0c043dd 100644
    a b class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te 
    16081608                $this->assertEquals( $params['excerpt'], $post->post_excerpt );
    16091609        }
    16101610
     1611        public function test_update_item_no_change() {
     1612                wp_set_current_user( self::$editor_id );
     1613                $post = get_post( self::$post_id );
     1614
     1615                $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/posts/%d', self::$post_id ) );
     1616                $request->set_param( 'author', $post->post_author );
     1617
     1618                // Run twice to make sure that the update still succeeds even if no DB
     1619                // rows are updated.
     1620                $response = $this->server->dispatch( $request );
     1621                $this->check_update_post_response( $response );
     1622
     1623                $response = $this->server->dispatch( $request );
     1624                $this->check_update_post_response( $response );
     1625        }
     1626
    16111627        public function test_rest_update_post() {
    16121628                wp_set_current_user( self::$editor_id );
    16131629
  • tests/phpunit/tests/rest-api/rest-tags-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-tags-controller.php b/tests/phpunit/tests/rest-api/rest-tags-controller.php
    index 4c461d3..bdca9cb 100644
    a b class WP_Test_REST_Tags_Controller extends WP_Test_REST_Controller_Testcase { 
    554554                $this->assertEquals( 'new-slug', $data['slug'] );
    555555        }
    556556
     557        public function test_update_item_no_change() {
     558                wp_set_current_user( self::$administrator );
     559                $term = get_term_by( 'id', $this->factory->tag->create(), 'post_tag' );
     560
     561                $request = new WP_REST_Request( 'PUT', '/wp/v2/tags/' . $term->term_id );
     562
     563                $response = $this->server->dispatch( $request );
     564                $this->assertEquals( 200, $response->get_status() );
     565                $request->set_param( 'slug', $term->slug );
     566
     567                // Run twice to make sure that the update still succeeds even if no DB
     568                // rows are updated.
     569                $response = $this->server->dispatch( $request );
     570                $this->assertEquals( 200, $response->get_status() );
     571
     572                $response = $this->server->dispatch( $request );
     573                $this->assertEquals( 200, $response->get_status() );
     574        }
     575
    557576        public function test_update_item_invalid_term() {
    558577                wp_set_current_user( self::$administrator );
    559578                $request = new WP_REST_Request( 'POST', '/wp/v2/tags/' . REST_TESTS_IMPOSSIBLY_HIGH_NUMBER );
  • tests/phpunit/tests/rest-api/rest-users-controller.php

    diff --git a/tests/phpunit/tests/rest-api/rest-users-controller.php b/tests/phpunit/tests/rest-api/rest-users-controller.php
    index 8da864f..62da922 100644
    a b class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase { 
    10871087                $this->assertEquals( $pw_before, $user->user_pass );
    10881088        }
    10891089
     1090        public function test_update_item_no_change() {
     1091                $this->allow_user_to_manage_multisite();
     1092                wp_set_current_user( self::$user );
     1093                $user = get_userdata( self::$editor );
     1094
     1095                $request = new WP_REST_Request( 'PUT', sprintf( '/wp/v2/users/%d', self::$editor ) );
     1096                $request->set_param( 'slug', $user->user_nicename );
     1097
     1098                // Run twice to make sure that the update still succeeds even if no DB
     1099                // rows are updated.
     1100                $response = $this->server->dispatch( $request );
     1101                $this->assertEquals( 200, $response->get_status() );
     1102
     1103                $response = $this->server->dispatch( $request );
     1104                $this->assertEquals( 200, $response->get_status() );
     1105        }
     1106
    10901107        public function test_update_item_existing_email() {
    10911108                $user1 = $this->factory->user->create( array( 'user_login' => 'test_json_user', 'user_email' => 'testjson@example.com' ) );
    10921109                $user2 = $this->factory->user->create( array( 'user_login' => 'test_json_user2', 'user_email' => 'testjson2@example.com' ) );