diff --git a/core/modules/block_place/css/block-place.css b/core/modules/block_place/css/block-place.css index 961952f..f47061f 100644 --- a/core/modules/block_place/css/block-place.css +++ b/core/modules/block_place/css/block-place.css @@ -3,6 +3,7 @@ * Styling for block_place module regions and buttons during block placement. */ +/* Borrows styling from Bartik's demo-block.css. */ .block-place-region { background: #ffff66; border: 1px dotted #9f9e00; @@ -27,5 +28,4 @@ .region:hover { outline: 1px dashed #9f9e00; - } diff --git a/core/modules/block_place/icons/ffffff/place-block.svg b/core/modules/block_place/icons/ffffff/place-block.svg index b83dfd9..8b45b53 100644 --- a/core/modules/block_place/icons/ffffff/place-block.svg +++ b/core/modules/block_place/icons/ffffff/place-block.svg @@ -1 +1 @@ - + diff --git a/core/modules/block_place/src/Tests/BlockPlaceTest.php b/core/modules/block_place/tests/src/Functional/BlockPlaceTest.php similarity index 66% rename from core/modules/block_place/src/Tests/BlockPlaceTest.php rename to core/modules/block_place/tests/src/Functional/BlockPlaceTest.php index 93f3ddc..8dc051a 100644 --- a/core/modules/block_place/src/Tests/BlockPlaceTest.php +++ b/core/modules/block_place/tests/src/Functional/BlockPlaceTest.php @@ -1,16 +1,16 @@ drupalLogin($this->drupalCreateUser([ 'access administration pages', @@ -31,27 +31,34 @@ function testPlacingBlocks() { 'view the administration theme', ])); $this->drupalGet(Url::fromRoute('')); - $this->assertLink('Place block'); $this->clickLink('Place block'); // Each region should have one link to place a block. $theme_name = $this->container->get('theme.manager')->getActiveTheme()->getName(); $visible_regions = system_region_list($theme_name, REGIONS_VISIBLE); - $this->assertTrue(count($visible_regions) > 0, 'At least one region is visible'); + $this->assertGreaterThan(0, count($visible_regions)); + $default_theme = $this->config('system.theme')->get('default'); $block_library_url = Url::fromRoute('block.admin_library', ['theme' => $default_theme]); foreach ($visible_regions as $region => $name) { $block_library_url->setOption('query', ['region' => $region]); $links = $this->xpath('//a[contains(@href, :href)]', [':href' => $block_library_url->toString()]); - $this->assertEqual(1, count($links), 'Found one matching link for region ' . $region); - list($path, $query_string) = explode('?', $links[0]['href'], 2); + $this->assertEquals(1, count($links)); + + list(, $query_string) = explode('?', $links[0]->getAttribute('href'), 2); parse_str($query_string, $query_parts); - $this->assertFalse(empty($query_parts['destination']), 'Destination query string is set in href'); - /* Get the text inside the div->a->span->em */ + $this->assertNotEmpty($query_parts['destination']); + + // Get the text inside the div->a->span->em. $demo_block = $this->xpath('//div[@class="block-place-region"]/a[text()="Place block"]//em[text()="' . $name . '"]'); - $this->assertEqual('1', count($demo_block), 'Found one matching DIV including the region name: ' . $name); + $this->assertEquals(1, count($demo_block)); } + } + /** + * Tests placing blocks as an unprivileged user. + */ + public function testPlacingBlocksUnprivileged() { // Create a user who cannot administer blocks. $this->drupalLogin($this->drupalCreateUser([ 'access administration pages', @@ -59,10 +66,11 @@ function testPlacingBlocks() { 'view the administration theme', ])); $this->drupalGet(Url::fromRoute('')); - $this->assertNoLink('Place block'); + $links = $this->xpath('//a[text()=:label]', [':label' => 'Place block']); + $this->assertEmpty($links); $this->drupalGet(Url::fromRoute('block.admin_library', ['theme' => 'classy'])); - $this->assertResponse(403); + $this->assertSession()->statusCodeEquals(403); } }