mirror of
https://github.com/e107inc/e107.git
synced 2025-04-21 13:11:52 +02:00
e107::wysiwyg() test. Still needs some work for reliable result.
This commit is contained in:
parent
c1f5a6f8dc
commit
a8c79eda5b
@ -414,6 +414,9 @@ City, State, Country
|
||||
<core name="wm_enclose">1</core>
|
||||
<core name="wmessage_sc">0</core>
|
||||
<core name="wysiwyg">1</core>
|
||||
<core name="wysiwyg_list"><![CDATA[array (
|
||||
'tinymce4' => 'TinyMce4',
|
||||
)]]></core>
|
||||
<core name="xup_enabled">1</core>
|
||||
<core name="xurl"><![CDATA[array ()]]></core>
|
||||
<core name="xmlfeed_languagepacks">http://www.e107.org/themeupdate.php</core>
|
||||
|
@ -3858,7 +3858,9 @@ class e107
|
||||
if(!isset($availEditors))
|
||||
{
|
||||
// init list of installed wysiwyg editors
|
||||
$availEditors = self::getPref('wysiwyg_list', array());
|
||||
$default = self::isInstalled('tinymce4') ? array('tinymce4'=>'TinyMce4') : array(); // if missing pref fallback.
|
||||
$availEditors = self::getPref('wysiwyg_list', $default);
|
||||
|
||||
// $availEditors = array_keys(e107::getPlug()->getInstalledWysiwygEditors()); // very slow.
|
||||
}
|
||||
|
||||
@ -3875,9 +3877,11 @@ class e107
|
||||
if(is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
|
||||
{
|
||||
$names = array_keys($availEditors);
|
||||
// $editor = count($availEditors) > 0 ? $availEditors[0] : $fallbackEditor;
|
||||
$editor = count($availEditors) > 0 ? reset($names) : $fallbackEditor;
|
||||
}
|
||||
}
|
||||
|
||||
// $returnEditor => false:
|
||||
// false => fallback editor (bbcode)
|
||||
// true => default wysiwyg editor
|
||||
|
@ -881,11 +881,31 @@ class e107Test extends \Codeception\Test\Unit
|
||||
|
||||
public function testWysiwyg()
|
||||
{
|
||||
$result = e107::wysiwyg(null, true);
|
||||
$expected = 'bbcode';
|
||||
$tests = array(
|
||||
//input => expected
|
||||
'default' => 'tinymce4',
|
||||
'bbcode' => 'bbcode',
|
||||
'tinymce4' => 'tinymce4'
|
||||
);
|
||||
|
||||
foreach($tests as $input => $expected)
|
||||
{
|
||||
e107::wysiwyg($input); // set the wysiwyg editor.
|
||||
$result = e107::wysiwyg(null, true); // get the name of the editor.
|
||||
$this->assertSame($expected, $result, "Input: ".$input);
|
||||
}
|
||||
|
||||
|
||||
e107::getConfig()->setPref('wysiwyg', false)->save(); // wysiwyg is disabled.
|
||||
e107::wysiwyg('default'); // set as default.
|
||||
$result = e107::wysiwyg(null, true); // get the editor value.
|
||||
$expected = 'bbcode';
|
||||
e107::getConfig()->setPref('wysiwyg', true)->save(); // enabled wysiwyg again.
|
||||
$this->assertSame($expected, $result);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
public function testLoadLanFiles()
|
||||
|
@ -32,10 +32,13 @@
|
||||
|
||||
public function testGetInstalledWysiwygEditors()
|
||||
{
|
||||
$expected = array('tinymce4'=>'TinyMce4');
|
||||
$result = $this->ep->getInstalledWysiwygEditors();
|
||||
if(e107::isInstalled('tinymce4'))
|
||||
{
|
||||
$expected = array('tinymce4'=>'TinyMce4');
|
||||
$result = $this->ep->getInstalledWysiwygEditors();
|
||||
|
||||
$this->assertSame($expected,$result);
|
||||
$this->assertSame($expected,$result);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user