Loading tests/src/Functional/TwigRealContentFunctionalTest.php 0 → 100644 +92 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\twig_real_content\Functional; use Drupal\Tests\BrowserTestBase; /** * This class provides methods specifically for testing something. * * @group twig_real_content */ class TwigRealContentFunctionalTest extends BrowserTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'node', 'test_page_test', 'twig_real_content', ]; /** * A user with authenticated permissions. * * @var \Drupal\Core\Session\AccountInterface */ protected $user; /** * A user with admin permissions. * * @var \Drupal\Core\Session\AccountInterface */ protected $adminUser; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->config('system.site')->set('page.front', '/test-page')->save(); $this->user = $this->drupalCreateUser([]); $this->adminUser = $this->drupalCreateUser([]); $this->adminUser->addRole($this->createAdminRole('admin', 'admin')); $this->adminUser->save(); $this->drupalLogin($this->adminUser); } /** * Tests if installing the module, won't break the site. */ public function testInstallation() { $session = $this->assertSession(); $this->drupalGet('<front>'); // Ensure the status code is success: $session->statusCodeEquals(200); // Ensure the correct test page is loaded as front page: $session->pageTextContains('Test page text.'); } /** * Tests if uninstalling the module, won't break the site. */ public function testUninstallation() { // Go to uninstallation page an uninstall twig_real_content: $session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalGet('/admin/modules/uninstall'); $session->statusCodeEquals(200); $page->checkField('edit-uninstall-twig-real-content'); $page->pressButton('edit-submit'); $session->statusCodeEquals(200); // Confirm uninstall: $page->pressButton('edit-submit'); $session->statusCodeEquals(200); $session->pageTextContains('The selected modules have been uninstalled.'); // Retest the frontpage: $this->drupalGet('<front>'); // Ensure the status code is success: $session->statusCodeEquals(200); // Ensure the correct test page is loaded as front page: $session->pageTextContains('Test page text.'); } } Loading
tests/src/Functional/TwigRealContentFunctionalTest.php 0 → 100644 +92 −0 Original line number Diff line number Diff line <?php namespace Drupal\Tests\twig_real_content\Functional; use Drupal\Tests\BrowserTestBase; /** * This class provides methods specifically for testing something. * * @group twig_real_content */ class TwigRealContentFunctionalTest extends BrowserTestBase { /** * {@inheritdoc} */ protected static $modules = [ 'node', 'test_page_test', 'twig_real_content', ]; /** * A user with authenticated permissions. * * @var \Drupal\Core\Session\AccountInterface */ protected $user; /** * A user with admin permissions. * * @var \Drupal\Core\Session\AccountInterface */ protected $adminUser; /** * {@inheritdoc} */ protected $defaultTheme = 'stark'; /** * {@inheritdoc} */ protected function setUp(): void { parent::setUp(); $this->config('system.site')->set('page.front', '/test-page')->save(); $this->user = $this->drupalCreateUser([]); $this->adminUser = $this->drupalCreateUser([]); $this->adminUser->addRole($this->createAdminRole('admin', 'admin')); $this->adminUser->save(); $this->drupalLogin($this->adminUser); } /** * Tests if installing the module, won't break the site. */ public function testInstallation() { $session = $this->assertSession(); $this->drupalGet('<front>'); // Ensure the status code is success: $session->statusCodeEquals(200); // Ensure the correct test page is loaded as front page: $session->pageTextContains('Test page text.'); } /** * Tests if uninstalling the module, won't break the site. */ public function testUninstallation() { // Go to uninstallation page an uninstall twig_real_content: $session = $this->assertSession(); $page = $this->getSession()->getPage(); $this->drupalGet('/admin/modules/uninstall'); $session->statusCodeEquals(200); $page->checkField('edit-uninstall-twig-real-content'); $page->pressButton('edit-submit'); $session->statusCodeEquals(200); // Confirm uninstall: $page->pressButton('edit-submit'); $session->statusCodeEquals(200); $session->pageTextContains('The selected modules have been uninstalled.'); // Retest the frontpage: $this->drupalGet('<front>'); // Ensure the status code is success: $session->statusCodeEquals(200); // Ensure the correct test page is loaded as front page: $session->pageTextContains('Test page text.'); } }