WordPress.org

Make WordPress Core

Changeset 40342


Ignore:
Timestamp:
03/28/2017 01:24:44 AM (14 months ago)
Author:
jeremyfelt
Message:

Tests: Clarify zero path segment tests for get_network_by_path().

The set of assertions in this data provider intend to test a 0 path segment configuration rather than the use of paths.

Fixes #37217.

File:
1 edited

Legend:

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

    r40102 r40342  
    9595    /**
    9696     * @ticket 37217
    97      * @dataProvider data_get_network_by_path_not_using_paths
     97     * @dataProvider data_get_network_by_path_with_zero_path_segments
    9898     *
    9999     * @param string $expected_key The array key associated with expected data for the test.
     
    102102     * @param string $message      The message to pass for failed tests.
    103103     */
    104     public function test_get_network_by_path_not_using_paths( $expected_key, $domain, $path, $message ) {
    105         if ( ! wp_using_ext_object_cache() ) {
    106             $this->markTestSkipped( 'Only testable with an external object cache.' );
    107         }
    108 
    109         // Temporarily store original object cache and using paths values.
    110         $using_paths_orig = wp_cache_get( 'networks_have_paths', 'site-options' );
    111 
    112         wp_cache_set( 'networks_have_paths', 0, 'site-options'  );
     104    public function test_get_network_by_path_with_zero_path_segments( $expected_key, $domain, $path, $message ) {
     105        add_filter( 'network_by_path_segments_count', '__return_zero' );
    113106
    114107        $network = get_network_by_path( $domain, $path );
    115108
    116         // Restore original object cache and using paths values.
    117         wp_cache_set( 'networks_have_paths', $using_paths_orig, 'site-options' );
     109        remove_filter( 'network_by_path_segments_count', '__return_zero' );
    118110
    119111        $this->assertEquals( self::$network_ids[ $expected_key ], $network->id, $message );
    120112    }
    121113
    122     public function data_get_network_by_path_not_using_paths() {
     114    public function data_get_network_by_path_with_zero_path_segments() {
    123115        return array(
    124116            array( 'wordpress.org/',         'wordpress.org',       '/',          'A standard domain and path request should work.' ),
Note: See TracChangeset for help on using the changeset viewer.