@@ -24,6 +24,10 @@ |
||
| 24 | 24 | private $required_value; |
| 25 | 25 | |
| 26 | 26 | // phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param string $filter_name |
|
| 30 | + */ |
|
| 27 | 31 | public function __construct( $filter_name, $required_value, $initial_value = false ) { |
| 28 | 32 | $this->filter_name = $filter_name; |
| 29 | 33 | $this->required_value = $required_value; |
@@ -24,21 +24,37 @@ |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | // phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @param string $name |
|
| 30 | + */ |
|
| 27 | 31 | public static function get( $name ) { |
| 28 | 32 | return self::$capabilities[ $name ]; |
| 29 | 33 | } |
| 30 | 34 | |
| 31 | 35 | // phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @param string $name |
|
| 39 | + */ |
|
| 32 | 40 | public static function granted( $name ) { |
| 33 | 41 | return isset( self::$capabilities[ $name ] ) ? self::$capabilities[ $name ]->check()->granted() : false; |
| 34 | 42 | } |
| 35 | 43 | |
| 36 | 44 | // phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @param string $name |
|
| 48 | + */ |
|
| 37 | 49 | public static function build( $name ) { |
| 38 | 50 | return ( new Capabilities\Builder() )->create()->register( $name ); |
| 39 | 51 | } |
| 40 | 52 | |
| 41 | 53 | // phpcs:ignore Squiz.Commenting.FunctionComment.Missing |
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @param Capabilities\AggregateRule $capability |
|
| 57 | + */ |
|
| 42 | 58 | public static function register( $capability, $name ) { |
| 43 | 59 | self::$capabilities[ $name ] = $capability; |
| 44 | 60 | } |
@@ -22,12 +22,16 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Utility functions |
| 25 | + * @param string $role |
|
| 25 | 26 | */ |
| 26 | 27 | protected function setUserRole( $role ) { |
| 27 | 28 | $user = wp_get_current_user(); |
| 28 | 29 | $user->set_role( $role ); |
| 29 | 30 | } |
| 30 | 31 | |
| 32 | + /** |
|
| 33 | + * @param string $cap |
|
| 34 | + */ |
|
| 31 | 35 | protected function addUserCapability( $cap ) { |
| 32 | 36 | $user = wp_get_current_user(); |
| 33 | 37 | $user->add_cap( $cap ); |
@@ -102,6 +106,9 @@ discard block |
||
| 102 | 106 | $this->assertFalse( $capability->check()->granted() ); |
| 103 | 107 | } |
| 104 | 108 | |
| 109 | + /** |
|
| 110 | + * @param string $product_slug |
|
| 111 | + */ |
|
| 105 | 112 | private function mockJetpackPlan( $product_slug ) { |
| 106 | 113 | $this->current_product_slug = $product_slug; |
| 107 | 114 | |
@@ -134,6 +141,9 @@ discard block |
||
| 134 | 141 | $this->assertFalse( $capability->check()->granted() ); |
| 135 | 142 | } |
| 136 | 143 | |
| 144 | + /** |
|
| 145 | + * @param string $supports_slug |
|
| 146 | + */ |
|
| 137 | 147 | private function mockJetpackPlanSupports( $supports_slug ) { |
| 138 | 148 | $this->current_supports_slug = $supports_slug; |
| 139 | 149 | |
@@ -217,6 +227,9 @@ discard block |
||
| 217 | 227 | $this->assertTrue( $capability->check()->granted() ); |
| 218 | 228 | } |
| 219 | 229 | |
| 230 | + /** |
|
| 231 | + * @param boolean $is_active |
|
| 232 | + */ |
|
| 220 | 233 | private function mockJetpackIsActive( $is_active ) { |
| 221 | 234 | $this->current_is_active = $is_active; |
| 222 | 235 | |