Make WordPress Core


Ignore:
Timestamp:
06/16/2016 11:08:30 PM (10 years ago)
Author:
jeremyfelt
Message:

Multisite: Add search column support to WP_Site_Query.

domain and/or path can be used to specify which column(s) should be searched.

See #35791.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/siteQuery.php

    r37477 r37735  
    471471                $this->assertEquals( $expected, $found );
    472472        }
     473
     474        public function test_wp_site_query_by_search_with_text_in_path_exclude_domain_from_search() {
     475                $q = new WP_Site_Query();
     476                $found = $q->query( array(
     477                        'fields' => 'ids',
     478                        'search' => 'make',
     479                        'search_columns' => array( 'path' ),
     480                ) );
     481
     482                $expected = array(
     483                        self::$site_ids['www.w.org/make/'],
     484                );
     485
     486                $this->assertEquals( $expected, $found );
     487        }
     488
     489        public function test_wp_site_query_by_search_with_text_in_domain_exclude_path_from_search() {
     490                $q = new WP_Site_Query();
     491                $found = $q->query( array(
     492                        'fields' => 'ids',
     493                        'search' => 'make',
     494                        'search_columns' => array( 'domain' ),
     495                ) );
     496
     497                $expected = array(
     498                        self::$site_ids['make.wordpress.org/'],
     499                        self::$site_ids['make.wordpress.org/foo/'],
     500                );
     501
     502                $this->assertEquals( $expected, $found );
     503        }
     504
     505        public function test_wp_site_query_by_search_with_wildcard_in_text() {
     506                $q = new WP_Site_Query();
     507                $found = $q->query( array(
     508                        'fields'       => 'ids',
     509                        'search'       => 'm*ke',
     510                ) );
     511
     512                $expected = array(
     513                        self::$site_ids['www.w.org/make/'],
     514                        self::$site_ids['make.wordpress.org/'],
     515                        self::$site_ids['make.wordpress.org/foo/'],
     516                );
     517
     518                $this->assertEqualSets( $expected, $found );
     519        }
     520
     521        public function test_wp_site_query_by_search_with_wildcard_in_text_exclude_path_from_search() {
     522                $q = new WP_Site_Query();
     523                $found = $q->query( array(
     524                        'fields' => 'ids',
     525                        'search' => 'm*ke',
     526                        'search_columns' => array( 'domain' ),
     527                ) );
     528
     529                $expected = array(
     530                        self::$site_ids['make.wordpress.org/'],
     531                        self::$site_ids['make.wordpress.org/foo/'],
     532                );
     533
     534                $this->assertEqualSets( $expected, $found );
     535        }
     536
     537        public function test_wp_site_query_by_search_with_wildcard_in_text_exclude_domain_from_search() {
     538                $q = new WP_Site_Query();
     539                $found = $q->query( array(
     540                        'fields' => 'ids',
     541                        'search' => 'm*ke',
     542                        'search_columns' => array( 'path' ),
     543                ) );
     544
     545                $expected = array(
     546                        self::$site_ids['www.w.org/make/'],
     547                );
     548
     549                $this->assertEqualSets( $expected, $found );
     550        }
    473551}
    474552
Note: See TracChangeset for help on using the changeset viewer.