WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/14/2013 11:09:59 PM (8 years ago)
Author:
nacin
Message:

Proper treatment of the 'archived' field in wp_get_sites(). see #14511.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/ms.php

    r25445 r25446  
    10691069    }
    10701070
     1071    /**
     1072     * Test the 'archived' argument for wp_get_sites().
     1073     *
     1074     * archived is an ENUM, not an integer field.
     1075     * ENUM('0', '1') means '0' is index 1 and '1' is index 2.
     1076     * `WHERE archived = 1` is like saying `WHERE archived = '0'`.
     1077     * `WHERE archived = 0` would produce no results.
     1078     *
     1079     * @ticket 14511
     1080     */
     1081    function test_wp_get_sites_archived_enum() {
     1082        global $wpdb;
     1083        $id = $this->factory->blog->create( array( 'site_id' => 2, 'meta' => array( 'archived' => '1' ) ) );
     1084        $this->factory->blog->create(       array( 'site_id' => 2, 'meta' => array( 'archived' => '0' ) ) );
     1085        $results = wp_get_sites( array( 'network_id' => 2, 'archived' => 1 ) );
     1086        $this->assertCount( 1, $results );
     1087        $this->assertEquals( $id, $results[0]['blog_id'], "This query is wrong:\n" . $wpdb->last_query );
     1088    }
    10711089}
    10721090
Note: See TracChangeset for help on using the changeset viewer.