Make WordPress Core

Ticket #37217: 37217.5.diff

File 37217.5.diff, 2.1 KB (added by jeremyfelt, 7 years ago)
  • tests/phpunit/tests/multisite/bootstrap.php

     
    9494
    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.
    100100         * @param string $domain       The requested domain.
    101101         * @param string $path         The requested path.
    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.' ),
    125117                        array( 'wordpress.net/',         'wordpress.net',       '/notapath/', 'A network matching a top level domain should be found regardless of path.' ),