diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php index e9c1e3106803322ed86702ab7600877da01e3887..01421f2042add45f38d8212b3a67769aab674d04 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php @@ -20,7 +20,7 @@ class CustomBlockAccessController implements EntityAccessControllerInterface { * Implements EntityAccessControllerInterface::viewAccess(). */ public function viewAccess(EntityInterface $entity, $langcode = LANGUAGE_DEFAULT, User $account = NULL) { - return user_access('view content', $account); + return TRUE; } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php new file mode 100644 index 0000000000000000000000000000000000000000..0841fd9a8a0ea4130b8810653abbb472866c436d --- /dev/null +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockPageViewTest.php @@ -0,0 +1,57 @@ +<?php + +/** + * @file + * Contains \Drupal\custom_block\Tests\CustomBlockPageViewTest. + */ + +namespace Drupal\custom_block\Tests; + +/** + * Tests the block edit functionality. + */ +class CustomBlockPageViewTest extends CustomBlockTestBase { + + /** + * Permissions to grant admin user. + * + * @var array + */ + protected $permissions = array( + 'administer blocks', + 'access content' + ); + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('block', 'custom_block', 'custom_block_test'); + + /** + * Declares test information. + */ + public static function getInfo() { + return array( + 'name' => 'Custom Block page view', + 'description' => 'Create a block and test block access by attempting to view the block.', + 'group' => 'Custom Block', + ); + } + + /** + * Checks block edit functionality. + */ + public function testPageEdit() { + $this->drupalLogin($this->adminUser); + $block = $this->createCustomBlock(); + + // Attempt to view the block. + $this->drupalGet('custom-block/' . $block->id()); + + // Assert response was '200' and not '403 Access denied'. + $this->assertResponse('200', 'User was able the view the block'); + } + +} diff --git a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module index 76bccdc4db8043709761c3e15efcead72b3494db..a2961fc641fb70a03585281f01f77ad5d2f7a648 100644 --- a/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module +++ b/core/modules/block/custom_block/tests/modules/custom_block_test/custom_block_test.module @@ -73,10 +73,27 @@ function custom_block_test_custom_block_update(CustomBlock $custom_block) { function custom_block_test_custom_block_insert(CustomBlock $custom_block) { // Set the custom_block title to the custom_block ID and save. if ($custom_block->info->value == 'new') { - $custom_block->info->value = 'CustomBlock '. $custom_block->id->value; + $custom_block->info->value = 'CustomBlock ' . $custom_block->id->value; $custom_block->save(); } if ($custom_block->info->value == 'fail_creation') { throw new Exception('Test exception for rollback.'); } } + +/** + * Implements hook_menu(). + */ +function custom_block_test_menu() { + $items = array(); + // Add a block-view callback. + $items['custom-block/%custom_block'] = array( + 'title callback' => 'entity_page_label', + 'title arguments' => array(1), + 'page callback' => 'entity_view', + 'page arguments' => array(1, 'default'), + 'access callback' => 'entity_page_access', + 'access arguments' => array(1, 'view'), + ); + return $items; +}