Skip to content

Commit 6bee627

Browse files
authored
Merge pull request #41 from localgovdrupal/feature/39-fix-tests
Feature/39 fix tests
2 parents 6cdc30b + 7ee1190 commit 6bee627

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44
"type": "drupal-module",
55
"homepage": "https://github.com/localgovdrupal/localgov_subsites_extras",
66
"license": "GPL-2.0-or-later",
7-
"minimum-stability": "dev"
7+
"minimum-stability": "dev",
8+
"require-dev": {
9+
"drupal/localgov_base": "^2.0",
10+
"drupal/localgov_guides": "^2.1",
11+
"drupal/localgov_subsites": "^2.0",
12+
"drupal/localgov_services": "^2.0",
13+
"drupal/localgov_step_by_step": "^2.1"
14+
}
815
}

localgov_subsites_extras.module

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ function localgov_subsites_extras_pathauto_alias_alter(&$alias, array &$context)
9898
return;
9999
}
100100

101-
$subsite_home_path_alias = $subsite_home->toUrl()->toString();
101+
// Get the subsite homepage path alias, not using toUrl() as that could
102+
// cause duplicate sub-directories in the alias.
103+
$subsite_home_path_alias = $subsite_home->path->alias;
102104
$has_no_subsite_home_path_alias = $subsite_home_path_alias === "/node/{$subsite_home->id()}";
103105
if ($has_no_subsite_home_path_alias) {
104106
return;

tests/src/Functional/PathAliasTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ class PathAliasTest extends BrowserTestBase {
1717
* Checks that the Subsite homepage path alias is prepended to child page path
1818
* aliases.
1919
*/
20-
public function testPathAlias() {
20+
public function testPathAlias(): void {
2121

2222
$subsiteHome = $this->getNodeByTitle(self::SUBSITE_HOMEPAGE_TITLE);
2323
$subsiteChild = $this->getNodeByTitle(self::SUBSITE_CHILDPAGE_TITLE);
24-
self::assertStringStartsWith($subsiteHome->path->alias, $subsiteChild->path->alias);
24+
self::assertStringStartsWith($subsiteHome->toUrl()->toString(), $subsiteChild->toUrl()->toString());
2525
}
2626

2727
/**

0 commit comments

Comments
 (0)