- 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-settings-controller.php
r48791 r48937 68 68 $request = new WP_REST_Request( 'GET', '/wp/v2/settings/title' ); 69 69 $response = rest_get_server()->dispatch( $request ); 70 $this->assert Equals( 404, $response->get_status() );70 $this->assertSame( 404, $response->get_status() ); 71 71 } 72 72 … … 77 77 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 78 78 $response = rest_get_server()->dispatch( $request ); 79 $this->assert Equals( 401, $response->get_status() );79 $this->assertSame( 401, $response->get_status() ); 80 80 } 81 81 … … 84 84 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 85 85 $response = rest_get_server()->dispatch( $request ); 86 $this->assert Equals( 403, $response->get_status() );86 $this->assertSame( 403, $response->get_status() ); 87 87 } 88 88 … … 118 118 sort( $actual ); 119 119 120 $this->assert Equals( 200, $response->get_status() );121 $this->assert Equals( $expected, $actual );120 $this->assertSame( 200, $response->get_status() ); 121 $this->assertSame( $expected, $actual ); 122 122 } 123 123 … … 129 129 $data = $response->get_data(); 130 130 131 $this->assert Equals( 200, $response->get_status() );132 $this->assert Equals( 1, $data['posts_per_page'] );131 $this->assertSame( 200, $response->get_status() ); 132 $this->assertSame( 1, $data['posts_per_page'] ); 133 133 } 134 134 … … 155 155 $data = $response->get_data(); 156 156 157 $this->assert Equals( 200, $response->get_status() );157 $this->assertSame( 200, $response->get_status() ); 158 158 $this->assertArrayHasKey( 'mycustomsettinginrest', $data ); 159 $this->assert Equals( 'validvalue1', $data['mycustomsettinginrest'] );159 $this->assertSame( 'validvalue1', $data['mycustomsettinginrest'] ); 160 160 161 161 update_option( 'mycustomsetting', 'validvalue2' ); … … 164 164 $response = rest_get_server()->dispatch( $request ); 165 165 $data = $response->get_data(); 166 $this->assert Equals( 'validvalue2', $data['mycustomsettinginrest'] );166 $this->assertSame( 'validvalue2', $data['mycustomsettinginrest'] ); 167 167 } 168 168 … … 191 191 $response = rest_get_server()->dispatch( $request ); 192 192 $data = $response->get_data(); 193 $this->assert Equals( array( 1, 2 ), $data['mycustomsetting'] );193 $this->assertSame( array( 1, 2 ), $data['mycustomsetting'] ); 194 194 195 195 // Empty array works as expected. … … 198 198 $response = rest_get_server()->dispatch( $request ); 199 199 $data = $response->get_data(); 200 $this->assert Equals( array(), $data['mycustomsetting'] );200 $this->assertSame( array(), $data['mycustomsetting'] ); 201 201 202 202 // Invalid value. … … 205 205 $response = rest_get_server()->dispatch( $request ); 206 206 $data = $response->get_data(); 207 $this->assert Equals( null,$data['mycustomsetting'] );207 $this->assertNull( $data['mycustomsetting'] ); 208 208 209 209 // No option value. … … 212 212 $response = rest_get_server()->dispatch( $request ); 213 213 $data = $response->get_data(); 214 $this->assert Equals( null,$data['mycustomsetting'] );214 $this->assertNull( $data['mycustomsetting'] ); 215 215 } 216 216 … … 245 245 $response = rest_get_server()->dispatch( $request ); 246 246 $data = $response->get_data(); 247 $this->assert Equals( array( 'a' => 1 ), $data['mycustomsetting'] );247 $this->assertSame( array( 'a' => 1 ), $data['mycustomsetting'] ); 248 248 249 249 // Empty array works as expected. … … 252 252 $response = rest_get_server()->dispatch( $request ); 253 253 $data = $response->get_data(); 254 $this->assert Equals( array(), $data['mycustomsetting'] );254 $this->assertSame( array(), $data['mycustomsetting'] ); 255 255 256 256 // Invalid value. … … 265 265 $response = rest_get_server()->dispatch( $request ); 266 266 $data = $response->get_data(); 267 $this->assert Equals( null,$data['mycustomsetting'] );267 $this->assertNull( $data['mycustomsetting'] ); 268 268 } 269 269 … … 310 310 $data = $response->get_data(); 311 311 312 $this->assert Equals( 200, $response->get_status() );312 $this->assertSame( 200, $response->get_status() ); 313 313 314 314 $this->assertArrayHasKey( 'mycustomsettinginrest1', $data ); 315 $this->assert Equals( 'unfiltered1', $data['mycustomsettinginrest1'] );315 $this->assertSame( 'unfiltered1', $data['mycustomsettinginrest1'] ); 316 316 317 317 $this->assertArrayHasKey( 'mycustomsettinginrest2', $data ); 318 $this->assert Equals( 'unfiltered2', $data['mycustomsettinginrest2'] );318 $this->assertSame( 'unfiltered2', $data['mycustomsettinginrest2'] ); 319 319 320 320 remove_all_filters( 'rest_pre_get_setting' ); … … 344 344 $response = rest_get_server()->dispatch( $request ); 345 345 $data = $response->get_data(); 346 $this->assert Equals( null,$data['mycustomsettinginrest'] );346 $this->assertNull( $data['mycustomsettinginrest'] ); 347 347 } 348 348 … … 370 370 $response = rest_get_server()->dispatch( $request ); 371 371 $data = $response->get_data(); 372 $this->assert Equals( null,$data['mycustomsettinginrest'] );372 $this->assertNull( $data['mycustomsettinginrest'] ); 373 373 } 374 374 … … 384 384 $data = $response->get_data(); 385 385 386 $this->assert Equals( 200, $response->get_status() );387 $this->assert Equals( 'The new title!', $data['title'] );388 $this->assert Equals( get_option( 'blogname' ), $data['title'] );386 $this->assertSame( 200, $response->get_status() ); 387 $this->assertSame( 'The new title!', $data['title'] ); 388 $this->assertSame( get_option( 'blogname' ), $data['title'] ); 389 389 } 390 390 … … 424 424 $response = rest_get_server()->dispatch( $request ); 425 425 $data = $response->get_data(); 426 $this->assert Equals( array( 1, 2 ), $data['mycustomsetting'] );427 $this->assert Equals( array( 1, 2 ), get_option( 'mycustomsetting' ) );426 $this->assertSame( array( 1, 2 ), $data['mycustomsetting'] ); 427 $this->assertSame( array( 1, 2 ), get_option( 'mycustomsetting' ) ); 428 428 429 429 // Setting an empty array. … … 432 432 $response = rest_get_server()->dispatch( $request ); 433 433 $data = $response->get_data(); 434 $this->assert Equals( array(), $data['mycustomsetting'] );435 $this->assert Equals( array(), get_option( 'mycustomsetting' ) );434 $this->assertSame( array(), $data['mycustomsetting'] ); 435 $this->assertSame( array(), get_option( 'mycustomsetting' ) ); 436 436 437 437 // Setting an invalid array. … … 514 514 $response = rest_get_server()->dispatch( $request ); 515 515 $data = $response->get_data(); 516 $this->assert Equals( array( 'a' => 1 ), $data['mycustomsetting'] );517 $this->assert Equals( array( 'a' => 1 ), get_option( 'mycustomsetting' ) );516 $this->assertSame( array( 'a' => 1 ), $data['mycustomsetting'] ); 517 $this->assertSame( array( 'a' => 1 ), get_option( 'mycustomsetting' ) ); 518 518 519 519 // Setting an empty object. … … 522 522 $response = rest_get_server()->dispatch( $request ); 523 523 $data = $response->get_data(); 524 $this->assert Equals( array(), $data['mycustomsetting'] );525 $this->assert Equals( array(), get_option( 'mycustomsetting' ) );524 $this->assertSame( array(), $data['mycustomsetting'] ); 525 $this->assertSame( array(), get_option( 'mycustomsetting' ) ); 526 526 527 527 // Provide more keys. … … 553 553 $response = rest_get_server()->dispatch( $request ); 554 554 $data = $response->get_data(); 555 $this->assert Equals( 200, $response->get_status() );556 $this->assert Equals( 'The old title!', $data['title'] );557 $this->assert Equals( 'The old description!', $data['description'] );558 $this->assert Equals( get_option( 'blogname' ), $data['title'] );559 $this->assert Equals( get_option( 'blogdescription' ), $data['description'] );555 $this->assertSame( 200, $response->get_status() ); 556 $this->assertSame( 'The old title!', $data['title'] ); 557 $this->assertSame( 'The old description!', $data['description'] ); 558 $this->assertSame( get_option( 'blogname' ), $data['title'] ); 559 $this->assertSame( get_option( 'blogdescription' ), $data['description'] ); 560 560 561 561 add_filter( 'rest_pre_update_setting', array( $this, 'update_setting_custom_callback' ), 10, 4 ); … … 567 567 $data = $response->get_data(); 568 568 569 $this->assert Equals( 200, $response->get_status() );570 $this->assert Equals( 'The old title!', $data['title'] );571 $this->assert Equals( 'The new description!', $data['description'] );572 $this->assert Equals( get_option( 'blogname' ), $data['title'] );573 $this->assert Equals( get_option( 'blogdescription' ), $data['description'] );569 $this->assertSame( 200, $response->get_status() ); 570 $this->assertSame( 'The old title!', $data['title'] ); 571 $this->assertSame( 'The new description!', $data['description'] ); 572 $this->assertSame( get_option( 'blogname' ), $data['title'] ); 573 $this->assertSame( get_option( 'blogdescription' ), $data['description'] ); 574 574 575 575 remove_all_filters( 'rest_pre_update_setting' ); … … 589 589 $request->set_param( 'posts_per_page', 11 ); 590 590 $response = rest_get_server()->dispatch( $request ); 591 $this->assert Equals( 200, $response->get_status() );591 $this->assertSame( 200, $response->get_status() ); 592 592 } 593 593 … … 612 612 $data = $response->get_data(); 613 613 614 $this->assert Equals( 200, $response->get_status() );615 $this->assert Equals( 10, $data['posts_per_page'] );614 $this->assertSame( 200, $response->get_status() ); 615 $this->assertSame( 10, $data['posts_per_page'] ); 616 616 } 617 617 … … 651 651 $request = new WP_REST_Request( 'DELETE', '/wp/v2/settings/title' ); 652 652 $response = rest_get_server()->dispatch( $request ); 653 $this->assert Equals( 404, $response->get_status() );653 $this->assertSame( 404, $response->get_status() ); 654 654 } 655 655
Note: See TracChangeset
for help on using the changeset viewer.