class UserLoginAppearanceTestCase extends BackdropWebTestCase {
protected $profile = 'testing';
protected $adminUser;
function setUp() {
parent::setUp(array('user_form_test'));
$this->adminUser = $this->backdropCreateUser(array('administer account settings', 'administer users'));
config_set('system.core', 'user_register', USER_REGISTER_VISITORS);
backdrop_static_reset();
backdrop_flush_all_caches();
}
function testLoginAppearance() {
$login_pages = array(
'user/login',
'user/password',
'user/register',
);
foreach ($login_pages as $page) {
$this->backdropGet($page);
$layout = $this->xpath('//body/div[contains(@class, "layout")]');
$this->assertEqual(count($layout), 0, 'No layout in use on the login page.');
$tabs = $this->xpath('(//nav[contains(@class, "tabs")])//ul[contains(@class, "tabs")]');
$this->assertEqual(count($tabs), 0, 'The tabs nav element was not found.');
$links = $this->xpath('(//ul[contains(@class, "login-links")])');
$this->assertEqual(count($links), 1, 'The links element was found.');
}
$this->backdropLogin($this->adminUser);
$edit = array();
$edit['user_login_appearance'] = 'tabs';
$this->backdropPost('admin/config/people/login', $edit, t('Save configuration'));
$this->backdropLogout();
foreach ($login_pages as $page) {
$this->backdropGet($page);
$layout = $this->xpath('//body/div[contains(@class, "layout")]');
$this->assertEqual(count($layout), 1, 'Layout in use on the login page.');
$tabs = $this->xpath('(//nav[contains(@class, "tabs")])//ul[contains(@class, "tabs")]');
$this->assertEqual(count($tabs), 1, 'The tabs nav element was found.');
$links = $this->xpath('(//ul[contains(@class, "login-links")])');
$this->assertEqual(count($links), 0, 'Login links were not found.');
}
$this->backdropLogin($this->adminUser);
$edit = array();
$edit['user_login_appearance'] = 'links';
$this->backdropPost('admin/config/people/login', $edit, t('Save configuration'));
$this->backdropLogout();
foreach ($login_pages as $page) {
$this->backdropGet($page);
$layout = $this->xpath('//body/div[contains(@class, "layout")]');
$this->assertEqual(count($layout), 1, 'Layout in use on the login page.');
$tabs = $this->xpath('(//nav[contains(@class, "tabs")])//ul[contains(@class, "tabs")]');
$this->assertEqual(count($tabs), 0, 'The tabs nav element was not found.');
$links = $this->xpath('(//ul[contains(@class, "login-links")])');
$this->assertEqual(count($links), 1, 'Login links were found.');
}
$this->backdropLogin($this->adminUser);
$edit = array();
$edit['user_login_appearance'] = 'simplified';
$this->backdropPost('admin/config/people/login', $edit, t('Save configuration'));
$this->backdropGet('user_form_test_current_password/' . $this->adminUser->uid);
$layout = $this->xpath('//body/div[contains(@class, "layout")]');
$this->assertEqual(count($layout), 1, 'Layout in use before enabling hook_user_paths() in user_form_test.');
state_set('user_form_test_user_paths', TRUE);
$this->backdropPost('admin/config/people/login', $edit, t('Save configuration'));
$this->backdropGet('user_form_test_current_password/' . $this->adminUser->uid);
$layout = $this->xpath('//body/div[contains(@class, "layout")]');
$this->assertEqual(count($layout), 0, 'Layout no longer in use after enabling hook_user_paths() in user_form_test.');
$this->backdropLogout();
$this->backdropGet('user/login');
$layout = $this->xpath('//body/div[contains(@class, "layout")]');
$this->assertEqual(count($layout), 1, 'User login form is excluded from user paths by hook_user_paths_alter() in user_form_test.');
}
}