WordPress.org

Make WordPress Core

Changeset 49003


Ignore:
Timestamp:
09/19/2020 10:34:54 AM (6 months ago)
Author:
SergeyBiryukov
Message:

Tests: Speed up slashed data tests by reusing shared fixtures.

Follow-up to [35249].

See #51344.

Location:
trunk/tests/phpunit/tests
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/attachment/slashes.php

    r48937 r49003  
    77 */
    88class Tests_Attachment_Slashes extends WP_UnitTestCase {
     9    protected static $author_id;
     10
     11    public static function wpSetUpBeforeClass( $factory ) {
     12        self::$author_id = $factory->user->create( array( 'role' => 'editor' ) );
     13    }
     14
    915    function setUp() {
    1016        parent::setUp();
    11         $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    12         wp_set_current_user( $this->author_id );
     17
     18        wp_set_current_user( self::$author_id );
    1319
    1420        // It is important to test with both even and odd numbered slashes,
  • trunk/tests/phpunit/tests/comment/slashes.php

    r48937 r49003  
    77 */
    88class Tests_Comment_Slashes extends WP_UnitTestCase {
     9    protected static $author_id;
     10
     11    public static function wpSetUpBeforeClass( $factory ) {
     12        // We need an admin user to bypass comment flood protection.
     13        self::$author_id = $factory->user->create( array( 'role' => 'administrator' ) );
     14    }
     15
    916    function setUp() {
    1017        parent::setUp();
    11         // We need an admin user to bypass comment flood protection.
    12         $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    13         wp_set_current_user( $this->author_id );
     18
     19        wp_set_current_user( self::$author_id );
    1420
    1521        // It is important to test with both even and odd numbered slashes,
  • trunk/tests/phpunit/tests/option/slashes.php

    r48937 r49003  
    77 */
    88class Tests_Option_Slashes extends WP_UnitTestCase {
     9
    910    function setUp() {
    1011        parent::setUp();
     12
    1113        // It is important to test with both even and odd numbered slashes,
    1214        // as KSES does a strip-then-add slashes in some of its function calls.
  • trunk/tests/phpunit/tests/post/slashes.php

    r48937 r49003  
    77 */
    88class Tests_Post_Slashes extends WP_UnitTestCase {
     9    protected static $author_id;
     10
     11    public static function wpSetUpBeforeClass( $factory ) {
     12        self::$author_id = $factory->user->create( array( 'role' => 'editor' ) );
     13    }
     14
    915    function setUp() {
    1016        parent::setUp();
    11         $this->author_id = self::factory()->user->create( array( 'role' => 'editor' ) );
    1217
    13         wp_set_current_user( $this->author_id );
     18        wp_set_current_user( self::$author_id );
    1419
    1520        // It is important to test with both even and odd numbered slashes,
  • trunk/tests/phpunit/tests/term/slashes.php

    r48937 r49003  
    77 */
    88class Tests_Term_Slashes extends WP_Ajax_UnitTestCase {
     9    protected static $author_id;
     10
     11    public static function wpSetUpBeforeClass( $factory ) {
     12        self::$author_id = $factory->user->create( array( 'role' => 'administrator' ) );
     13    }
     14
    915    function setUp() {
    1016        parent::setUp();
    11         $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    1217
    13         wp_set_current_user( $this->author_id );
     18        wp_set_current_user( self::$author_id );
    1419
    1520        $this->slash_1 = 'String with 1 slash \\';
  • trunk/tests/phpunit/tests/user/slashes.php

    r48937 r49003  
    77 */
    88class Tests_User_Slashes extends WP_UnitTestCase {
     9    protected static $author_id;
     10
     11    public static function wpSetUpBeforeClass( $factory ) {
     12        self::$author_id = $factory->user->create( array( 'role' => 'administrator' ) );
     13    }
     14
    915    function setUp() {
    1016        parent::setUp();
    11         $this->author_id = self::factory()->user->create( array( 'role' => 'administrator' ) );
    12 
    13         wp_set_current_user( $this->author_id );
     17
     18        wp_set_current_user( self::$author_id );
    1419
    1520        // It is important to test with both even and odd numbered slashes,
Note: See TracChangeset for help on using the changeset viewer.