1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-22 06:03:27 +02:00

Prevent error if 'social_login' pref is not an array

This commit is contained in:
Nick Liu
2020-02-19 16:26:49 +01:00
parent 5edcee8ad0
commit 0bacc5903c
2 changed files with 18 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
include_once(e_PLUGIN . "social/SocialLoginConfigManager.php");
$this->pref = $this->make('e_pref');
$this->pref->set('social_login', [
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, [
'Twitter-OAuth1' => [
'enabled' => true,
'keys' => [
@@ -120,6 +120,18 @@ class SocialLoginConfigManagerTest extends \Codeception\Test\Unit
$this->assertEquals(['enabled' => true], $result);
}
public function testSetProviderConfigOverwritesNonArray()
{
$this->pref->set(SocialLoginConfigManager::SOCIAL_LOGIN_PREF, 'bad string!');
$manager = new SocialLoginConfigManager($this->pref);
$expected = ['enabled' => true];
$manager->setProviderConfig('FirstProvider', $expected);
$result = $manager->getProviderConfig('FirstProvider');
$this->assertEquals($expected, $result);
}
public function testGetProviderConfig()
{
$result = $this->manager->getProviderConfig('Twitter');