| | 272 | |
| | 273 | class BP_UnitTest_Factory_For_Friendship extends WP_UnitTest_Factory_For_Thing { |
| | 274 | public function __construct( $factory = null ) { |
| | 275 | parent::__construct( $factory ); |
| | 276 | } |
| | 277 | |
| | 278 | public function create_object( $args ) { |
| | 279 | $friendship = new BP_Friends_Friendship(); |
| | 280 | |
| | 281 | foreach ( array( 'initiator_user_id', 'firend_user_id' ) as $arg ) { |
| | 282 | if ( isset( $args[ $arg ] ) ) { |
| | 283 | $friendship->$arg = $args[ $arg ]; |
| | 284 | } else { |
| | 285 | $friendship->$arg = $this->factory->user->create(); |
| | 286 | } |
| | 287 | } |
| | 288 | |
| | 289 | foreach ( array( 'is_confirmed', 'is_limited', 'date_created' ) as $arg ) { |
| | 290 | if ( isset( $args[ $arg ] ) ) { |
| | 291 | $friendship->$arg = $args[ $arg ]; |
| | 292 | } |
| | 293 | } |
| | 294 | |
| | 295 | $friendship->save(); |
| | 296 | |
| | 297 | return $friendship->id; |
| | 298 | } |
| | 299 | |
| | 300 | public function update_object( $id, $fields ) {} |
| | 301 | |
| | 302 | public function get_object_by_id( $id ) { |
| | 303 | return new BP_Friends_Friendship( $id ); |
| | 304 | } |
| | 305 | } |