-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a09bb9f
commit c34669b
Showing
5 changed files
with
133 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* Class Toolbox Test. | ||
* | ||
* @package GP_Toolbox | ||
*/ | ||
|
||
use GP_Toolbox\Toolbox; | ||
|
||
|
||
/** | ||
* Toolbox test case. | ||
*/ | ||
class Test_Toolbox extends GP_UnitTestCase { | ||
Check warning on line 14 in tests/phpunit/includes/test-toolbox.php GitHub Actions / PHP coding standards
|
||
|
||
|
||
/** | ||
* Test add Tools and Dashboard items do side menu. | ||
*/ | ||
public function test_nav_menu_items() { | ||
|
||
$existent_items = array( | ||
'/glotpress/profile/username/' => 'Profile', | ||
'/glotpress/settings/' => 'Settings', | ||
'/wp-login.php?action=logout' => 'Log out', | ||
); | ||
|
||
$new_nav_menu_items = Toolbox::nav_menu_items( $existent_items, 'main' ); | ||
|
||
// Don't add any menu items for non-administrators. | ||
$this->assertSame( | ||
$existent_items, | ||
$new_nav_menu_items, | ||
); | ||
|
||
GP::$administrator_permission->create( | ||
array( | ||
'user_id' => 1, | ||
'action' => 'admin', | ||
) | ||
); | ||
|
||
wp_set_current_user( '1' ); | ||
|
||
$new_nav_menu_items = Toolbox::nav_menu_items( $existent_items, 'side' ); | ||
|
||
// Add menu items for GlotPress administrators. | ||
$this->assertSame( | ||
array( | ||
'/glotpress/tools' => 'Tools', | ||
admin_url() => 'Dashboard', | ||
'/glotpress/profile/username/' => 'Profile', | ||
'/glotpress/settings/' => 'Settings', | ||
'/wp-login.php?action=logout' => 'Log out', | ||
), | ||
$new_nav_menu_items, | ||
|
||
); | ||
|
||
} | ||
|
||
} | ||