Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/27/2024 08:16:17 PM (19 months ago)
Author:
espellcaste
Message:

Core: Add cache_results flag to the BP_Optout::get getter.

When performing a request with cache_results, it stops the optout information retrieved from being added to the cache.

See #8552
Closes https://github.com/buddypress/buddypress/pull/344/

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/includes/factory.php

    r13980 r13991  
    1414        $this->signup         = new BP_UnitTest_Factory_For_Signup( $this );
    1515        $this->friendship     = new BP_UnitTest_Factory_For_Friendship( $this );
     16        $this->optout         = new BP_UnitTest_Factory_For_Optout( $this );
    1617    }
    1718}
     
    7071    }
    7172
    72     public function update_object( $activity_id, $fields ) {
    73         $activity = new BP_Activity_Activity( $activity_id );
     73    public function update_object( $object_id, $fields ) {
     74        $activity = new BP_Activity_Activity( $object_id );
    7475
    7576        foreach ( $fields as $field_name => $value ) {
     
    8485    }
    8586
    86     public function get_object_by_id( $user_id ) {
    87         return new BP_Activity_Activity( $user_id );
     87    public function get_object_by_id( $object_id ) {
     88        return new BP_Activity_Activity( $object_id );
    8889    }
    8990}
     
    138139    }
    139140
    140     public function update_object( $group_id, $fields ) {
    141         $group = new BP_Groups_Group( $group_id );
     141    public function update_object( $object_id, $fields ) {
     142        $group = new BP_Groups_Group( $object_id );
    142143
    143144        foreach ( $fields as $field_name => $value ) {
     
    152153    }
    153154
    154     public function get_object_by_id( $group_id ) {
    155         return new BP_Groups_Group( $group_id );
     155    public function get_object_by_id( $object_id ) {
     156        return new BP_Groups_Group( $object_id );
    156157    }
    157158}
     
    187188    }
    188189
    189     public function update_object( $message_id, $fields ) {}
    190 
    191     public function get_object_by_id( $message_id ) {
    192         return new BP_Messages_Message( $message_id );
     190    public function update_object( $object_id, $fields ) {}
     191
     192    public function get_object_by_id( $object_id ) {
     193        return new BP_Messages_Message( $object_id );
    193194    }
    194195}
     
    210211    }
    211212
    212     public function update_object( $group_id, $fields ) {}
    213 
    214     public function get_object_by_id( $group_id ) {
    215         return new BP_XProfile_Group( $group_id );
     213    public function update_object( $object_id, $fields ) {}
     214
     215    public function get_object_by_id( $object_id ) {
     216        return new BP_XProfile_Group( $object_id );
    216217    }
    217218}
     
    233234    }
    234235
    235     public function update_object( $field_id, $fields ) {}
    236 
    237     public function get_object_by_id( $field_id ) {
    238         return new BP_XProfile_Field( $field_id );
     236    public function update_object( $object_id, $fields ) {}
     237
     238    public function get_object_by_id( $object_id ) {
     239        return new BP_XProfile_Field( $object_id );
    239240    }
    240241}
     
    245246    }
    246247
    247     public function update_object( $id, $fields ) {}
    248 
    249     public function get_object_by_id( $id ) {
    250         return new BP_Notifications_Notification( $id );
     248    public function update_object( $object_id, $fields ) {}
     249
     250    public function get_object_by_id( $object_id ) {
     251        return new BP_Notifications_Notification( $object_id );
    251252    }
    252253}
     
    257258    }
    258259
    259     public function update_object( $id, $fields ) {}
    260 
    261     public function get_object_by_id( $id ) {
    262         return new BP_Signup( $id );
     260    public function update_object( $object_id, $fields ) {}
     261
     262    public function get_object_by_id( $object_id ) {
     263        return new BP_Signup( $object_id );
    263264    }
    264265}
     
    293294    }
    294295
    295     public function update_object( $id, $fields ) {}
    296 
    297     public function get_object_by_id( $id ) {
    298         return new BP_Friends_Friendship( $id );
    299     }
    300 }
     296    public function update_object( $object_id, $fields ) {}
     297
     298    public function get_object_by_id( $object_id ) {
     299        return new BP_Friends_Friendship( $object_id );
     300    }
     301}
     302
     303/**
     304 * Factory for optout.
     305 *
     306 * @since 15.0.0
     307 */
     308class BP_UnitTest_Factory_For_Optout extends WP_UnitTest_Factory_For_Thing {
     309
     310    public function __construct( $factory = null ) {
     311        parent::__construct( $factory );
     312
     313        $this->default_generation_definitions = array(
     314            'email_address' => new WP_UnitTest_Generator_Sequence( 'user_%s@example.org' ),
     315            'user_id'       => 0,
     316            'email_type'    => '',
     317            'date_modified' => bp_core_current_time(),
     318        );
     319    }
     320
     321    public function create_object( $args ) {
     322        $optout = new BP_Optout();
     323
     324        $optout->email_address = $args['email_address'];
     325        $optout->user_id       = $args['user_id'];
     326        $optout->email_type    = $args['email_type'];
     327        $optout->date_modified = $args['date_modified'];
     328
     329        return $optout->save();
     330    }
     331
     332    public function update_object( $object_id, $fields ) {}
     333
     334    public function get_object_by_id( $object_id ) {
     335        return new BP_Optout( $object_id );
     336    }
     337}
Note: See TracChangeset for help on using the changeset viewer.