Skip to:
Content

BuddyPress.org

Changeset 9233


Ignore:
Timestamp:
12/17/2014 05:14:17 AM (10 years ago)
Author:
tw2113
Message:

Add tests for bp_make_spam/ham_user and make_spam/ham_user filters.

Filters names were originally assigned to a passed in variable but
they were separated out for documentation purposes.

See #5944.

File:
1 edited

Legend:

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

    r9139 r9233  
    446446        return $wpdb->prefix . $key;
    447447    }
     448
     449    /**
     450     * @group bp_core_process_spammer_status
     451     */
     452    public function test_bp_core_process_spammer_status_make_spam_user_filter() {
     453        add_filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) );
     454
     455        $u1 = $this->factory->user->create();
     456        $n = bp_core_process_spammer_status( $u1, 'spam' );
     457
     458        remove_filter( 'make_spam_user', array( $this, 'notification_filter_callback' ) );
     459
     460        $this->assertSame( 'make_spam_user', $this->filter_fired );
     461
     462    }
     463
     464    public function test_bp_core_process_spammer_status_make_ham_user_filter() {
     465        add_filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) );
     466
     467        $u1 = $this->factory->user->create();
     468        $n = bp_core_process_spammer_status( $u1, 'ham' );
     469
     470        remove_filter( 'make_ham_user', array( $this, 'notification_filter_callback' ) );
     471
     472        $this->assertSame( 'make_ham_user', $this->filter_fired );
     473
     474    }
     475
     476    public function test_bp_core_process_spammer_status_bp_make_spam_user_filter() {
     477        add_filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) );
     478
     479        $u1 = $this->factory->user->create();
     480        $n = bp_core_process_spammer_status( $u1, 'spam' );
     481
     482        remove_filter( 'bp_make_spam_user', array( $this, 'notification_filter_callback' ) );
     483
     484        $this->assertSame( 'bp_make_spam_user', $this->filter_fired );
     485
     486    }
     487
     488    public function test_bp_core_process_spammer_status_bp_make_ham_user_filter() {
     489        add_filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) );
     490
     491        $u1 = $this->factory->user->create();
     492        $n = bp_core_process_spammer_status( $u1, 'ham' );
     493
     494        remove_filter( 'bp_make_ham_user', array( $this, 'notification_filter_callback' ) );
     495
     496        $this->assertSame( 'bp_make_ham_user', $this->filter_fired );
     497
     498    }
     499
     500    public function notification_filter_callback( $value ) {
     501        $this->filter_fired = current_filter();
     502        return $value;
     503    }
    448504}
Note: See TracChangeset for help on using the changeset viewer.