mirror of
https://github.com/e107inc/e107.git
synced 2025-08-13 10:04:35 +02:00
New API to detect if social login is enabled site-wide
The site-wide social login system is now backwards-compatible with how
the social_login_active core pref worked since commit
3b2d8333b6
.
social_login_active's least significant bit is now treated as a global
bit, so if it's not set, no other bits are allowed to be set. This
un-breaks all existing checks for whether social_login_active is empty.
Except in themes, the social_login_active check has been replaced with
an e_user_provider API to check if social login is enabled site-wide.
This commit is contained in:
@@ -55,22 +55,48 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
|
||||
$this->manager = new SocialLoginConfigManager($this->pref);
|
||||
}
|
||||
|
||||
public function testFlagSetting()
|
||||
public function testFlagSettingOff()
|
||||
{
|
||||
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_FLAGS, 0x0);
|
||||
$this->manager = new SocialLoginConfigManager($this->pref);
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
public function testFlagSettingGlobalOffPreventsOthersOn()
|
||||
{
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_GLOBAL, 0);
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE, 1);
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
public function testFlagSettingGlobalOnAllowsOtherToggles()
|
||||
{
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_GLOBAL, 1);
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE, 0);
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE, 1);
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't break existing client code that checks if social_login_active is 0 or not!
|
||||
* If the global bit is 0, all the other bits should be 0, too.
|
||||
*/
|
||||
public function testFlagGlobalOffTurnsAllOff()
|
||||
{
|
||||
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_FLAGS, ~0);
|
||||
$this->manager = new SocialLoginConfigManager($this->pref);
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertTrue($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
|
||||
$this->manager->setFlag(SocialLoginConfigManager::ENABLE_BIT_GLOBAL, 0);
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL));
|
||||
$this->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE));
|
||||
}
|
||||
|
||||
public function testIsProviderEnabled()
|
||||
|
Reference in New Issue
Block a user