+ public function testCanExecute() {
+ $user = $this->getTestUser()->getUser();
+ $user->mRights = [ 'access' ];
+ $action = Action::factory( 'access', $this->getPage(), $this->getContext() );
+ $this->assertNull( $action->canExecute( $user ) );
+ }
+
+ public function testCanExecuteNoRight() {
+ $user = $this->getTestUser()->getUser();
+ $user->mRights = [];
+ $action = Action::factory( 'access', $this->getPage(), $this->getContext() );
+
+ try {
+ $action->canExecute( $user );
+ } catch ( Exception $e ) {
+ $this->assertInstanceOf( PermissionsError::class, $e );
+ }
+ }
+
+ public function testCanExecuteRequiresUnblock() {
+ $user = $this->getTestUser()->getUser();
+ $user->mRights = [];
+
+ $page = $this->getExistingTestPage();
+ $action = Action::factory( 'unblock', $page, $this->getContext() );
+
+ $block = new Block( [
+ 'address' => $user,
+ 'by' => $this->getTestSysop()->getUser()->getId(),
+ 'expiry' => 'infinity',
+ 'sitewide' => false,
+ ] );
+ $block->setRestrictions( [
+ new PageRestriction( 0, $page->getTitle()->getArticleID() ),
+ ] );
+
+ $block->insert();
+
+ try {
+ $action->canExecute( $user );
+ } catch ( Exception $e ) {
+ $this->assertInstanceOf( UserBlockedError::class, $e );
+ }
+
+ $block->delete();
+ }
+