1 node.test NodeFrontPageCallback::testCustomFrontPage()

File

core/modules/node/tests/node.test, line 2260
Tests for node.module.

Class

NodeFrontPageCallback
Test toggle between custom front page callback and default /node callback.

Code

function testCustomFrontPage() {
  $settings = array(
    'title' => $this->randomName(8),
    'promote' => 0,
  );
  // Set a custom front page.
  $node = $this->backdropCreateNode($settings);
  $edit['site_frontpage'] = 'node/' . $node->nid;
  $this->backdropPost('admin/config/system/site-information', $edit, t('Save configuration'));
  $this->backdropGet('<front>');
  $this->assertNoText(t('No content has been promoted yet.'), 'Confirmed /home is not the frontpage.');
  $this->assertText($node->title);

  // Set back to default front page.
  $edit['site_frontpage'] = 'home';
  $this->backdropPost('admin/config/system/site-information', $edit, t('Save configuration'));
  $this->backdropGet('<front>');
  $this->assertText(t('This is your first post! You may edit or delete it.'), "Default /home front page restored.");
}