Skip to content
Snippets Groups Projects
Commit 1d6b9c7e authored by Michael Strelan's avatar Michael Strelan Committed by Michael Strelan
Browse files

Add test coverage

parent 1f7b881a
No related branches found
No related tags found
1 merge request!5026Issue #3096092: Make "path_alias" module optional
<?php
declare(strict_types=1);
namespace Drupal\Tests\path_alias\Functional;
use Drupal\node\NodeInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\Traits\Core\PathAliasTestTrait;
/**
* Tests site information form alter functionality.
*
* @group path_alias
*/
class SiteInformationFormAlterTest extends BrowserTestBase {
use PathAliasTestTrait;
/**
* {@inheritdoc}
*/
protected static $modules = ['node', 'path_alias'];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* The node that is created for testing.
*/
protected NodeInterface $node;
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Create admin user, log in admin user, and create a node type.
$this->drupalLogin($this->drupalCreateUser([
'access content',
'administer site configuration',
]));
$this->drupalCreateContentType(['type' => 'page']);
}
/**
* Tests form alter.
*/
public function testFormAlter(): void {
$node = $this->drupalCreateNode();
$this->createPathAlias('/node/' . $node->id(), '/foo');
// Configure site information.
$this->drupalGet('admin/config/system/site-information');
$this->submitForm([
'site_frontpage' => '/foo',
'site_403' => '/foo',
'site_404' => '/foo',
], 'Save configuration');
$this->assertSession()->pageTextContains('The configuration options have been saved.');
// Check that the system paths has been saved.
$this->assertSame('/node/1', $this->config('system.site')->get('page.front'));
$this->assertSame('/node/1', $this->config('system.site')->get('page.403'));
$this->assertSame('/node/1', $this->config('system.site')->get('page.404'));
// Check that only the front page path is converted to an alias.
$page = $this->getSession()->getPage();
$this->assertSame('/foo', $page->findField('site_frontpage')->getValue());
$this->assertSame('/node/1', $page->findField('site_403')->getValue());
$this->assertSame('/node/1', $page->findField('site_404')->getValue());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment