From 331aa5f99ecd01b73b3e35f44085afec3a0703e3 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 28 Feb 2020 10:33:50 -0800 Subject: [PATCH] Interface fixes and refactoring to e107 conventions/standards. --- e107_core/controllers/system/xup.php | 10 +- .../shortcodes/batch/signup_shortcodes.php | 2 +- e107_handlers/e107_class.php | 2 +- e107_handlers/user_handler.php | 8 +- e107_plugins/social/admin_config.php | 171 +++++++++++++++--- .../social_login_config.php} | 4 +- .../languages/English/English_admin.php | 5 +- e107_plugins/social/social_setup.php | 12 +- .../social/SocialLoginConfigManagerTest.php | 56 +++--- .../unit/plugins/social/social_setupTest.php | 28 +-- 10 files changed, 214 insertions(+), 84 deletions(-) rename e107_plugins/social/{SocialLoginConfigManager.php => includes/social_login_config.php} (98%) diff --git a/e107_core/controllers/system/xup.php b/e107_core/controllers/system/xup.php index f8c58dde4..4e7943350 100644 --- a/e107_core/controllers/system/xup.php +++ b/e107_core/controllers/system/xup.php @@ -21,15 +21,15 @@ class core_system_xup_controller extends eController var $backUrl = null; /** - * @var SocialLoginConfigManager + * @var social_login_config */ private $social_login_config_manager; public function __construct(eRequest $request, eResponse $response = null) { parent::__construct($request, $response); - require_once(e_PLUGIN."social/SocialLoginConfigManager.php"); - $this->social_login_config_manager = new SocialLoginConfigManager(e107::getConfig()); + require_once(e_PLUGIN."social/includes/social_login_config.php"); + $this->social_login_config_manager = new social_login_config(e107::getConfig()); } public function init() @@ -65,8 +65,8 @@ class core_system_xup_controller extends eController public function actionTest() { - require_once(e_PLUGIN . "social/SocialLoginConfigManager.php"); - $manager = new SocialLoginConfigManager(e107::getConfig()); + require_once(e_PLUGIN . "social/includes/social_login_config.php"); + $manager = new social_login_config(e107::getConfig()); if (!$manager->isFlagActive($manager::ENABLE_BIT_TEST_PAGE)) { diff --git a/e107_core/shortcodes/batch/signup_shortcodes.php b/e107_core/shortcodes/batch/signup_shortcodes.php index ef363a366..751e11240 100755 --- a/e107_core/shortcodes/batch/signup_shortcodes.php +++ b/e107_core/shortcodes/batch/signup_shortcodes.php @@ -112,7 +112,7 @@ class signup_shortcodes extends e_shortcode } - $manager = new SocialLoginConfigManager(e107::getConfig()); + $manager = new social_login_config(e107::getConfig()); $providers = $manager->getValidConfiguredProviderConfigs(); foreach ($providers as $p => $v) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 0804875fa..f9f6f23ae 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -343,7 +343,7 @@ class e107 * @param $e107_paths * @param $e107_root_path * @param array $e107_config_override - * @return e107 + * @return object|boolean e107 */ public function initInstall($e107_paths, $e107_root_path, $e107_config_override = array()) { diff --git a/e107_handlers/user_handler.php b/e107_handlers/user_handler.php index e0c2fa3bc..a89356dbd 100644 --- a/e107_handlers/user_handler.php +++ b/e107_handlers/user_handler.php @@ -1104,14 +1104,14 @@ class e_user_provider protected $hybridauth; protected $_config = array(); /** - * @var SocialLoginConfigManager + * @var social_login_config */ protected $social_login_config_manager; public function __construct($provider = null, $config = array()) { - require_once(e_PLUGIN . "social/SocialLoginConfigManager.php"); - $this->social_login_config_manager = new SocialLoginConfigManager(e107::getConfig()); + require_once(e_PLUGIN . "social/includes/social_login_config.php"); + $this->social_login_config_manager = new social_login_config(e107::getConfig()); if (!empty($config)) { @@ -1432,7 +1432,7 @@ class e_user_provider */ public function isSocialLoginEnabled() { - return $this->social_login_config_manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_GLOBAL); + return $this->social_login_config_manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL); } /** diff --git a/e107_plugins/social/admin_config.php b/e107_plugins/social/admin_config.php index 151f7aefa..bf29bdd37 100644 --- a/e107_plugins/social/admin_config.php +++ b/e107_plugins/social/admin_config.php @@ -12,6 +12,111 @@ if (!getperms('P')) e107::lan('social',true, true); e107::lan('social',false, true); +// test legacy upgrade interface. +/* +$legacy = array( + 'FakeProviderNeverExisted' => + array( + 'enabled' => '1', + ), + 'AOL' => + array( + 'enabled' => '1', + ), + 'Facebook' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'scope' => 'c', + 'enabled' => '1', + ), + 'Foursquare' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'enabled' => '1', + ), + 'Github' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'scope' => 'c', + 'enabled' => '1', + ), + 'Google' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'scope' => 'c', + 'enabled' => '1', + ), + 'LinkedIn' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'enabled' => '1', + ), + 'Live' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'enabled' => '1', + ), + 'OpenID' => + array( + 'enabled' => '1', + ), + 'Steam' => + array( + 'keys' => + array( + 'key' => 'a', + ), + 'enabled' => '1', + ), + 'Twitter' => + array( + 'keys' => + array( + 'key' => 'a', + 'secret' => 'b', + ), + 'enabled' => '1', + ), + 'Yahoo' => + array( + 'keys' => + array( + 'id' => 'a', + 'secret' => 'b', + ), + 'enabled' => '1', + ), +); + +e107::getConfig()->setPref('social_login', $legacy); +*/ + + + class social_adminarea extends e_admin_dispatcher { @@ -50,7 +155,7 @@ class social_adminarea extends e_admin_dispatcher public function init() { - $slcm = new SocialLoginConfigManager(e107::getConfig()); + $slcm = new social_login_config(e107::getConfig()); $supported_providers = $slcm->getSupportedProviders(); $configured_providers = $slcm->getConfiguredProviders(); $unsupported_providers = array_diff($configured_providers, $supported_providers); @@ -70,7 +175,7 @@ class social_adminarea extends e_admin_dispatcher -require_once("SocialLoginConfigManager.php"); +require_once("includes/social_login_config.php"); class social_ui extends e_admin_ui { @@ -131,7 +236,7 @@ class social_ui extends e_admin_ui protected $social_logins = array(); /** - * @var SocialLoginConfigManager + * @var social_login_config */ protected $social_login_config_manager; @@ -141,7 +246,7 @@ class social_ui extends e_admin_ui public function init() { - $this->social_login_config_manager = new SocialLoginConfigManager(e107::getConfig()); + $this->social_login_config_manager = new social_login_config(e107::getConfig()); if(!empty($_POST['save_social_logins']) ) { @@ -152,10 +257,14 @@ class social_ui extends e_admin_ui $this->social_login_config_manager->setProviderConfig($provider_name, $raw_updated_social_login); } - $social_login_flags = - !!$_POST['social_login_active'] << SocialLoginConfigManager::ENABLE_BIT_GLOBAL | - !!$_POST['social_login_test_page'] << SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE; - $cfg->setPref(SocialLoginConfigManager::SOCIAL_LOGIN_FLAGS, $social_login_flags); + if(isset($_POST['social_login_active'])) + { + $social_login_flags = + !!$_POST['social_login_active'] << social_login_config::ENABLE_BIT_GLOBAL | + !!$_POST['social_login_test_page'] << social_login_config::ENABLE_BIT_TEST_PAGE; + $cfg->setPref(social_login_config::SOCIAL_LOGIN_FLAGS, $social_login_flags); + } + $cfg->save(true, true, true); } @@ -217,31 +326,37 @@ class social_ui extends e_admin_ui function renderHelp() { - $action = $this->getAction(); switch($action) { case "configure": - $notice = LAN_SOCIAL_ADMIN_45."
"; + $notice = LAN_SOCIAL_ADMIN_45; break; case "unsupported": $notice = LAN_SOCIAL_ADMIN_48; break; + case "prefs": + return null; // todo? + break; + default: case "add": - $notice = LAN_SOCIAL_ADMIN_46."

"; - $notice .= LAN_SOCIAL_ADMIN_08."

".self::TEST_URL.""; - - $callBack = SITEURL; - $notice .= "

".LAN_SOCIAL_ADMIN_09."
".$callBack.""; + $notice = LAN_SOCIAL_ADMIN_46; break; } + if($action == 'configure' || $action == 'add') + { + $notice .= "

".LAN_SOCIAL_ADMIN_08."

".self::TEST_URL.""; + $callBack = SITEURL; + $notice .= "

".LAN_SOCIAL_ADMIN_09."
".$callBack.""; + } + $tp = e107::getParser(); return array("caption"=>LAN_HELP,'text'=> $tp->toHTML($notice,true)); @@ -256,7 +371,7 @@ class social_ui extends e_admin_ui $unsupported_providers = array_diff($configured_providers, $supported_providers); // $configured_providers = array_diff($configured_providers, $unsupported_providers); - return $this->generateSocialLoginSection($unsupported_providers ); + return $this->generateSocialLoginSection($unsupported_providers, true ); } @@ -404,7 +519,7 @@ class social_ui extends e_admin_ui - + ".$frm->radio_switch('social_login_active', $slcm->isFlagActive($slcm::ENABLE_BIT_GLOBAL))." @@ -455,7 +570,7 @@ class social_ui extends e_admin_ui * @param array $provider_names * @return string */ - private function generateSocialLoginSection($provider_names) + private function generateSocialLoginSection($provider_names, $readonly=false) { if(empty($provider_names)) { @@ -482,7 +597,7 @@ class social_ui extends e_admin_ui foreach ($provider_names as $provider_name) { - $text .= $this->generateSocialLoginRow($provider_name); + $text .= $this->generateSocialLoginRow($provider_name, $readonly); } $text .= ""; @@ -566,7 +681,7 @@ class social_ui extends e_admin_ui * @param $provider_name * @return string Text to append */ - private function generateSocialLoginRow($provider_name, $mode = 'list') + private function generateSocialLoginRow($provider_name, $readonly = false) { $slcm = $this->social_login_config_manager; $provider_type = $slcm->getTypeOfProvider($provider_name); @@ -596,6 +711,11 @@ class social_ui extends e_admin_ui 'placeholder' => self::getPlaceholderFor($provider_name, $fieldSlash), ]; + if($readonly) + { + $frm_options['readonly'] = 1; ; + } + $text .= "".$this->getLabel($fieldSlash).""; $text .= "".$frm->text("social_login[$provider_name][$field]", $slcm->getProviderConfig($provider_name, $fieldSlash), 256, $frm_options). "
$description
"; @@ -604,7 +724,16 @@ class social_ui extends e_admin_ui $text .= ""; - $textEnabled = $frm->radio_switch("social_login[$provider_name][enabled]", $slcm->isProviderEnabled($provider_name), '', '', ['class' => 'e-expandit']); + + if($readonly) + { + $textEnabled = ($slcm->isProviderEnabled($provider_name)) ? ADMIN_TRUE_ICON : ADMIN_FALSE_ICON; + } + else + { + $enabledOpts = ['class' => 'e-expandit']; + $textEnabled = $frm->radio_switch("social_login[$provider_name][enabled]", $slcm->isProviderEnabled($provider_name), '', '', $enabledOpts); + } $text .= $textKeys . $textScope . "" . $textEnabled . ""; diff --git a/e107_plugins/social/SocialLoginConfigManager.php b/e107_plugins/social/includes/social_login_config.php similarity index 98% rename from e107_plugins/social/SocialLoginConfigManager.php rename to e107_plugins/social/includes/social_login_config.php index 0b3ab3b75..6a5b7462f 100644 --- a/e107_plugins/social/SocialLoginConfigManager.php +++ b/e107_plugins/social/includes/social_login_config.php @@ -10,7 +10,7 @@ require_once(e_HANDLER . "user_handler.php"); -class SocialLoginConfigManager +class social_login_config { const SOCIAL_LOGIN_PREF = "social_login"; @@ -100,7 +100,7 @@ class SocialLoginConfigManager * $options['keys']['id'] string The OAuth1 client key or OAuth2 client ID * $options['keys']['secret'] string The OAuth1 or OAuth2 client secret * $options['scope'] string OAuth2 scopes, space-delimited - * @see SocialLoginConfigManager::saveConfig() to commit to database. + * @see social_login_config::saveConfig() to commit to database. * */ public function setProviderConfig($providerName, $options) diff --git a/e107_plugins/social/languages/English/English_admin.php b/e107_plugins/social/languages/English/English_admin.php index eb363c4ff..19d4e0010 100644 --- a/e107_plugins/social/languages/English/English_admin.php +++ b/e107_plugins/social/languages/English/English_admin.php @@ -9,7 +9,7 @@ define("LAN_SOCIAL_ADMIN_00", "Applications"); define("LAN_SOCIAL_ADMIN_01", "Pages"); -define("LAN_SOCIAL_ADMIN_02", "Social Signup/Login"); //tab +define("LAN_SOCIAL_ADMIN_02", "Configured Login Providers"); //tab define("LAN_SOCIAL_ADMIN_03", "Signup/Login"); //bar define("LAN_SOCIAL_ADMIN_04", "Provider"); define("LAN_SOCIAL_ADMIN_05", "Key/ID"); @@ -53,7 +53,7 @@ define("LAN_SOCIAL_ADMIN_42", "Custom Image"); define("LAN_SOCIAL_ADMIN_43","A [database update] is required to continue using this plugin."); define("LAN_SOCIAL_ADMIN_44", "Add New Provider"); -define("LAN_SOCIAL_ADMIN_45", "These social login providers are currently configured.\nIf the master switch [b]Social Signup/Login[/b] is toggled on, each provider in this table that is also toggled on may be used for user registration and login. If you empty the fields of a provider here and save, it will move to the [b]Add New Providers[/b] section."); +define("LAN_SOCIAL_ADMIN_45", "These social login providers are currently configured.\nIf the master switch [b]Social Signup/Login[/b] is toggled on, each provider in this table that is also toggled on may be used for user registration and login. If you empty the fields of a provider here and save, it will move to the [b]Add New Provider[/b] section."); define("LAN_SOCIAL_ADMIN_46", "These are the available social login providers, which have not been configured. Once you configure and save a provider here, it will move to the [b]Configured[/b] section."); define("LAN_SOCIAL_ADMIN_47", "Broken Configured Providers"); define("LAN_SOCIAL_ADMIN_48", "These social login providers were configured in the past but no longer have an adapter that can support them.[br]This may be due to them no longer existing or being replaced by a different provider."); @@ -62,6 +62,7 @@ define("LAN_SOCIAL_ADMIN_50", "Enable or disable the social login test page"); define("LAN_SOCIAL_ADMIN_08", "Note: In most cases, you will need to obtain an application ID and secret key from social login providers.\nIf a provider's name is a link, that link should take you to the login application configuration documentation.\n\nYou may test your configuration with the following URL after enabling the [b]Test Page[/b] option:"); define("LAN_SOCIAL_ADMIN_09", "Your callback URL is: "); +define("LAN_SOCIAL_ADMIN_51", "Social Login System"); diff --git a/e107_plugins/social/social_setup.php b/e107_plugins/social/social_setup.php index abf229179..2f08e4470 100644 --- a/e107_plugins/social/social_setup.php +++ b/e107_plugins/social/social_setup.php @@ -8,7 +8,7 @@ * */ -require_once("SocialLoginConfigManager.php"); +require_once("includes/social_login_config.php"); class social_setup { @@ -30,8 +30,8 @@ class social_setup private function upgrade_required_provider_name_normalization() { $coreConfig = e107::getConfig(); - $manager = new SocialLoginConfigManager($coreConfig); - $providerConfig = $coreConfig->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF); + $manager = new social_login_config($coreConfig); + $providerConfig = $coreConfig->getPref(social_login_config::SOCIAL_LOGIN_PREF); if (!is_array($providerConfig)) $providerConfig = []; $normalizedProviderNames = array_keys($providerConfig); foreach ($normalizedProviderNames as $normalizedProviderName) @@ -75,9 +75,9 @@ class social_setup { $coreConfig = e107::getConfig(); $logger = e107::getMessage(); - $manager = new SocialLoginConfigManager($coreConfig); + $manager = new social_login_config($coreConfig); - $providerConfig = $coreConfig->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF); + $providerConfig = $coreConfig->getPref(social_login_config::SOCIAL_LOGIN_PREF); if (!is_array($providerConfig)) $providerConfig = []; foreach ($providerConfig as $oldNormalizedProviderName => $oldOptions) @@ -107,7 +107,7 @@ class social_setup { $manager->setProviderConfig($denormalizedProviderName, $newOptions); $coreConfig->removePref( - SocialLoginConfigManager::SOCIAL_LOGIN_PREF . '/' . $oldNormalizedProviderName + social_login_config::SOCIAL_LOGIN_PREF . '/' . $oldNormalizedProviderName ); $logger->addSuccess( "Updated name of social login provider $oldNormalizedProviderName → $actualNormalizedProviderName" diff --git a/e107_tests/tests/unit/plugins/social/SocialLoginConfigManagerTest.php b/e107_tests/tests/unit/plugins/social/SocialLoginConfigManagerTest.php index b59fb4fc9..369078f4d 100644 --- a/e107_tests/tests/unit/plugins/social/SocialLoginConfigManagerTest.php +++ b/e107_tests/tests/unit/plugins/social/SocialLoginConfigManagerTest.php @@ -17,7 +17,7 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit */ private $pref; /** - * @var SocialLoginConfigManager + * @var social_login_config */ private $manager; @@ -26,10 +26,10 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit */ public function _before() { - include_once(e_PLUGIN . "social/SocialLoginConfigManager.php"); + include_once(e_PLUGIN . "social/includes/social_login_config.php"); $this->pref = $this->make('e_pref'); - $this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, [ + $this->pref->set(social_login_config::SOCIAL_LOGIN_PREF, [ 'Twitter-OAuth1' => [ 'enabled' => true, 'keys' => [ @@ -52,35 +52,35 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit 'enabled' => true, ], ]); - $this->manager = new SocialLoginConfigManager($this->pref); + $this->manager = new social_login_config($this->pref); } 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)); + $this->pref->set(social_login_config::SOCIAL_LOGIN_FLAGS, 0x0); + $this->manager = new social_login_config($this->pref); + $this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL)); + $this->assertFalse($this->manager->isFlagActive(social_login_config::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->assertFalse($this->manager->isFlagActive(SocialLoginConfigManager::ENABLE_BIT_TEST_PAGE)); + $this->manager->setFlag(social_login_config::ENABLE_BIT_GLOBAL, 0); + $this->manager->setFlag(social_login_config::ENABLE_BIT_TEST_PAGE, 1); + $this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL)); + $this->assertFalse($this->manager->isFlagActive(social_login_config::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(social_login_config::ENABLE_BIT_GLOBAL, 1); + $this->manager->setFlag(social_login_config::ENABLE_BIT_TEST_PAGE, 0); + $this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL)); + $this->assertFalse($this->manager->isFlagActive(social_login_config::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)); + $this->manager->setFlag(social_login_config::ENABLE_BIT_TEST_PAGE, 1); + $this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL)); + $this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE)); } /** @@ -89,14 +89,14 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit */ 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->pref->set(social_login_config::SOCIAL_LOGIN_FLAGS, ~0); + $this->manager = new social_login_config($this->pref); + $this->assertTrue($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL)); + $this->assertTrue($this->manager->isFlagActive(social_login_config::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)); + $this->manager->setFlag(social_login_config::ENABLE_BIT_GLOBAL, 0); + $this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_GLOBAL)); + $this->assertFalse($this->manager->isFlagActive(social_login_config::ENABLE_BIT_TEST_PAGE)); } public function testIsProviderEnabled() @@ -166,8 +166,8 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit public function testSetProviderConfigOverwritesNonArray() { - $this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, 'bad string!'); - $manager = new SocialLoginConfigManager($this->pref); + $this->pref->set(social_login_config::SOCIAL_LOGIN_PREF, 'bad string!'); + $manager = new social_login_config($this->pref); $expected = ['enabled' => true]; $manager->setProviderConfig('FirstProvider', $expected); diff --git a/e107_tests/tests/unit/plugins/social/social_setupTest.php b/e107_tests/tests/unit/plugins/social/social_setupTest.php index 374423ded..50c72665d 100644 --- a/e107_tests/tests/unit/plugins/social/social_setupTest.php +++ b/e107_tests/tests/unit/plugins/social/social_setupTest.php @@ -12,30 +12,30 @@ class social_setupTest extends \Codeception\Test\Unit { public function _before() { - include_once(e_PLUGIN . "social/SocialLoginConfigManager.php"); + include_once(e_PLUGIN . "social/includes/social_login_config.php"); include_once(e_PLUGIN . "social/social_setup.php"); } public function testUpgradeProviderNameNormalization() { - e107::getConfig()->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, SOCIAL_LOGIN_LEGACY_DATA); + e107::getConfig()->set(social_login_config::SOCIAL_LOGIN_PREF, SOCIAL_LOGIN_LEGACY_DATA); $social_setup = new social_setup(); $this->assertTrue($social_setup->upgrade_required()); - $this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL")); - $this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL-OpenID")); - $this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Github")); - $this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2")); - $this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Live")); - $this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/WindowsLive")); + $this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL")); + $this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL-OpenID")); + $this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Github")); + $this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2")); + $this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Live")); + $this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/WindowsLive")); $social_setup->upgrade_pre(); $this->assertFalse($social_setup->upgrade_required()); - $this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL")); - $this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/AOL-OpenID")); - $this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Github")); - $this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2")); - $this->assertIsNotArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/Live")); - $this->assertIsArray(e107::getConfig()->getPref(SocialLoginConfigManager::SOCIAL_LOGIN_PREF . "/WindowsLive-OAuth2")); + $this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL")); + $this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/AOL-OpenID")); + $this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Github")); + $this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/GitHub-OAuth2")); + $this->assertIsNotArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/Live")); + $this->assertIsArray(e107::getConfig()->getPref(social_login_config::SOCIAL_LOGIN_PREF . "/WindowsLive-OAuth2")); } public function testUpgradeFixRenamedProvidersXup()