Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/03/2017 07:44:10 PM (4 years ago)
Author:
boonebgorges
Message:

Use static factory method throughout PHPUnit tests.

See #7620.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/blogs/functions.php

    r10971 r11737  
    289289
    290290        // Create a regular member
    291         $u = $this->factory->user->create();
     291        $u = self::factory()->user->create();
    292292
    293293        // Create blogs
    294         $b1 = $this->factory->blog->create( array( 'user_id' => $u ) );
    295         $b2 = $this->factory->blog->create( array( 'user_id' => $u ) );
     294        $b1 = self::factory()->blog->create( array( 'user_id' => $u ) );
     295        $b2 = self::factory()->blog->create( array( 'user_id' => $u ) );
    296296
    297297        $expected = array(
     
    323323     */
    324324    public function test_transition_post_status_publish_to_publish() {
    325         $post_id = $this->factory->post->create( array(
     325        $post_id = self::factory()->post->create( array(
    326326            'post_status' => 'publish',
    327327            'post_type' => 'post',
     
    344344     */
    345345    public function test_transition_post_status_password_publish() {
    346         $post_id = $this->factory->post->create( array(
     346        $post_id = self::factory()->post->create( array(
    347347            'post_status'   => 'publish',
    348348            'post_type'     => 'post',
     
    359359     */
    360360    public function test_transition_post_status_publish_update_password() {
    361         $post_id = $this->factory->post->create( array(
     361        $post_id = self::factory()->post->create( array(
    362362            'post_status'   => 'publish',
    363363            'post_type'     => 'post',
     
    380380     */
    381381    public function test_transition_post_status_private_publish() {
    382         $post_id = $this->factory->post->create( array(
     382        $post_id = self::factory()->post->create( array(
    383383            'post_status'   => 'private',
    384384            'post_type'     => 'post',
     
    401401     */
    402402    public function test_transition_post_status_publish_private() {
    403         $post_id = $this->factory->post->create( array(
     403        $post_id = self::factory()->post->create( array(
    404404            'post_status'   => 'publish',
    405405            'post_type'     => 'post',
     
    422422     */
    423423    public function test_transition_post_status_draft_to_draft() {
    424         $post_id = $this->factory->post->create( array(
     424        $post_id = self::factory()->post->create( array(
    425425            'post_status' => 'draft',
    426426            'post_type' => 'post',
     
    442442     */
    443443    public function test_transition_post_status_draft_to_publish() {
    444         $post_id = $this->factory->post->create( array(
     444        $post_id = self::factory()->post->create( array(
    445445            'post_status' => 'draft',
    446446            'post_type' => 'post',
     
    462462     */
    463463    public function test_transition_post_status_publish_to_draft() {
    464         $post_id = $this->factory->post->create( array(
     464        $post_id = self::factory()->post->create( array(
    465465            'post_status' => 'publish',
    466466            'post_type' => 'post',
     
    482482     */
    483483    public function test_transition_post_status_wp_delete_post() {
    484         $post_id = $this->factory->post->create( array(
     484        $post_id = self::factory()->post->create( array(
    485485            'post_status' => 'publish',
    486486            'post_type' => 'post',
     
    499499     */
    500500    public function test_transition_post_status_wp_trash_post() {
    501         $post_id = $this->factory->post->create( array(
     501        $post_id = self::factory()->post->create( array(
    502502            'post_status' => 'publish',
    503503            'post_type' => 'post',
     
    519519        // save the current user and override logged-in user
    520520        $old_user = get_current_user_id();
    521         $u = $this->factory->user->create();
     521        $u = self::factory()->user->create();
    522522        $this->set_current_user( $u );
    523523        $userdata = get_userdata( $u );
    524524
    525525        // create the blog post
    526         $post_id = $this->factory->post->create( array(
     526        $post_id = self::factory()->post->create( array(
    527527            'post_status' => 'publish',
    528528            'post_type' => 'post',
     
    604604        // save the current user and override logged-in user
    605605        $old_user = get_current_user_id();
    606         $u = $this->factory->user->create();
     606        $u = self::factory()->user->create();
    607607        $this->set_current_user( $u );
    608608        $userdata = get_userdata( $u );
    609609
    610610        // create the blog post
    611         $post_id = $this->factory->post->create( array(
     611        $post_id = self::factory()->post->create( array(
    612612            'post_status' => 'publish',
    613613            'post_type' => 'post',
     
    666666    public function test_bp_blogs_post_type_remove_comment() {
    667667        $old_user = get_current_user_id();
    668         $u = $this->factory->user->create();
     668        $u = self::factory()->user->create();
    669669        $this->set_current_user( $u );
    670670        $userdata = get_userdata( $u );
    671671
    672672        // create the blog post
    673         $p = $this->factory->post->create( array(
     673        $p = self::factory()->post->create( array(
    674674            'post_status' => 'publish',
    675675            'post_type' => 'post',
     
    708708        add_filter( 'bp_blogs_is_blog_trackable', '__return_false' );
    709709
    710         $post_id = $this->factory->post->create( array(
     710        $post_id = self::factory()->post->create( array(
    711711            'post_status'   => 'publish',
    712712            'post_type'     => 'post',
     
    737737        add_filter( 'bp_is_blog_public', '__return_zero' );
    738738
    739         $post_id = $this->factory->post->create( array(
     739        $post_id = self::factory()->post->create( array(
    740740            'post_status'   => 'publish',
    741741            'post_type'     => 'post',
     
    764764        // save the current user and override logged-in user
    765765        $old_user = get_current_user_id();
    766         $u = $this->factory->user->create();
     766        $u = self::factory()->user->create();
    767767        $this->set_current_user( $u );
    768768        $userdata = get_userdata( $u );
     
    777777
    778778        // create the blog post
    779         $post_id = $this->factory->post->create( array(
     779        $post_id = self::factory()->post->create( array(
    780780            'post_status' => 'publish',
    781781            'post_type'   => 'post',
     
    828828        // Save the current user and override logged-in user
    829829        $old_user = get_current_user_id();
    830         $u = $this->factory->user->create();
     830        $u = self::factory()->user->create();
    831831        $this->set_current_user( $u );
    832832
     
    838838
    839839        // Create the blog post
    840         $post_id = $this->factory->post->create( array(
     840        $post_id = self::factory()->post->create( array(
    841841            'post_status' => 'publish',
    842842            'post_type'   => 'post',
     
    887887    public function test_bp_blogs_comment_sync_activity_comment_for_custom_post_type() {
    888888        if ( is_multisite() ) {
    889             $b = $this->factory->blog->create();
     889            $b = self::factory()->blog->create();
    890890            switch_to_blog( $b );
    891891            add_filter( 'comment_flood_filter', '__return_false' );
     
    894894        }
    895895
    896         $u = $this->factory->user->create();
     896        $u = self::factory()->user->create();
    897897        $userdata = get_userdata( $u );
    898898
     
    916916        add_filter( 'bp_disable_blogforum_comments', '__return_false' );
    917917
    918         $p = $this->factory->post->create( array(
     918        $p = self::factory()->post->create( array(
    919919            'post_author' => $u,
    920920            'post_type'   => 'foo',
     
    995995        $old_user = get_current_user_id();
    996996
    997         $u = $this->factory->user->create();
     997        $u = self::factory()->user->create();
    998998        $this->set_current_user( $u );
    999999
    10001000        // Create three sites.
    1001         $this->factory->blog->create_many( 3, array(
     1001        self::factory()->blog->create_many( 3, array(
    10021002            'user_id' => $u
    10031003        ) );
     
    10311031        $_POST['blog_public'] = 1;
    10321032
    1033         $u = $this->factory->user->create();
     1033        $u = self::factory()->user->create();
    10341034        $this->set_current_user( $u );
    10351035
    10361036        // Create three sites.
    1037         $b = $this->factory->blog->create( array(
     1037        $b = self::factory()->blog->create( array(
    10381038            'user_id' => $u
    10391039        ) );
     
    10781078        $_POST['blog_public'] = 1;
    10791079
    1080         $u = $this->factory->user->create();
     1080        $u = self::factory()->user->create();
    10811081        $this->set_current_user( $u );
    10821082
    10831083        // Create three sites.
    1084         $b = $this->factory->blog->create( array(
     1084        $b = self::factory()->blog->create( array(
    10851085            'user_id' => $u
    10861086        ) );
    10871087
    1088         $u2 = $this->factory->user->create();
     1088        $u2 = self::factory()->user->create();
    10891089        add_user_to_blog( $b, $u2, 'contributor' );
    10901090
Note: See TracChangeset for help on using the changeset viewer.