diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php new file mode 100644 index 0000000..071f5a4 --- /dev/null +++ b/core/modules/block/lib/Drupal/block/Tests/BlockSystemBrandingTest.php @@ -0,0 +1,94 @@ + 'System Branding Block', + 'description' => 'Tests branding block display.', + 'group' => 'Block', + ); + } + + function setUp() { + parent::setUp(); + // Set a site slogan. + \Drupal::config('system.site') + ->set('slogan', 'Community plumbing') + ->save(); + // Add the system branding block to the page. + $this->drupalPlaceBlock('system_branding_block', array('region' => 'header', 'id' => 'sitebranding')); + } + + /** + * Tests system branding block configuration. + */ + function testSystemBrandingSettings() { + // With the default block settings, test that all branding elements are + // displayed. + $this->drupalGet(''); + $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); + $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); + $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($logo_element), 'The branding block logo was found.'); + $this->assertTrue(!empty($sitename_element), 'The branding block site name was found.'); + $this->assertTrue(!empty($slogan_element), 'The branding block slogan was found.'); + + // Turn just the logo off, and re-test all branding elements. + \Drupal::config('block.block.sitebranding') + ->set('settings.site_logo', 0) + ->save(); + $this->drupalGet(''); + $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); + $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); + $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); + $this->assertTrue(empty($logo_element), 'The branding block logo was disabled.'); + $this->assertTrue(!empty($sitename_element), 'The branding block site name was found.'); + $this->assertTrue(!empty($slogan_element), 'The branding block slogan was found.'); + + // Turn just the site name off, and re-test all branding elements. + \Drupal::config('block.block.sitebranding') + ->set('settings.site_logo', 1) + ->set('settings.site_name', 0) + ->save(); + $this->drupalGet(''); + $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); + $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); + $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($logo_element), 'The branding block logo was found.'); + $this->assertTrue(empty($sitename_element), 'The branding block site name was disabled.'); + $this->assertTrue(!empty($slogan_element), 'The branding block slogan was found.'); + + // Turn just the site slogan off, and re-test all branding elements. + \Drupal::config('block.block.sitebranding') + ->set('settings.site_name', 1) + ->set('settings.site_slogan', 0) + ->save(); + $this->drupalGet(''); + $logo_element = $this->xpath('//div[@id="block-sitebranding"]//a[@class="site-logo"]'); + $sitename_element = $this->xpath('//div[@id="block-sitebranding"]//strong[@class="site-name"]'); + $slogan_element = $this->xpath('//div[@id="block-sitebranding"]//div[@class="site-slogan"]'); + $this->assertTrue(!empty($logo_element), 'The branding block logo was found.'); + $this->assertTrue(!empty($sitename_element), 'The branding block site name was found.'); + $this->assertTrue(empty($slogan_element), 'The branding block slogan was disabled.'); + + } + +}