WordPress.org

Make WordPress Core


Ignore:
Timestamp:
10/17/2015 06:02:16 PM (6 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/comment/getCommentClass.php

    r35225 r35242  
    66class Tests_Comment_GetCommentClass extends WP_UnitTestCase {
    77    public function test_should_accept_comment_id() {
    8         $post_id    = self::$factory->post->create();
    9         $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     8        $post_id    = self::factory()->post->create();
     9        $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) );
    1010
    1111        $classes = get_comment_class( '', $comment_id );
     
    1414
    1515    public function test_should_accept_comment_object() {
    16         $post_id = self::$factory->post->create();
    17         $comment = self::$factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) );
     16        $post_id = self::factory()->post->create();
     17        $comment = self::factory()->comment->create_and_get( array( 'comment_post_ID' => $post_id ) );
    1818
    1919        $classes = get_comment_class( '', $comment );
     
    2222
    2323    public function test_should_append_single_class() {
    24         $post_id    = self::$factory->post->create();
    25         $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     24        $post_id    = self::factory()->post->create();
     25        $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) );
    2626
    2727        $classes = get_comment_class( 'foo', $comment_id );
     
    3030
    3131    public function test_should_append_array_of_classes() {
    32         $post_id    = self::$factory->post->create();
    33         $comment_id = self::$factory->comment->create( array( 'comment_post_ID' => $post_id ) );
     32        $post_id    = self::factory()->post->create();
     33        $comment_id = self::factory()->comment->create( array( 'comment_post_ID' => $post_id ) );
    3434
    3535        $classes = get_comment_class( array( 'foo', 'bar' ), $comment_id );
Note: See TracChangeset for help on using the changeset viewer.