Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Merge requests
!1791
#3262873
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
#3262873
issue/drupal-3262873:3262873
into
9.4.x
Overview
0
Commits
4
Pipelines
0
Changes
1
Open
Alex Pott
requested to merge
issue/drupal-3262873:3262873
into
9.4.x
3 years ago
Overview
0
Commits
4
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
9.4.x
version 2
05c5f1f4
3 years ago
version 1
a3ffa23a
3 years ago
9.4.x (HEAD)
and
latest version
latest version
05acfce5
4 commits,
3 years ago
version 2
05c5f1f4
3 commits,
3 years ago
version 1
a3ffa23a
2 commits,
3 years ago
1 file
+
127
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
core/modules/path_alias/tests/src/Functional/MultilingualUiMonolingualContentTest.php
0 → 100644
+
127
−
0
Options
<?php
namespace
Drupal\Tests\path_alias\Functional
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\Tests\Traits\Core\PathAliasTestTrait
;
/**
* Tests sites with multiple UI languages but content in a single language.
*
* @group path_alias
*/
class
MultilingualUiMonolingualContentTest
extends
BrowserTestBase
{
use
PathAliasTestTrait
;
/**
* Modules to enable.
*
* @var array
*/
protected
static
$modules
=
[
'node'
,
'locale'
,
'path_alias'
,
'path'
];
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
drupalCreateContentType
([
'type'
=>
'article'
]);
// @todo create an admin user with permissions
$this
->
drupalLogin
(
$this
->
rootUser
);
// Add the German language
$this
->
drupalGet
(
'admin/config/regional/language/add'
);
$this
->
submitForm
([
'predefined_langcode'
=>
'de'
],
'Add language'
);
$this
->
assertSession
()
->
pageTextContains
(
'The language German has been created and can now be used.'
);
// Change the default language to German
$this
->
submitForm
([
'site_default_language'
=>
'de'
],
'Save configuration'
);
$this
->
assertSession
()
->
pageTextContains
(
'Configuration saved.'
);
// Set up detection and selection to not use URL detection.
$this
->
drupalGet
(
'admin/config/regional/language/detection'
);
$this
->
submitForm
([
'language_interface[enabled][language-url]'
=>
0
,
'language_interface[enabled][language-user]'
=>
1
,
],
'Save settings'
);
$this
->
assertSession
()
->
pageTextContains
(
'Language detection configuration saved.'
);
// Enable the language selector on article nodes.
$this
->
drupalGet
(
'admin/config/regional/content-language'
);
$this
->
submitForm
([
"entity_types[node]"
=>
TRUE
,
"settings[node][article][settings][language][language_alterable]"
=>
TRUE
],
'Save configuration'
);
$this
->
drupalLogout
();
}
/**
* Tests URL aliases work.
*/
public
function
testPathAlias
()
{
// @todo create an admin user with permissions
$this
->
drupalLogin
(
$this
->
rootUser
);
$this
->
drupalGet
(
'node/add/article'
);
$this
->
submitForm
([
'title[0][value]'
=>
'Test content DE'
,
'path[0][alias]'
=>
'/test-content-de'
],
'Save'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
// Should be on /test-content but we'll be on node/1.
$this
->
assertSession
()
->
linkByHrefExists
(
'/test-content-de'
);
$this
->
drupalGet
(
'test-content-de'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
// Prove the current state of the entities.
$node
=
$this
->
drupalGetNodeByTitle
(
'Test content DE'
);
$this
->
assertSame
(
'de'
,
$node
->
language
()
->
getId
());
$this
->
assertSame
(
'en'
,
$this
->
rootUser
->
getPreferredLangcode
());
// Change the user preferred language to de.
$this
->
drupalGet
(
'user/1/edit'
);
$this
->
submitForm
([
'preferred_langcode'
=>
'de'
],
'Save'
);
$this
->
assertSession
()
->
pageTextContains
(
'The changes have been saved.'
);
$this
->
drupalGet
(
'test-content-de'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
// Add an english article.
$this
->
drupalGet
(
'node/add/article'
);
$this
->
submitForm
([
'title[0][value]'
=>
'Test content EN'
,
'path[0][alias]'
=>
'/test-content-en'
,
'langcode[0][value]'
=>
'en'
],
'Save'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
$this
->
assertSession
()
->
linkByHrefExists
(
'/test-content-en'
);
$this
->
drupalGet
(
'test-content-en'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
// Prove the current state of the node.
$node
=
$this
->
drupalGetNodeByTitle
(
'Test content EN'
);
$this
->
assertSame
(
'en'
,
$node
->
language
()
->
getId
());
// Change the user preferred language to en.
$this
->
drupalGet
(
'user/1/edit'
);
$this
->
submitForm
([
'preferred_langcode'
=>
'en'
],
'Save'
);
$this
->
assertSession
()
->
pageTextContains
(
'The changes have been saved.'
);
$this
->
drupalGet
(
'test-content-en'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
}
/**
* Tests URL aliases work after setting the prefix to an empty string.
*/
public
function
testPathAliasAfterFixingPathPrefixes
()
{
// @todo create an admin user with permissions
$this
->
drupalLogin
(
$this
->
rootUser
);
// Set the language url prefix config (even though it is disabled).
$this
->
drupalGet
(
'admin/config/regional/language/detection'
);
$this
->
clickLink
(
'Configure'
);
$this
->
assertSession
()
->
pageTextContains
(
'Part of the URL that determines language'
);
$this
->
submitForm
([
'prefix[de]'
=>
''
],
'Save configuration'
);
$this
->
assertSession
()
->
pageTextContains
(
'The configuration options have been saved.'
);
// The DE node test will now pass. The EN node will not.
$this
->
testPathAlias
();
}
}
Loading