Commit 7bf1e5a4 authored by alexpott's avatar alexpott

Issue #2449633 by joshi.rohit100, pjonckiere, willzyx, andypost:...

Issue #2449633 by joshi.rohit100, pjonckiere, willzyx, andypost: ShortcutsBlock does not respect the 'access shortcuts' permission
parent a805ce2d
......@@ -8,6 +8,7 @@
namespace Drupal\shortcut\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Session\AccountInterface;
/**
* Provides a 'Shortcut' block.
......@@ -29,4 +30,11 @@ public function build() {
);
}
/**
* {@inheritdoc}
*/
protected function blockAccess(AccountInterface $account) {
return $account->hasPermission('access shortcuts');
}
}
......@@ -24,7 +24,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
*
* @var array
*/
public static $modules = array('router_test', 'views');
public static $modules = array('router_test', 'views', 'block');
/**
* Tests that creating a shortcut works properly.
......@@ -327,4 +327,27 @@ private function verifyAccessShortcutsPermissionForEditPages() {
}
}
/**
* Tests that the 'access shortcuts' permission is required to access the
* shortcut block.
*/
public function testShortcutBlockAccess() {
// Creates a block instance and place in a region through api.
$block = $this->drupalPlaceBlock('shortcuts');
// Verify that users with the 'access shortcuts' permission can see the
// shortcut block.
$this->drupalLogin($this->shortcutUser);
$this->drupalGet('');
$this->assertBlockAppears($block);
$this->drupalLogout();
// Verify that users without the 'access shortcuts' permission can see the
// shortcut block.
$this->drupalLogin($this->drupalCreateUser(array()));
$this->drupalGet('');
$this->assertNoBlockAppears($block);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment