Loading core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php +8 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ namespace Drupal\shortcut\Plugin\Block; use Drupal\Core\Block\BlockBase; use Drupal\Core\Session\AccountInterface; /** * Provides a 'Shortcut' block. Loading @@ -29,4 +30,11 @@ public function build() { ); } /** * {@inheritdoc} */ protected function blockAccess(AccountInterface $account) { return $account->hasPermission('access shortcuts'); } } core/modules/shortcut/src/Tests/ShortcutLinksTest.php +24 −1 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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); } } Loading
core/modules/shortcut/src/Plugin/Block/ShortcutsBlock.php +8 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ namespace Drupal\shortcut\Plugin\Block; use Drupal\Core\Block\BlockBase; use Drupal\Core\Session\AccountInterface; /** * Provides a 'Shortcut' block. Loading @@ -29,4 +30,11 @@ public function build() { ); } /** * {@inheritdoc} */ protected function blockAccess(AccountInterface $account) { return $account->hasPermission('access shortcuts'); } }
core/modules/shortcut/src/Tests/ShortcutLinksTest.php +24 −1 Original line number Diff line number Diff line Loading @@ -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. Loading Loading @@ -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); } }