Changeset 48937 for trunk/tests/phpunit/tests/rest-api/rest-request.php
- Timestamp:
- 09/02/2020 12:35:36 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-request.php
r48642 r48937 24 24 $this->request->set_header( 'Content-Type', $value ); 25 25 26 $this->assert Equals( $value, $this->request->get_header( 'Content-Type' ) );26 $this->assertSame( $value, $this->request->get_header( 'Content-Type' ) ); 27 27 } 28 28 … … 34 34 public function test_remove_header() { 35 35 $this->request->add_header( 'Test-Header', 'value' ); 36 $this->assert Equals( 'value', $this->request->get_header( 'Test-Header' ) );36 $this->assertSame( 'value', $this->request->get_header( 'Test-Header' ) ); 37 37 38 38 $this->request->remove_header( 'Test-Header' ); … … 46 46 $this->request->add_header( 'Accept', $value2 ); 47 47 48 $this->assert Equals( $value1 . ',' . $value2, $this->request->get_header( 'Accept' ) );49 $this->assert Equals( array( $value1, $value2 ), $this->request->get_header_as_array( 'Accept' ) );48 $this->assertSame( $value1 . ',' . $value2, $this->request->get_header( 'Accept' ) ); 49 $this->assertSame( array( $value1, $value2 ), $this->request->get_header_as_array( 'Accept' ) ); 50 50 } 51 51 … … 67 67 */ 68 68 public function test_header_canonicalization( $original, $expected ) { 69 $this->assert Equals( $expected, $this->request->canonicalize_header_name( $original ) );69 $this->assertSame( $expected, $this->request->canonicalize_header_name( $original ) ); 70 70 } 71 71 … … 97 97 $parsed = $this->request->get_content_type(); 98 98 99 $this->assert Equals( $value, $parsed['value'] );100 $this->assert Equals( $type, $parsed['type'] );101 $this->assert Equals( $subtype, $parsed['subtype'] );102 $this->assert Equals( $parameters, $parsed['parameters'] );99 $this->assertSame( $value, $parsed['value'] ); 100 $this->assertSame( $type, $parsed['type'] ); 101 $this->assertSame( $subtype, $parsed['subtype'] ); 102 $this->assertSame( $parameters, $parsed['parameters'] ); 103 103 } 104 104 … … 145 145 146 146 // Check that query takes precedence. 147 $this->assert Equals( 'query', $this->request->get_param( 'source' ) );147 $this->assertSame( 'query', $this->request->get_param( 'source' ) ); 148 148 149 149 // Check that the correct arguments are parsed (and that falling through … … 166 166 167 167 // Check that POST takes precedence. 168 $this->assert Equals( 'body', $this->request->get_param( 'source' ) );168 $this->assertSame( 'body', $this->request->get_param( 'source' ) ); 169 169 170 170 // Check that the correct arguments are parsed (and that falling through … … 187 187 188 188 // Check that JSON takes precedence. 189 $this->assert Equals( 'json', $this->request->get_param( 'source' ) );189 $this->assertSame( 'json', $this->request->get_param( 'source' ) ); 190 190 191 191 // Check that the correct arguments are parsed (and that falling through … … 209 209 210 210 // Check that JSON is ignored. 211 $this->assert Equals( 'body', $this->request->get_param( 'source' ) );211 $this->assertSame( 'body', $this->request->get_param( 'source' ) ); 212 212 213 213 // Check that the correct arguments are parsed (and that falling through … … 253 253 $this->request->set_body( http_build_query( $data ) ); 254 254 foreach ( $data as $key => $expected_value ) { 255 $this->assert Equals( $expected_value, $this->request->get_param( $key ) );255 $this->assertSame( $expected_value, $this->request->get_param( $key ) ); 256 256 } 257 257 } … … 275 275 276 276 foreach ( $data as $key => $expected_value ) { 277 $this->assert Equals( $expected_value, $this->request->get_param( $key ) );277 $this->assertSame( $expected_value, $this->request->get_param( $key ) ); 278 278 } 279 279 } … … 297 297 298 298 foreach ( $data as $key => $expected_value ) { 299 $this->assert Equals( $expected_value, $this->request->get_param( $key ) );299 $this->assertSame( $expected_value, $this->request->get_param( $key ) ); 300 300 } 301 301 } … … 308 308 $expected = array( 309 309 'source' => 'body', 310 'has_default_params' => true, 310 311 'has_url_params' => true, 311 312 'has_query_params' => true, 312 313 'has_body_params' => true, 313 'has_default_params' => true, 314 ); 315 $this->assertEquals( $expected, $this->request->get_params() ); 314 ); 315 $this->assertSame( $expected, $this->request->get_params() ); 316 316 } 317 317 … … 327 327 '2' => 'goodbye', 328 328 ); 329 $this->assert Equals( $expected, $this->request->get_params() );329 $this->assertSame( $expected, $this->request->get_params() ); 330 330 } 331 331 … … 353 353 $this->request->sanitize_params(); 354 354 355 $this->assert Equals( 123, $this->request->get_param( 'someinteger' ) );356 $this->assert Equals( 0, $this->request->get_param( 'somestring' ) );355 $this->assertSame( 123, $this->request->get_param( 'someinteger' ) ); 356 $this->assertSame( 0, $this->request->get_param( 'somestring' ) ); 357 357 } 358 358 … … 379 379 $valid = $this->request->sanitize_params(); 380 380 $this->assertWPError( $valid ); 381 $this->assert Equals( 'rest_invalid_param', $valid->get_error_code() );381 $this->assertSame( 'rest_invalid_param', $valid->get_error_code() ); 382 382 } 383 383 … … 440 440 441 441 $this->assertWPError( $valid ); 442 $this->assert Equals( 'rest_missing_callback_param', $valid->get_error_code() );442 $this->assertSame( 'rest_missing_callback_param', $valid->get_error_code() ); 443 443 } 444 444 … … 460 460 461 461 $this->assertWPError( $valid ); 462 $this->assert Equals( 'rest_missing_callback_param', $valid->get_error_code() );462 $this->assertSame( 'rest_missing_callback_param', $valid->get_error_code() ); 463 463 464 464 $data = $valid->get_error_data( 'rest_missing_callback_param' ); … … 488 488 489 489 $this->assertWPError( $valid ); 490 $this->assert Equals( 'rest_invalid_param', $valid->get_error_code() );490 $this->assertSame( 'rest_invalid_param', $valid->get_error_code() ); 491 491 } 492 492 … … 497 497 $valid = $this->request->has_valid_params(); 498 498 $this->assertWPError( $valid ); 499 $this->assert Equals( 'rest_invalid_json', $valid->get_error_code() );499 $this->assertSame( 'rest_invalid_json', $valid->get_error_code() ); 500 500 $data = $valid->get_error_data(); 501 $this->assert Equals( JSON_ERROR_SYNTAX, $data['json_error_code'] );501 $this->assertSame( JSON_ERROR_SYNTAX, $data['json_error_code'] ); 502 502 } 503 503 … … 535 535 536 536 $this->assertWPError( $valid ); 537 $this->assert Equals( 'rest_invalid_param', $valid->get_error_code() );537 $this->assertSame( 'rest_invalid_param', $valid->get_error_code() ); 538 538 539 539 $data = $valid->get_error_data( 'rest_invalid_param' ); … … 568 568 $error_data = $valid->get_error_data(); 569 569 570 $this->assert Equals( array( 'someinteger', 'someotherparams' ), array_keys( $error_data['params'] ) );571 $this->assert Equals( 'This is not valid!', $error_data['params']['someotherparams'] );570 $this->assertSame( array( 'someinteger', 'someotherparams' ), array_keys( $error_data['params'] ) ); 571 $this->assertSame( 'This is not valid!', $error_data['params']['someotherparams'] ); 572 572 } 573 573 … … 595 595 update_option( 'permalink_structure', $permalink_structure ); 596 596 $url = add_query_arg( 'foo', 'bar', rest_url( '/wp/v2/posts/1' ) ); 597 $this->assert Equals( $original_url, $url );597 $this->assertSame( $original_url, $url ); 598 598 $request = WP_REST_Request::from_url( $url ); 599 599 $this->assertInstanceOf( 'WP_REST_Request', $request ); 600 $this->assert Equals( '/wp/v2/posts/1', $request->get_route() );600 $this->assertSame( '/wp/v2/posts/1', $request->get_route() ); 601 601 $this->assertEqualSets( 602 602 array( … … 624 624 $request = new WP_REST_Request(); 625 625 $request->set_param( 'param', 'value' ); 626 $this->assert Equals( 'value', $request->get_param( 'param' ) );626 $this->assertSame( 'value', $request->get_param( 'param' ) ); 627 627 } 628 628 … … 638 638 ) 639 639 ); 640 $this->assert Equals( 'value', $request->get_param( 'param' ) );641 $this->assert Equals(640 $this->assertSame( 'value', $request->get_param( 'param' ) ); 641 $this->assertSame( 642 642 array( 'param' => 'value' ), 643 643 $request->get_json_params() … … 645 645 646 646 $request->set_param( 'param', 'new_value' ); 647 $this->assert Equals( 'new_value', $request->get_param( 'param' ) );648 $this->assert Equals(647 $this->assertSame( 'new_value', $request->get_param( 'param' ) ); 648 $this->assertSame( 649 649 array( 'param' => 'new_value' ), 650 650 $request->get_json_params() … … 673 673 $request->set_param( 'param', 'new_value' ); 674 674 675 $this->assert Equals( 'new_value', $request->get_param( 'param' ) );676 $this->assert Equals( array(), $request->get_body_params() );677 $this->assert Equals( array( 'param' => 'new_value' ), $request->get_json_params() );678 $this->assert Equals( array( 'param' => 'new_value' ), $request->get_query_params() );675 $this->assertSame( 'new_value', $request->get_param( 'param' ) ); 676 $this->assertSame( array(), $request->get_body_params() ); 677 $this->assertSame( array( 'param' => 'new_value' ), $request->get_json_params() ); 678 $this->assertSame( array( 'param' => 'new_value' ), $request->get_query_params() ); 679 679 } 680 680 … … 705 705 $request->set_param( 'param_query', 'new_value' ); 706 706 707 $this->assert Equals( 'new_value', $request->get_param( 'param_query' ) );708 $this->assert Equals( array(), $request->get_body_params() );709 $this->assert Equals( array( 'param_body' => 'value_body' ), $request->get_json_params() );710 $this->assert Equals( array( 'param_query' => 'new_value' ), $request->get_query_params() );707 $this->assertSame( 'new_value', $request->get_param( 'param_query' ) ); 708 $this->assertSame( array(), $request->get_body_params() ); 709 $this->assertSame( array( 'param_body' => 'value_body' ), $request->get_json_params() ); 710 $this->assertSame( array( 'param_query' => 'new_value' ), $request->get_query_params() ); 711 711 // Verify the default wasn't overwritten. 712 $this->assert Equals( $original_defaults, $request->get_default_params() );712 $this->assertSame( $original_defaults, $request->get_default_params() ); 713 713 } 714 714 … … 734 734 $request->set_param( 'param', null ); 735 735 736 $this->assert Equals( null,$request->get_param( 'param' ) );737 $this->assert Equals( array(), $request->get_body_params() );738 $this->assert Equals( array( 'param' => null ), $request->get_json_params() );739 $this->assert Equals( array( 'param' => null ), $request->get_query_params() );736 $this->assertNull( $request->get_param( 'param' ) ); 737 $this->assertSame( array(), $request->get_body_params() ); 738 $this->assertSame( array( 'param' => null ), $request->get_json_params() ); 739 $this->assertSame( array( 'param' => null ), $request->get_query_params() ); 740 740 } 741 741 … … 761 761 $request->set_param( 'param', 'new_value' ); 762 762 763 $this->assert Equals( 'new_value', $request->get_param( 'param' ) );764 $this->assert Equals( array(), $request->get_body_params() );765 $this->assert Equals( array( 'param' => 'new_value' ), $request->get_json_params() );766 $this->assert Equals( array( 'param' => 'new_value' ), $request->get_query_params() );763 $this->assertSame( 'new_value', $request->get_param( 'param' ) ); 764 $this->assertSame( array(), $request->get_body_params() ); 765 $this->assertSame( array( 'param' => 'new_value' ), $request->get_json_params() ); 766 $this->assertSame( array( 'param' => 'new_value' ), $request->get_query_params() ); 767 767 } 768 768 … … 778 778 779 779 $this->assertTrue( $request->has_param( 'param' ) ); 780 $this->assert Equals( 'value', $request->get_param( 'param' ) );780 $this->assertSame( 'value', $request->get_param( 'param' ) ); 781 781 } 782 782 }
Note: See TracChangeset
for help on using the changeset viewer.