Make WordPress Core


Ignore:
Timestamp:
07/14/2015 05:51:05 AM (11 years ago)
Author:
jeremyfelt
Message:

Tests: Use a data provider when testing path slashing in update_blog_details().

Trims down 11 tests to 1 clean area of testing and makes for a much saner read.

See #32988.

File:
1 edited

Legend:

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

    r33253 r33254  
    235235
    236236        /**
    237          * When the path for a site is updated with update_blog_details(), the final
    238          * path should have a leading and trailing slash. When multiple directories
    239          * are part of the path, only one slash should separate each directory.
     237         * When the path for a site is updated with update_blog_details(), the final path
     238         * should have a leading and trailing slash.
    240239         *
    241          * @ticket 18117
    242          */
    243         function test_update_blog_details_single_path_no_slashes() {
    244                 update_blog_details( 1, array( 'path' => 'my_path' ) );
    245                 $blog = get_blog_details( 1 );
    246                 $this->assertEquals( '/my_path/', $blog->path );
    247         }
    248 
    249         function test_update_blog_details_single_path_double_trailing_slashes() {
    250                 update_blog_details( 1, array( 'path' => 'my_path//' ) );
    251                 $blog = get_blog_details( 1 );
    252                 $this->assertEquals( '/my_path/', $blog->path );
    253         }
    254 
    255         function test_update_blog_details_single_path_double_leading_slashes() {
    256                 update_blog_details( 1, array( 'path' => '//my_path' ) );
    257                 $blog = get_blog_details( 1 );
    258                 $this->assertEquals( '/my_path/', $blog->path );
    259         }
    260 
    261         function test_update_blog_details_single_path_single_trailing_slash() {
    262                 update_blog_details( 1, array( 'path' => 'my_path/' ) );
    263                 $blog = get_blog_details( 1 );
    264                 $this->assertEquals( '/my_path/', $blog->path );
    265         }
    266 
    267         function test_update_blog_details_single_path_single_leading_slashes() {
    268                 update_blog_details( 1, array( 'path' => '/my_path' ) );
    269                 $blog = get_blog_details( 1 );
    270                 $this->assertEquals( '/my_path/', $blog->path );
    271         }
    272 
    273         function test_update_blog_details_single_path_both_slashes() {
    274                 update_blog_details( 1, array( 'path' => '/my_path/' ) );
    275                 $blog = get_blog_details( 1 );
    276                 $this->assertEquals( '/my_path/', $blog->path );
    277         }
    278 
    279         function test_update_blog_details_multiple_paths_no_slashes() {
    280                 update_blog_details( 1, array( 'path' => 'multiple/dirs' ) );
    281                 $blog = get_blog_details( 1 );
    282                 $this->assertEquals( '/multiple/dirs/', $blog->path );
    283         }
    284 
    285         /**
    286          * `update_blog_details()` does not resolve multiple slashes in the
    287          * middle of a path string.
    288          */
    289         function test_update_blog_details_multiple_paths_middle_slashes() {
    290                 update_blog_details( 1, array( 'path' => 'multiple///dirs' ) );
    291                 $blog = get_blog_details( 1 );
    292                 $this->assertEquals( '/multiple///dirs/', $blog->path );
    293         }
    294 
    295         function test_update_blog_details_multiple_paths_leading_slash() {
    296                 update_blog_details( 1, array( 'path' => '/multiple/dirs' ) );
    297                 $blog = get_blog_details( 1 );
    298                 $this->assertEquals( '/multiple/dirs/', $blog->path );
    299         }
    300 
    301         function test_update_blog_details_multiple_paths_trailing_slash() {
    302                 update_blog_details( 1, array( 'path' => 'multiple/dirs/' ) );
    303                 $blog = get_blog_details( 1 );
    304                 $this->assertEquals( '/multiple/dirs/', $blog->path );
    305         }
    306 
    307         function test_update_blog_details_multiple_paths_both_slashes() {
    308                 update_blog_details( 1, array( 'path' => '/multiple/dirs/' ) );
    309                 $blog = get_blog_details( 1 );
    310                 $this->assertEquals( '/multiple/dirs/', $blog->path );
     240         * @dataProvider data_single_directory_path
     241         */
     242        public function test_update_blog_details_single_directory_path( $path, $expected ) {
     243                update_blog_details( 1, array( 'path' => $path ) );
     244                $site = get_blog_details( 1 );
     245
     246                $this->assertEquals( $expected, $site->path );
     247        }
     248
     249        public function data_single_directory_path() {
     250                return array(
     251                        array( 'my_path',   '/my_path/' ),
     252                        array( 'my_path//', '/my_path/' ),
     253                        array( '//my_path', '/my_path/' ),
     254                        array( 'my_path/',  '/my_path/' ),
     255                        array( '/my_path',  '/my_path/' ),
     256                        array( '/my_path/', '/my_path/' ),
     257
     258                        array( 'multiple/dirs',   '/multiple/dirs/' ),
     259                        array( '/multiple/dirs',  '/multiple/dirs/' ),
     260                        array( 'multiple/dirs/',  '/multiple/dirs/' ),
     261                        array( '/multiple/dirs/', '/multiple/dirs/' ),
     262
     263                        // update_blog_details() does not resolve multiple slashes in the middle of a path string.
     264                        array( 'multiple///dirs', '/multiple///dirs/' ),
     265                );
    311266        }
    312267
Note: See TracChangeset for help on using the changeset viewer.