Skip to content

Commit

Permalink
Merge pull request #508 from buddypress/feature/unit-tests-review
Browse files Browse the repository at this point in the history
Cleanup: Unit tests
  • Loading branch information
renatonascalves authored May 24, 2024
2 parents 1c2baf3 + 198bb71 commit 989a805
Show file tree
Hide file tree
Showing 26 changed files with 1,153 additions and 1,416 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1', '8.2']
php: ['7.4', '8.0', '8.1', '8.2', '8.3']
wp_version: ['master']
include:
- php: '8.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,35 +433,27 @@ public function create_item_permissions_check( $request ) {
$retval = new WP_Error(
'bp_rest_authorization_required',
__( 'Sorry, you need to be logged in to create a membership request.', 'buddypress' ),
array(
'status' => rest_authorization_required_code(),
)
array( 'status' => rest_authorization_required_code() )
);
} elseif ( ! $user instanceof WP_User ) {
$retval = new WP_Error(
'bp_rest_group_member_invalid_id',
__( 'Invalid member ID.', 'buddypress' ),
array(
'status' => 404,
)
array( 'status' => 404 )
);
} elseif ( ! $group instanceof BP_Groups_Group ) {
$retval = new WP_Error(
'bp_rest_group_invalid_id',
__( 'Invalid group ID.', 'buddypress' ),
array(
'status' => 404,
)
array( 'status' => 404 )
);
} elseif ( bp_current_user_can( 'bp_moderate' ) || $user_id === $user_id_arg ) {
$retval = true;
} else {
$retval = new WP_Error(
'bp_rest_group_membership_requests_cannot_create_item',
__( 'User may not extend requests on behalf of another user.', 'buddypress' ),
array(
'status' => rest_authorization_required_code(),
)
array( 'status' => rest_authorization_required_code() )
);
}

Expand Down
3 changes: 0 additions & 3 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ function _manually_load_plugins() {
echo "Loading WP Testing environment...\n";
require_once WP_TESTS_DIR . '/includes/bootstrap.php';

echo "Loading REST controllers...\n";
require_once WP_TESTS_DIR . '/includes/testcase-rest-controller.php';

echo "Loading BuddyPress testcases...\n";
require_once BP_TESTS_DIR . '/includes/testcase.php';
require_once BP_TESTS_DIR . '/includes/testcase-emails.php';
Expand Down
5 changes: 1 addition & 4 deletions tests/define-constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
* - Assume that we are inside of a develop.svn.wordpress.org setup, and walk
* up the directory tree
*/
if ( false !== getenv( 'WP_PHPUNIT__DIR' ) ) {
define( 'WP_TESTS_DIR', getenv( 'WP_PHPUNIT__DIR' ) );
define( 'WP_ROOT_DIR', '/var/www/html' );
} elseif ( false !== getenv( 'WP_TESTS_DIR' ) ) {
if ( false !== getenv( 'WP_TESTS_DIR' ) ) {
define( 'WP_TESTS_DIR', getenv( 'WP_TESTS_DIR' ) );
define( 'WP_ROOT_DIR', WP_TESTS_DIR );
} else {
Expand Down
83 changes: 0 additions & 83 deletions tests/env-wp-phpunit-config.php

This file was deleted.

Loading

0 comments on commit 989a805

Please sign in to comment.