mirror of
https://github.com/buddypress/buddypress.git
synced 2026-07-23 21:06:56 +08:00
We are officially deprecating the V1 of the BP REST API. And bundling the new, default, V2 of the BP REST API inside BuddyPress core. Previously, the V1 was developed as a plugin in a separate repo (https://github.com/buddypress/BP-REST). - One of the main differences between the V1 and V2 is how objects are returned. Single items are no longer returned as an `array`; - We have a new `BP_Test_REST_Controller_Testcase` for testing the new API endpoints; - We changed the names of our controllers to follow our autoloader rules; - Removed the BP-REST plugin from `wp-env` and from our release script; - And we added notices for the deprecated V1 API (endpoints and files). Props imath & I. ;) Fixes #8200 See #9145 Closes https://github.com/buddypress/buddypress/pull/337 git-svn-id: https://buddypress.svn.wordpress.org/trunk@14026 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group testsuite
|
|
* @group factory
|
|
*/
|
|
class BP_Tests_Testsuite_Factory extends BP_UnitTestCase {
|
|
/**
|
|
* @ticket BP7234
|
|
*/
|
|
public function test_message_create_and_get_should_return_message_object() {
|
|
$m = self::factory()->message->create_and_get();
|
|
|
|
$this->assertTrue( $m instanceof BP_Messages_Message );
|
|
}
|
|
|
|
/**
|
|
* @ticket BP7234
|
|
*/
|
|
public function test_message_should_create_default_sender_and_recipient() {
|
|
$m = self::factory()->message->create_and_get();
|
|
|
|
$this->assertNotEmpty( $m->sender_id );
|
|
$this->assertNotEmpty( $m->get_recipients() );
|
|
}
|
|
|
|
/**
|
|
* @ticket BP7243
|
|
*/
|
|
public function test_friendship_should_create_default_initiator_and_friend() {
|
|
$f = self::factory()->friendship->create_and_get();
|
|
|
|
$u1 = new WP_User( $f->initiator_user_id );
|
|
$u2 = new WP_User( $f->friend_user_id );
|
|
|
|
$this->assertTrue( $u1->exists() );
|
|
$this->assertTrue( $u2->exists() );
|
|
}
|
|
|
|
/**
|
|
* @ticket BP7243
|
|
*/
|
|
public function test_friendship_should_respect_passed_initiator_and_friend() {
|
|
$u1 = self::factory()->user->create();
|
|
$u2 = self::factory()->user->create();
|
|
|
|
$f = self::factory()->friendship->create_and_get(
|
|
array(
|
|
'initiator_user_id' => $u1,
|
|
'friend_user_id' => $u2,
|
|
)
|
|
);
|
|
|
|
$this->assertSame( $u1, $f->initiator_user_id );
|
|
$this->assertSame( $u2, $f->friend_user_id );
|
|
}
|
|
}
|