Make WordPress Core

Changeset 49005


Ignore:
Timestamp:
09/19/2020 11:11:00 AM (5 years ago)
Author:
SergeyBiryukov
Message:

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

Follow-up to [35249], [49003].

See #51344.

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

Legend:

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

    r49004 r49005  
    88class Tests_Comment_Slashes extends WP_UnitTestCase {
    99    protected static $author_id;
     10    protected static $post_id;
    1011
    1112    public static function wpSetUpBeforeClass( $factory ) {
    1213        // We need an admin user to bypass comment flood protection.
    1314        self::$author_id = $factory->user->create( array( 'role' => 'administrator' ) );
     15        self::$post_id   = $factory->post->create();
    1416    }
    1517
     
    3436     */
    3537    function test_wp_new_comment() {
    36         $post_id = self::factory()->post->create();
     38        $post_id = self::$post_id;
    3739
    3840        // Not testing comment_author_email or comment_author_url
     
    7375     */
    7476    function test_edit_comment() {
    75         $post_id    = self::factory()->post->create();
     77        $post_id    = self::$post_id;
    7678        $comment_id = self::factory()->comment->create(
    7779            array(
     
    119121     */
    120122    function test_wp_insert_comment() {
    121         $post_id = self::factory()->post->create();
     123        $post_id = self::$post_id;
    122124
    123125        $comment_id = wp_insert_comment(
     
    150152     */
    151153    function test_wp_update_comment() {
    152         $post_id    = self::factory()->post->create();
     154        $post_id    = self::$post_id;
    153155        $comment_id = self::factory()->comment->create(
    154156            array(
  • trunk/tests/phpunit/tests/meta/slashes.php

    r49004 r49005  
    1010    protected static $post_id;
    1111    protected static $comment_id;
     12    protected static $user_id;
    1213
    1314    public static function wpSetUpBeforeClass( $factory ) {
     
    1516        self::$post_id    = $factory->post->create();
    1617        self::$comment_id = $factory->comment->create( array( 'comment_post_ID' => self::$post_id ) );
     18        self::$user_id    = $factory->user->create();
    1719    }
    1820
     
    3537     */
    3638    function test_edit_post() {
    37         $post_id = self::factory()->post->create();
     39        $post_id = self::$post_id;
    3840
    3941        if ( function_exists( 'wp_add_post_meta' ) ) {
     
    112114     */
    113115    function test_add_post_meta() {
    114         $post_id = self::factory()->post->create();
     116        $post_id = self::$post_id;
    115117
    116118        add_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) );
     
    127129     */
    128130    function test_update_post_meta() {
    129         $post_id = self::factory()->post->create();
     131        $post_id = self::$post_id;
    130132
    131133        update_post_meta( $post_id, 'slash_test_1', addslashes( $this->slash_1 ) );
     
    192194     */
    193195    function test_add_user_meta() {
    194         $user_id = self::factory()->user->create();
     196        $user_id = self::$user_id;
    195197
    196198        add_user_meta( $user_id, 'slash_test_1', $this->slash_1 );
     
    215217     */
    216218    function test_update_user_meta() {
    217         $user_id = self::factory()->user->create();
     219        $user_id = self::$user_id;
    218220
    219221        add_user_meta( $user_id, 'slash_test_1', 'foo' );
  • trunk/tests/phpunit/tests/post/slashes.php

    r49004 r49005  
    88class Tests_Post_Slashes extends WP_UnitTestCase {
    99    protected static $author_id;
     10    protected static $post_id;
    1011
    1112    public static function wpSetUpBeforeClass( $factory ) {
    1213        self::$author_id = $factory->user->create( array( 'role' => 'editor' ) );
     14        self::$post_id   = $factory->post->create();
    1315    }
    1416
     
    3335     */
    3436    function test_edit_post() {
    35         $post_id = self::factory()->post->create();
     37        $post_id = self::$post_id;
    3638
    3739        $_POST               = array();
     
    106108     */
    107109    function test_wp_update_post() {
    108         $post_id = self::factory()->post->create();
     110        $post_id = self::$post_id;
    109111
    110112        wp_update_post(
  • trunk/tests/phpunit/tests/user/slashes.php

    r49004 r49005  
    88class Tests_User_Slashes extends WP_UnitTestCase {
    99    protected static $author_id;
     10    protected static $user_id;
    1011
    1112    public static function wpSetUpBeforeClass( $factory ) {
    1213        self::$author_id = $factory->user->create( array( 'role' => 'administrator' ) );
     14        self::$user_id   = $factory->user->create();
    1315    }
    1416
     
    8890     */
    8991    function test_edit_user() {
    90         $user_id = self::factory()->user->create();
     92        $user_id = self::$user_id;
    9193
    9294        $_POST                 = array();
     
    186188     */
    187189    function test_wp_update_user() {
    188         $user_id = self::factory()->user->create();
     190        $user_id = self::$user_id;
    189191        $user_id = wp_update_user(
    190192            array(
Note: See TracChangeset for help on using the changeset viewer.