Make WordPress Core

Ticket #33185: 33185.tests.patch

File 33185.tests.patch, 1.6 KB (added by johnbillion, 8 years ago)
  • tests/phpunit/tests/multisite/network-admin/sites.php

     
     1<?php
     2
     3if ( is_multisite() ) :
     4
     5/**
     6 * Tests specific to Network Admin -> Sites in multisite.
     7 *
     8 * @group ms-site
     9 * @group multisite
     10 */
     11class Tests_Multisite_Network_Admin_Sites extends WP_UnitTestCase {
     12
     13        function setUp() {
     14                set_current_screen( 'sites-network' );
     15                $GLOBALS['hook_suffix'] = '';
     16                $this->table = _get_list_table( 'WP_MS_Sites_List_Table' );
     17
     18                parent::setUp();
     19        }
     20
     21        /**
     22         * @ticket 33185
     23         * @dataProvider data_site_searches
     24         */
     25        public function test_site_searches_match_expected_results( $search, $matches ) {
     26
     27                $blogs = array();
     28                $paths = array(
     29                        'abc123',
     30                        'three',
     31                );
     32
     33                $this->assertSame( 1, count( wp_get_sites() ) );
     34
     35                foreach ( $paths as $path ) {
     36                        $i = $this->factory->blog->create( array(
     37                                'path' => "/{$path}/",
     38                        ) );
     39                        $blogs[ $i ] = $path;
     40                }
     41
     42                $_GET['s'] = $_REQUEST['s'] = $search;
     43
     44                $this->table->prepare_items();
     45
     46                $expected = array_keys( array_intersect( $blogs, $matches ) );
     47                $this->assertEquals( $expected, wp_list_pluck( $this->table->items, 'blog_id' ) );
     48
     49        }
     50
     51        public function data_site_searches() {
     52                return array(
     53                        array(
     54                                'bc',
     55                                array(
     56                                        'abc123',
     57                                ),
     58                        ),
     59                        array(
     60                                '3',
     61                                array(
     62                                        'abc123',
     63                                        'three',
     64                                ),
     65                        ),
     66                );
     67        }
     68
     69}
     70
     71endif;