-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Fixes - Clarified helper text in the taxonomy field - Updated support dashboard page with new features - Enhanced security - Updated dependencies
- Loading branch information
Showing
6 changed files
with
100 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,65 @@ | ||
<?php | ||
/** | ||
* WordPress unit test plugin. | ||
* | ||
* @package feedzy-rss-feeds-pro | ||
* @subpackage Tests | ||
* @copyright Copyright (c) 2017, Bogdan Preda | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License | ||
* @since 1.2.0 | ||
*/ | ||
class Test_Post_Access extends WP_UnitTestCase { | ||
|
||
/** | ||
* Utility method to generate a random 5 char string. | ||
* | ||
* @since 3.0.12 | ||
* @access private | ||
* @return string | ||
*/ | ||
private function get_rand_name() { | ||
$characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | ||
$result = ''; | ||
for ( $i = 0; $i < 5; $i ++ ) { | ||
$result .= $characters[ mt_rand( 0, 61 ) ]; | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
public function test_custom_post_access() { | ||
$random_name = $this->get_rand_name(); | ||
$admin_id = $this->factory->user->create( | ||
array( | ||
'role' => 'administrator', | ||
) | ||
); | ||
wp_set_current_user( $admin_id ); | ||
$p = $this->factory->post->create_and_get( | ||
array( | ||
'post_title' => $random_name, | ||
'post_type' => 'feedzy_categories', | ||
'post_author' => $admin_id, | ||
) | ||
); | ||
do_action( 'save_post', $p->ID, $p ); | ||
$this->assertEquals( $p->post_title, $random_name ); | ||
$this->assertEquals( $p->post_type, 'feedzy_categories' ); | ||
|
||
$this->assertTrue( feedzy_current_user_can() ); | ||
$this->assertTrue( current_user_can( 'edit_post', $p->ID ) ); | ||
|
||
|
||
$contributor_id = $this->factory->user->create( | ||
array( | ||
'role' => 'contributor', | ||
) | ||
); | ||
wp_set_current_user( $contributor_id ); | ||
|
||
$this->assertFalse( feedzy_current_user_can() ); | ||
$this->assertFalse( current_user_can( 'edit_post', $p->ID ) ); | ||
|
||
} | ||
|
||
} |