Changeset 11975
- Timestamp:
- 07/18/2022 08:08:49 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-profiles/tests/e2e.php
r11950 r11975 23 23 } 24 24 25 const TEST_USERNAME = 'iandunn-test'; 25 const TRANSLATOR_ID = 12824495; // iandunn-test 26 const REVIEWER_ID = 20508422; // metatestaccount 27 const TRANSLATION_SET_ID = 3; 26 28 27 29 /** @var array $args */ … … 29 31 30 32 function main( $case ) { 31 $ user = get_user_by( 'slug', TEST_USERNAME);33 $translator = get_user_by( 'id', TRANSLATOR_ID ); 32 34 33 35 try { 34 call_user_func( __NAMESPACE__ . "\\test_$case", $user ); 36 add_action( 'gp_pre_can_user', __NAMESPACE__ . '\grant_editor_capabilities', 10, 2 ); 37 call_user_func( __NAMESPACE__ . "\\test_$case", $translator ); 38 echo "\nThe daily digest count should have been bumped on https://profiles.wordpress.org/$translator->user_nicename/, and/or the reviewer. \n"; 35 39 36 40 } catch ( Exception $exception ) { 37 41 echo $exception->getMessage(); 38 39 42 } 40 43 } 41 44 42 function test_add( WP_User $user ) { 45 function grant_editor_capabilities( $preliminary, $filter_args ) { 46 if ( REVIEWER_ID === $filter_args['user_id'] ) { 47 return true; 48 } else { 49 return $preliminary; 50 } 51 } 52 53 function test_suggest( WP_User $user ) { 54 wp_set_current_user( TRANSLATOR_ID ); 55 43 56 $translation = new GP_Translation( array( 44 'user_id' => $user->ID, 45 'status' => 'waiting', 57 'user_id' => $user->ID, 58 'status' => 'waiting', 59 'translation_set_id' => TRANSLATION_SET_ID, 46 60 ) ); 47 61 GlotPress_Profiles\add_single_translation_activity( $translation ); 62 } 63 64 function test_approve( WP_User $translator ) { 65 wp_set_current_user( REVIEWER_ID ); 66 67 $_POST['status'] = 'current'; 48 68 49 69 $previous_translation = new GP_Translation( array( 50 'user_id' => $user->ID, 51 'status' => 'waiting', 70 'user_id' => $translator->ID, 71 'status' => 'waiting', 72 'translation_set_id' => TRANSLATION_SET_ID, 52 73 ) ); 53 74 $translation = new GP_Translation( array( 54 'user_id' => $ user->ID,75 'user_id' => $translator->ID, 55 76 'status' => 'current', 56 77 ) ); 57 78 GlotPress_Profiles\add_single_translation_activity( $translation, $previous_translation ); 58 59 echo "\nThe daily digest count should have been bumped on https://profiles.wordpress.org/$user->user_nicename/ \n";60 79 } 61 80 62 function test_bulk_approve( WP_User $user ) { 81 function test_bulk_approve( WP_User $translator ) { 82 wp_set_current_user( REVIEWER_ID ); 83 63 84 $bulk = array( 64 85 'action' => 'approve', … … 66 87 ); 67 88 GlotPress_Profiles\add_bulk_translation_activity( new GP_Project(), new GP_Locale(), new GP_Translation_Set(), $bulk ); 89 } 68 90 69 echo "\nThe daily digest count should have been bumped on https://profiles.wordpress.org/$user->user_nicename/ \n"; 91 function test_bulk_reject( WP_User $translator ) { 92 wp_set_current_user( REVIEWER_ID ); 93 94 $bulk = array( 95 'action' => 'reject', 96 'row-ids' => array( '512-43', '514-44' ), 97 ); 98 GlotPress_Profiles\add_bulk_translation_activity( new GP_Project(), new GP_Locale(), new GP_Translation_Set(), $bulk ); 70 99 }
Note: See TracChangeset
for help on using the changeset viewer.