Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
05/03/2023 06:18:23 AM (3 years ago)
Author:
imath
Message:

Stop using BP Legacy URL parser in favor of the new BP Rewrites API

  • Deprecate bp_core_set_uri_globals(). This function is moved inside the BP Classic compatibility plugin.
  • Introduce the new bp_register_nav action to hook to when globalizing Members single item navigations from the BP_Component class.
  • Improve bp_get_component_navigations() so that Avatar/Cover images navigation items are moved inside the Profile sub nav if the Extended profile component is active.
  • Register Avatar/Cover images Ajax actions so that these actions trigger our new URL Parser inside Ajax context.
  • Improve the BP_Core_Nav::add_nav() method so that any BP action variable slugs can be customized.
  • Improve Members & Groups component canonical redirections.
  • Handle slugs customization persistency using directory pages post metas.
  • Introduce a new repair tool to reset all slugs to BuddyPress default one.
  • Adapt some PHPUnit tests to better handle our new URL parser.

Props Props r-a-y, johnjamesjacoby, boonebgorges

Closes https://github.com/buddypress/buddypress/pull/94
See #4954

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/testcases/activity/notifications.php

    r13436 r13468  
    4646     */
    4747    public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink() {
    48         $this->create_notifications();
    49         $this->set_permalink_structure( '/%postname%/' );
    50 
    51         $notifications = BP_Notifications_Notification::get( array(
    52             'user_id' => $this->u1,
    53         ) );
    54 
    55         // Double check it's there
    56         $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
     48        $this->set_permalink_structure( '/%postname%/' );
     49        $this->create_notifications();
     50
     51        $notifications = BP_Notifications_Notification::get( array(
     52            'user_id' => $this->u1,
     53        ) );
     54
     55        // Double check it's there
     56        $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
     57        $url = bp_members_get_user_url(
     58            $this->u1,
     59            array(
     60                'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
     61                'single_item_action'    => $this->a1,
     62            )
     63        );
     64
     65        // Go to the activity permalink page
     66        $this->go_to( $url );
     67
     68        $notifications = BP_Notifications_Notification::get( array(
     69            'user_id' => $this->u1,
     70        ) );
     71
     72        // Should be empty
     73        $this->assertEquals( array(), $notifications );
     74    }
     75
     76    /**
     77     * @group bp_activity_remove_screen_notifications
     78     * @group mentions
     79     */
     80    public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink_logged_out() {
     81        $this->create_notifications();
     82        $this->set_permalink_structure( '/%postname%/' );
     83
     84        $notifications = BP_Notifications_Notification::get( array(
     85            'user_id' => $this->u1,
     86        ) );
     87
     88        // Double check it's there
     89        $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
     90
     91        // Log out
     92        $this->set_current_user( 0 );
    5793
    5894        // Go to the activity permalink page
     
    71107        ) );
    72108
    73         // Should be empty
    74         $this->assertEquals( array(), $notifications );
    75     }
    76 
    77     /**
    78      * @group bp_activity_remove_screen_notifications
    79      * @group mentions
    80      */
    81     public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink_logged_out() {
    82         $this->create_notifications();
    83         $this->set_permalink_structure( '/%postname%/' );
    84 
    85         $notifications = BP_Notifications_Notification::get( array(
    86             'user_id' => $this->u1,
    87         ) );
    88 
    89         // Double check it's there
    90         $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    91 
    92         // Log out
    93         $this->set_current_user( 0 );
     109        // Should be untouched
     110        $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
     111
     112        $this->set_current_user( $this->u1 );
     113    }
     114
     115    /**
     116     * @group bp_activity_remove_screen_notifications
     117     * @group mentions
     118     */
     119    public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink_wrong_user() {
     120        $this->create_notifications();
     121        $this->set_permalink_structure( '/%postname%/' );
     122
     123        $notifications = BP_Notifications_Notification::get( array(
     124            'user_id' => $this->u1,
     125        ) );
     126
     127        // Double check it's there
     128        $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
     129
     130        // Switch user
     131        $this->set_current_user( $this->u2 );
    94132
    95133        // Go to the activity permalink page
     
    118156     * @group mentions
    119157     */
    120     public function test_bp_activity_remove_screen_notifications_on_single_activity_permalink_wrong_user() {
    121         $this->create_notifications();
    122         $this->set_permalink_structure( '/%postname%/' );
    123 
    124         $notifications = BP_Notifications_Notification::get( array(
    125             'user_id' => $this->u1,
    126         ) );
    127 
    128         // Double check it's there
    129         $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    130 
    131         // Switch user
    132         $this->set_current_user( $this->u2 );
    133 
    134         // Go to the activity permalink page
    135         $this->go_to(
    136             bp_members_get_user_url(
    137                 $this->u1,
    138                 array(
    139                     'single_item_component' => bp_rewrites_get_slug( 'members', 'member_activity', bp_get_activity_slug() ),
    140                     'single_item_action'    => $this->a1,
    141                 )
    142             )
    143         );
    144 
    145         $notifications = BP_Notifications_Notification::get( array(
    146             'user_id' => $this->u1,
    147         ) );
    148 
    149         // Should be untouched
    150         $this->assertEquals( array( $this->a1 ), wp_list_pluck( $notifications, 'item_id' ) );
    151 
    152         $this->set_current_user( $this->u1 );
    153     }
    154 
    155     /**
    156      * @group bp_activity_remove_screen_notifications
    157      * @group mentions
    158      */
    159158    public function test_bp_activity_remove_screen_notifications_on_mentions() {
    160159        $this->create_notifications();
Note: See TracChangeset for help on using the changeset viewer.