Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (11 years ago)
Author:
wonderboymusic
Message:

Unit Tests: after [35225], make factory a method/getter on WP_UnitTestCase and add magic methods for BC for every plugin that is extending WP_UnitTestCase and accessing the $factory instance prop.

Props nerrad, wonderboymusic.
See #30017, #33968.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/url.php

    r35225 r35242  
    273273        public function test_get_adjacent_post() {
    274274                $now = time();
    275                 $post_id = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    276                 $post_id2 = self::$factory->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     275                $post_id = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     276                $post_id2 = self::factory()->post->create( array( 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    277277
    278278                if ( ! isset( $GLOBALS['post'] ) )
     
    306306         */
    307307        public function test_get_adjacent_post_should_return_private_posts_belonging_to_the_current_user() {
    308                 $u = self::$factory->user->create( array( 'role' => 'author' ) );
     308                $u = self::factory()->user->create( array( 'role' => 'author' ) );
    309309                $old_uid = get_current_user_id();
    310310                wp_set_current_user( $u );
    311311
    312312                $now = time();
    313                 $p1 = self::$factory->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    314                 $p2 = self::$factory->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     313                $p1 = self::factory()->post->create( array( 'post_author' => $u, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     314                $p2 = self::factory()->post->create( array( 'post_author' => $u, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    315315
    316316                if ( ! isset( $GLOBALS['post'] ) ) {
     
    332332         */
    333333        public function test_get_adjacent_post_should_return_private_posts_belonging_to_other_users_if_the_current_user_can_read_private_posts() {
    334                 $u1 = self::$factory->user->create( array( 'role' => 'author' ) );
    335                 $u2 = self::$factory->user->create( array( 'role' => 'administrator' ) );
     334                $u1 = self::factory()->user->create( array( 'role' => 'author' ) );
     335                $u2 = self::factory()->user->create( array( 'role' => 'administrator' ) );
    336336                $old_uid = get_current_user_id();
    337337                wp_set_current_user( $u2 );
    338338
    339339                $now = time();
    340                 $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    341                 $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     340                $p1 = self::factory()->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     341                $p2 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    342342
    343343                if ( ! isset( $GLOBALS['post'] ) ) {
     
    359359         */
    360360        public function test_get_adjacent_post_should_not_return_private_posts_belonging_to_other_users_if_the_current_user_cannot_read_private_posts() {
    361                 $u1 = self::$factory->user->create( array( 'role' => 'author' ) );
    362                 $u2 = self::$factory->user->create( array( 'role' => 'author' ) );
     361                $u1 = self::factory()->user->create( array( 'role' => 'author' ) );
     362                $u2 = self::factory()->user->create( array( 'role' => 'author' ) );
    363363                $old_uid = get_current_user_id();
    364364                wp_set_current_user( $u2 );
    365365
    366366                $now = time();
    367                 $p1 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) );
    368                 $p2 = self::$factory->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
    369                 $p3 = self::$factory->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
     367                $p1 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now - 2 ) ) );
     368                $p2 = self::factory()->post->create( array( 'post_author' => $u1, 'post_status' => 'private', 'post_date' => date( 'Y-m-d H:i:s', $now - 1 ) ) );
     369                $p3 = self::factory()->post->create( array( 'post_author' => $u1, 'post_date' => date( 'Y-m-d H:i:s', $now ) ) );
    370370
    371371                if ( ! isset( $GLOBALS['post'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.