- Timestamp:
- 07/07/2021 10:32:56 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r51137 r51367 269 269 $response = rest_get_server()->dispatch( $request ); 270 270 $this->assertSame( 200, $response->get_status() ); 271 $this->assert Same( $total_posts, count( $response->get_data()) );271 $this->assertCount( $total_posts, $response->get_data() ); 272 272 273 273 // Limit to editor and author. … … 277 277 $this->assertSame( 200, $response->get_status() ); 278 278 $data = $response->get_data(); 279 $this->assert Same( 2, count( $data ));279 $this->assertCount( 2, $data ); 280 280 $this->assertSameSets( array( self::$editor_id, self::$author_id ), wp_list_pluck( $data, 'author' ) ); 281 281 … … 286 286 $this->assertSame( 200, $response->get_status() ); 287 287 $data = $response->get_data(); 288 $this->assert Same( 1, count( $data ));288 $this->assertCount( 1, $data ); 289 289 $this->assertSame( self::$editor_id, $data[0]['author'] ); 290 290 } … … 301 301 $response = rest_get_server()->dispatch( $request ); 302 302 $this->assertSame( 200, $response->get_status() ); 303 $this->assert Same( $total_posts, count( $response->get_data()) );303 $this->assertCount( $total_posts, $response->get_data() ); 304 304 305 305 // Exclude editor and author. … … 310 310 $this->assertSame( 200, $response->get_status() ); 311 311 $data = $response->get_data(); 312 $this->assert Same( $total_posts - 2, count( $data ));312 $this->assertCount( $total_posts - 2, $data ); 313 313 $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); 314 314 $this->assertNotEquals( self::$author_id, $data[0]['author'] ); … … 321 321 $this->assertSame( 200, $response->get_status() ); 322 322 $data = $response->get_data(); 323 $this->assert Same( $total_posts - 1, count( $data ));323 $this->assertCount( $total_posts - 1, $data ); 324 324 $this->assertNotEquals( self::$editor_id, $data[0]['author'] ); 325 325 $this->assertNotEquals( self::$editor_id, $data[1]['author'] ); … … 352 352 $response = rest_get_server()->dispatch( $request ); 353 353 $data = $response->get_data(); 354 $this->assert Same( 2, count( $data ));354 $this->assertCount( 2, $data ); 355 355 $this->assertSame( $id2, $data[0]['id'] ); 356 356 $this->assertPostsOrderedBy( '{posts}.post_date DESC' ); … … 360 360 $response = rest_get_server()->dispatch( $request ); 361 361 $data = $response->get_data(); 362 $this->assert Same( 2, count( $data ));362 $this->assertCount( 2, $data ); 363 363 $this->assertSame( $id1, $data[0]['id'] ); 364 364 $this->assertPostsOrderedBy( "FIELD({posts}.ID,$id1,$id2)" ); … … 510 510 $request->set_param( 'per_page', self::$per_page ); 511 511 $response = rest_get_server()->dispatch( $request ); 512 $this->assert Same( $total_posts, count( $response->get_data()) );512 $this->assertCount( $total_posts, $response->get_data() ); 513 513 514 514 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 516 516 $response = rest_get_server()->dispatch( $request ); 517 517 $data = $response->get_data(); 518 $this->assert Same( 1, count( $data ));518 $this->assertCount( 1, $data ); 519 519 $this->assertSame( 'Search Result', $data[0]['title']['rendered'] ); 520 520 } … … 539 539 $this->assertSame( 200, $response->get_status() ); 540 540 $data = $response->get_data(); 541 $this->assert Same( 1, count( $data ));541 $this->assertCount( 1, $data ); 542 542 $this->assertSame( 'Apple', $data[0]['title']['rendered'] ); 543 543 } … … 568 568 $this->assertSame( 200, $response->get_status() ); 569 569 $data = $response->get_data(); 570 $this->assert Same( 2, count( $data ));570 $this->assertCount( 2, $data ); 571 571 $titles = array( 572 572 $data[0]['title']['rendered'], … … 602 602 $this->assertSame( 200, $response->get_status() ); 603 603 $data = $response->get_data(); 604 $this->assert Same( 2, count( $data ));604 $this->assertCount( 2, $data ); 605 605 $titles = array( 606 606 $data[0]['title']['rendered'], … … 621 621 $response = rest_get_server()->dispatch( $request ); 622 622 $this->assertSame( 200, $response->get_status() ); 623 $this->assert Same( self::$total_posts, count( $response->get_data()) );623 $this->assertCount( self::$total_posts, $response->get_data() ); 624 624 625 625 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); … … 634 634 $response = rest_get_server()->dispatch( $request ); 635 635 $this->assertSame( 200, $response->get_status() ); 636 $this->assert Same( 1, count( $response->get_data()) );636 $this->assertCount( 1, $response->get_data() ); 637 637 } 638 638 … … 651 651 $this->assertSame( 200, $response->get_status() ); 652 652 $data = $response->get_data(); 653 $this->assert Same( 2, count( $data ));653 $this->assertCount( 2, $data ); 654 654 $statuses = array( 655 655 $data[0]['status'], … … 674 674 $this->assertSame( 200, $response->get_status() ); 675 675 $data = $response->get_data(); 676 $this->assert Same( 2, count( $data ));676 $this->assertCount( 2, $data ); 677 677 $statuses = array( 678 678 $data[0]['status'], … … 4168 4168 $data = $response->get_data(); 4169 4169 $properties = $data['schema']['properties']; 4170 $this->assert Same( 26, count( $properties ));4170 $this->assertCount( 26, $properties ); 4171 4171 $this->assertArrayHasKey( 'author', $properties ); 4172 4172 $this->assertArrayHasKey( 'comment_status', $properties );
Note: See TracChangeset
for help on using the changeset viewer.