Chris@0: drupalLogin($this->drupalCreateUser([ Chris@0: 'access content', Chris@0: 'administer site configuration', Chris@0: ])); Chris@0: $this->drupalCreateContentType(['type' => 'page']); Chris@0: $this->nodePath = "node/" . $this->drupalCreateNode(['promote' => 1])->id(); Chris@0: Chris@0: // Configure 'node' as front page. Chris@0: $this->config('system.site')->set('page.front', '/node')->save(); Chris@0: // Enable front page logging in system_test.module. Chris@0: \Drupal::state()->set('system_test.front_page_output', 1); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test front page functionality. Chris@0: */ Chris@0: public function testDrupalFrontPage() { Chris@0: // Create a promoted node to test the tag on the front page view. Chris@0: $settings = [ Chris@0: 'title' => $this->randomMachineName(8), Chris@0: 'promote' => 1, Chris@0: ]; Chris@0: $this->drupalCreateNode($settings); Chris@0: $this->drupalGet(''); Chris@0: $this->assertTitle('Home | Drupal'); Chris@0: Chris@0: $this->assertText(t('On front page.'), 'Path is the front page.'); Chris@0: $this->drupalGet('node'); Chris@0: $this->assertText(t('On front page.'), 'Path is the front page.'); Chris@0: $this->drupalGet($this->nodePath); Chris@0: $this->assertNoText(t('On front page.'), 'Path is not the front page.'); Chris@0: Chris@0: // Change the front page to an invalid path. Chris@0: $edit = ['site_frontpage' => '/kittens']; Chris@0: $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); Chris@0: $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", ['@path' => $edit['site_frontpage']])); Chris@0: Chris@0: // Change the front page to a path without a starting slash. Chris@0: $edit = ['site_frontpage' => $this->nodePath]; Chris@0: $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); Chris@0: $this->assertRaw(SafeMarkup::format("The path '%path' has to start with a slash.", ['%path' => $edit['site_frontpage']])); Chris@0: Chris@0: // Change the front page to a valid path. Chris@0: $edit['site_frontpage'] = '/' . $this->nodePath; Chris@0: $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); Chris@0: $this->assertText(t('The configuration options have been saved.'), 'The front page path has been saved.'); Chris@0: Chris@0: $this->drupalGet(''); Chris@0: $this->assertText(t('On front page.'), 'Path is the front page.'); Chris@0: $this->drupalGet('node'); Chris@0: $this->assertNoText(t('On front page.'), 'Path is not the front page.'); Chris@0: $this->drupalGet($this->nodePath); Chris@0: $this->assertText(t('On front page.'), 'Path is the front page.'); Chris@0: } Chris@0: Chris@0: }