Make WordPress Core

Ticket #38971: 38971-test2.patch

File 38971-test2.patch, 2.6 KB (added by hnle, 8 years ago)

broken...

  • tests/phpunit/tests/rest-api/rest-comments-controller.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    10071007                update_option( 'require_name_email', 0 );
    10081008        }
    10091009
     1010        /**
     1011         * @ticket 38971
     1012         */
     1013        public function test_create_comment_empty_required_author_name_and_email_per_option_value() {
     1014                add_filter( 'rest_allow_anonymous_comments', '__return_true' );
     1015                update_option( 'require_name_email', 1 );
     1016
     1017                $params = array(
     1018                        'author_name'  => '',
     1019                        'post'    => self::$post_id,
     1020                        'content' => 'Now, I don\'t want you to worry class. These tests will have no affect on your grades. They merely determine your future social status and financial success. If any.',
     1021                );
     1022
     1023                $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1024                $request->add_header( 'content-type', 'application/json' );
     1025                $request->set_body( wp_json_encode( $params ) );
     1026
     1027                $response = $this->server->dispatch( $request );
     1028
     1029                $this->assertErrorResponse( 'rest_comment_author_data_required', $response, 400 );
     1030
     1031                update_option( 'require_name_email', 0 );
     1032        }
     1033
    10101034        public function test_create_comment_missing_required_author_name_per_option_value() {
    10111035                wp_set_current_user( self::$admin_id );
    10121036                update_option( 'require_name_email', 1 );
     
    10271051                update_option( 'require_name_email', 0 );
    10281052        }
    10291053
     1054        /**
     1055         * @ticket 38971
     1056         */
     1057        public function test_create_comment_empty_required_author_name_per_option_value() {
     1058                add_filter( 'rest_allow_anonymous_comments', '__return_true' );
     1059                update_option( 'require_name_email', 1 );
     1060
     1061                $params = array(
     1062                        'author_name'  => '',
     1063                        'post'         => self::$post_id,
     1064                        'author_email' => 'ekrabappel@springfield-elementary.edu',
     1065                        'content'      => 'Now, I don\'t want you to worry class. These tests will have no affect on your grades. They merely determine your future social status and financial success. If any.',
     1066                );
     1067
     1068                $request = new WP_REST_Request( 'POST', '/wp/v2/comments' );
     1069                $request->add_header( 'content-type', 'application/json' );
     1070                $request->set_body( wp_json_encode( $params ) );
     1071
     1072                $response = $this->server->dispatch( $request );
     1073                $this->assertErrorResponse( 'rest_comment_author_required', $response, 400 );
     1074
     1075                update_option( 'require_name_email', 0 );
     1076        }
     1077
    10301078        public function test_create_comment_missing_required_author_email_per_option_value() {
    10311079                wp_set_current_user( self::$admin_id );
    10321080                update_option( 'require_name_email', 1 );