Index: tests/phpunit/tests/multisite/network-admin/sites.php =================================================================== --- tests/phpunit/tests/multisite/network-admin/sites.php (revision 0) +++ tests/phpunit/tests/multisite/network-admin/sites.php (working copy) @@ -0,0 +1,71 @@ + Sites in multisite. + * + * @group ms-site + * @group multisite + */ +class Tests_Multisite_Network_Admin_Sites extends WP_UnitTestCase { + + function setUp() { + set_current_screen( 'sites-network' ); + $GLOBALS['hook_suffix'] = ''; + $this->table = _get_list_table( 'WP_MS_Sites_List_Table' ); + + parent::setUp(); + } + + /** + * @ticket 33185 + * @dataProvider data_site_searches + */ + public function test_site_searches_match_expected_results( $search, $matches ) { + + $blogs = array(); + $paths = array( + 'abc123', + 'three', + ); + + $this->assertSame( 1, count( wp_get_sites() ) ); + + foreach ( $paths as $path ) { + $i = $this->factory->blog->create( array( + 'path' => "/{$path}/", + ) ); + $blogs[ $i ] = $path; + } + + $_GET['s'] = $_REQUEST['s'] = $search; + + $this->table->prepare_items(); + + $expected = array_keys( array_intersect( $blogs, $matches ) ); + $this->assertEquals( $expected, wp_list_pluck( $this->table->items, 'blog_id' ) ); + + } + + public function data_site_searches() { + return array( + array( + 'bc', + array( + 'abc123', + ), + ), + array( + '3', + array( + 'abc123', + 'three', + ), + ), + ); + } + +} + +endif;