Skip to content
Snippets Groups Projects
Commit 18802aaa authored by Alex Pott's avatar Alex Pott
Browse files

Issue #893868 by ericbroder, jaxxed, iMiksu, yogen.prasad, a.ross, mrfelton,...

Issue #893868 by ericbroder, jaxxed, iMiksu, yogen.prasad, a.ross, mrfelton, VM, lauriii, Jasu_M: Login block not shown on user/register
parent 64d6415c
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -77,7 +77,7 @@ public static function create(ContainerInterface $container, array $configuratio
*/
protected function blockAccess(AccountInterface $account) {
$route_name = $this->routeMatch->getRouteName();
if ($account->isAnonymous() && !in_array($route_name, array('user.register', 'user.login', 'user.logout'))) {
if ($account->isAnonymous() && !in_array($route_name, array('user.login', 'user.logout'))) {
return AccessResult::allowed()
->addCacheContexts(['route.name', 'user.roles:anonymous']);
}
......
......@@ -39,6 +39,30 @@ protected function setUp() {
$this->drupalLogout($this->adminUser);
}
/**
* Tests that user login block is hidden from user/login.
*/
function testUserLoginBlockVisibility() {
// Array keyed list where key being the URL address and value being expected
// visibility as boolean type.
$paths = [
'node' => TRUE,
'user/login' => FALSE,
'user/register' => TRUE,
'user/password' => TRUE,
];
foreach ($paths as $path => $expected_visibility) {
$this->drupalGet($path);
$elements = $this->xpath('//div[contains(@class,"block-user-login-block") and @role="form"]');
if ($expected_visibility) {
$this->assertTrue(!empty($elements), 'User login block in path "' . $path . '" should be visible');
}
else {
$this->assertTrue(empty($elements), 'User login block in path "' . $path . '" should not be visible');
}
}
}
/**
* Test the user login block.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment