Ejemplo n.º 1
0
 /**
  * Remove event-related capabilities
  *
  * @return void
  */
 private function clear_capabilities()
 {
     $capabilities = new Tribe__Events__Capabilities();
     $capabilities->remove_all_caps();
 }
 /**
  * @param string $role
  * @param bool $can
  *
  * @dataProvider contributor_or_higher
  */
 public function tests_role_can_edit_venues($role, $can)
 {
     $caps = new Tribe__Events__Capabilities();
     $caps->register_post_type_caps(Tribe__Events__Main::VENUE_POST_TYPE, $role);
     /** @var WP_User $user */
     $user = $this->factory->user->create_and_get(array('role' => $role));
     $this->assertEquals($can, $user->has_cap('edit_tribe_venues'), "Check if {$role} can edit venue");
 }
 public function test_remove_caps()
 {
     /** @var WP_User $user */
     $user = $this->factory->user->create_and_get(array('role' => 'editor'));
     $caps = new Tribe__Events__Capabilities();
     $this->assertTrue($user->has_cap('edit_tribe_events'));
     // baseline
     $caps->remove_post_type_caps(Tribe__Events__Main::POSTTYPE, 'editor');
     $user = new WP_User($user);
     // to reinit caps
     $this->assertFalse($user->has_cap('edit_tribe_events'));
     // now put everything back where we found it
     $caps->register_post_type_caps(Tribe__Events__Main::POSTTYPE, 'editor');
     $user = new WP_User($user);
     // to reinit caps
     $this->assertTrue($user->has_cap('edit_tribe_events'));
 }