Changeset 48151 for trunk/tests/phpunit/tests/admin/includesListTable.php
- Timestamp:
- 06/23/2020 11:13:35 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/admin/includesListTable.php
r47122 r48151 294 294 $this->assertNotContains( 'id="delete_all"', $output ); 295 295 } 296 297 /** 298 * @ticket 45089 299 */ 300 public function test_sortable_columns() { 301 require_once ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php'; 302 303 $override_sortable_columns = array( 304 'author' => array( 'comment_author', true ), 305 'response' => 'comment_post_ID', 306 'date' => array( 'comment_date', 'dEsC' ), // The ordering support should be case insensitive. 307 ); 308 309 // Stub the get_sortable_columns() method. 310 $object = $this->getMockBuilder( 'WP_Comments_List_Table' ) 311 ->setConstructorArgs( array( array( 'screen' => 'edit-comments' ) ) ) 312 ->setMethods( array( 'get_sortable_columns' ) ) 313 ->getMock(); 314 315 // Change the null return value of the stubbed get_sortable_columns() method. 316 $object->method( 'get_sortable_columns' ) 317 ->willReturn( $override_sortable_columns ); 318 319 $output = get_echo( array( $object, 'print_column_headers' ) ); 320 321 $this->assertContains( '?orderby=comment_author&order=desc', $output, 'Mismatch of the default link ordering for comment author column. Should be desc.' ); 322 $this->assertContains( 'column-author sortable asc', $output, 'Mismatch of CSS classes for the comment author column.' ); 323 324 $this->assertContains( '?orderby=comment_post_ID&order=asc', $output, 'Mismatch of the default link ordering for comment response column. Should be asc.' ); 325 $this->assertContains( 'column-response sortable desc', $output, 'Mismatch of CSS classes for the comment post ID column.' ); 326 327 $this->assertContains( '?orderby=comment_date&order=asc', $output, 'Mismatch of the default link ordering for comment author column. Should be asc.' ); 328 $this->assertContains( 'column-date sortable desc', $output, 'Mismatch of CSS classes for the comment date column.' ); 329 } 330 331 /** 332 * @ticket 45089 333 */ 334 public function test_sortable_columns_with_current_ordering() { 335 require_once ABSPATH . 'wp-admin/includes/class-wp-comments-list-table.php'; 336 337 $override_sortable_columns = array( 338 'author' => array( 'comment_author', false ), 339 'response' => 'comment_post_ID', 340 'date' => array( 'comment_date', 'asc' ), // We will override this with current ordering. 341 ); 342 343 // Current ordering. 344 $_GET['orderby'] = 'comment_date'; 345 $_GET['order'] = 'desc'; 346 347 // Stub the get_sortable_columns() method. 348 $object = $this->getMockBuilder( 'WP_Comments_List_Table' ) 349 ->setConstructorArgs( array( array( 'screen' => 'edit-comments' ) ) ) 350 ->setMethods( array( 'get_sortable_columns' ) ) 351 ->getMock(); 352 353 // Change the null return value of the stubbed get_sortable_columns() method. 354 $object->method( 'get_sortable_columns' ) 355 ->willReturn( $override_sortable_columns ); 356 357 $output = get_echo( array( $object, 'print_column_headers' ) ); 358 359 $this->assertContains( '?orderby=comment_author&order=asc', $output, 'Mismatch of the default link ordering for comment author column. Should be asc.' ); 360 $this->assertContains( 'column-author sortable desc', $output, 'Mismatch of CSS classes for the comment author column.' ); 361 362 $this->assertContains( '?orderby=comment_post_ID&order=asc', $output, 'Mismatch of the default link ordering for comment response column. Should be asc.' ); 363 $this->assertContains( 'column-response sortable desc', $output, 'Mismatch of CSS classes for the comment post ID column.' ); 364 365 $this->assertContains( '?orderby=comment_date&order=asc', $output, 'Mismatch of the current link ordering for comment date column. Should be asc.' ); 366 $this->assertContains( 'column-date sorted desc', $output, 'Mismatch of CSS classes for the comment date column.' ); 367 } 368 296 369 }
Note: See TracChangeset
for help on using the changeset viewer.