mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
e107::wysiwyg() test. Still needs some work for reliable result.
This commit is contained in:
@@ -414,6 +414,9 @@ City, State, Country
|
|||||||
<core name="wm_enclose">1</core>
|
<core name="wm_enclose">1</core>
|
||||||
<core name="wmessage_sc">0</core>
|
<core name="wmessage_sc">0</core>
|
||||||
<core name="wysiwyg">1</core>
|
<core name="wysiwyg">1</core>
|
||||||
|
<core name="wysiwyg_list"><![CDATA[array (
|
||||||
|
'tinymce4' => 'TinyMce4',
|
||||||
|
)]]></core>
|
||||||
<core name="xup_enabled">1</core>
|
<core name="xup_enabled">1</core>
|
||||||
<core name="xurl"><![CDATA[array ()]]></core>
|
<core name="xurl"><![CDATA[array ()]]></core>
|
||||||
<core name="xmlfeed_languagepacks">http://www.e107.org/themeupdate.php</core>
|
<core name="xmlfeed_languagepacks">http://www.e107.org/themeupdate.php</core>
|
||||||
|
@@ -3858,7 +3858,9 @@ class e107
|
|||||||
if(!isset($availEditors))
|
if(!isset($availEditors))
|
||||||
{
|
{
|
||||||
// init list of installed wysiwyg editors
|
// 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.
|
// $availEditors = array_keys(e107::getPlug()->getInstalledWysiwygEditors()); // very slow.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3875,9 +3877,11 @@ class e107
|
|||||||
if(is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
|
if(is_bool($editor) || ($editor !== $fallbackEditor && !in_array($editor, $availEditors)))
|
||||||
{
|
{
|
||||||
$names = array_keys($availEditors);
|
$names = array_keys($availEditors);
|
||||||
|
// $editor = count($availEditors) > 0 ? $availEditors[0] : $fallbackEditor;
|
||||||
$editor = count($availEditors) > 0 ? reset($names) : $fallbackEditor;
|
$editor = count($availEditors) > 0 ? reset($names) : $fallbackEditor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// $returnEditor => false:
|
// $returnEditor => false:
|
||||||
// false => fallback editor (bbcode)
|
// false => fallback editor (bbcode)
|
||||||
// true => default wysiwyg editor
|
// true => default wysiwyg editor
|
||||||
|
@@ -881,11 +881,31 @@ class e107Test extends \Codeception\Test\Unit
|
|||||||
|
|
||||||
public function testWysiwyg()
|
public function testWysiwyg()
|
||||||
{
|
{
|
||||||
$result = e107::wysiwyg(null, true);
|
$tests = array(
|
||||||
$expected = 'bbcode';
|
//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);
|
$this->assertSame($expected, $result);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
public function testLoadLanFiles()
|
public function testLoadLanFiles()
|
||||||
|
@@ -31,11 +31,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testGetInstalledWysiwygEditors()
|
public function testGetInstalledWysiwygEditors()
|
||||||
|
{
|
||||||
|
if(e107::isInstalled('tinymce4'))
|
||||||
{
|
{
|
||||||
$expected = array('tinymce4'=>'TinyMce4');
|
$expected = array('tinymce4'=>'TinyMce4');
|
||||||
$result = $this->ep->getInstalledWysiwygEditors();
|
$result = $this->ep->getInstalledWysiwygEditors();
|
||||||
|
|
||||||
$this->assertSame($expected,$result);
|
$this->assertSame($expected,$result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user