WordPress.org

Make WordPress Core

Ticket #23865: 23865.tests.diff

File 23865.tests.diff, 1.4 KB (added by simonwheatley, 6 years ago)

New test method for multisite to test the path is correctly sanitised and slashed

  • phpunit/tests/ms.php

     
    595595        }
    596596
    597597        /**
     598         * Check the path for a sub-directory site is correctly sanitised,
     599         * and has a trailing slash.
     600         *
     601         * @ticket 23865
     602         */
     603        function test_update_blog_sanitises_subdirectory_path() {
     604                global $test_action_counter;
     605
     606                $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );
     607                $blog_id = $this->factory->blog->create( array( 'user_id' => $user_id, 'path' => '/test_blogpath', 'title' => 'Test Title' ) );
     608                $this->assertInternalType( 'int', $blog_id );
     609
     610                $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'my_path') );
     611
     612                $blog = get_blog_details( $blog_id );
     613                $this->assertEquals( '/my_path/', $blog->path );
     614
     615                $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => 'my_path//') );
     616
     617                $blog = get_blog_details( $blog_id );
     618                $this->assertEquals( '/my_path/', $blog->path );
     619
     620                $result = update_blog_details( $blog_id, array('domain' => 'example.com', 'path' => '/my_path') );
     621
     622                $blog = get_blog_details( $blog_id );
     623                $this->assertEquals( '/my_path/', $blog->path );
     624        }
     625
     626        /**
    598627         * Test fetching a blog that doesn't exist and again after it exists.
    599628         *
    600629         * @ticket 23405