2009-12-16 06:30:46 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2009-12-16 06:30:46 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class HtmlEditorConfigTest extends SapphireTest {
|
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testEnablePluginsByString() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins('plugin1');
|
|
|
|
$this->assertContains('plugin1', array_keys($c->getPlugins()));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testEnablePluginsByArray() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins(array('plugin1', 'plugin2'));
|
|
|
|
$this->assertContains('plugin1', array_keys($c->getPlugins()));
|
|
|
|
$this->assertContains('plugin2', array_keys($c->getPlugins()));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testEnablePluginsByMultipleStringParameters() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins('plugin1', 'plugin2');
|
|
|
|
$this->assertContains('plugin1', array_keys($c->getPlugins()));
|
|
|
|
$this->assertContains('plugin2', array_keys($c->getPlugins()));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testEnablePluginsByArrayWithPaths() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins(array('plugin1' => '/mypath/plugin1', 'plugin2' => '/mypath/plugin2'));
|
|
|
|
$plugins = $c->getPlugins();
|
|
|
|
$this->assertContains('plugin1', array_keys($plugins));
|
|
|
|
$this->assertEquals('/mypath/plugin1', $plugins['plugin1']);
|
|
|
|
$this->assertContains('plugin2', array_keys($plugins));
|
|
|
|
$this->assertEquals('/mypath/plugin2', $plugins['plugin2']);
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testDisablePluginsByString() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins('plugin1');
|
|
|
|
$c->disablePlugins('plugin1');
|
|
|
|
$this->assertNotContains('plugin1', array_keys($c->getPlugins()));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testDisablePluginsByArray() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins(array('plugin1', 'plugin2'));
|
|
|
|
$c->disablePlugins(array('plugin1', 'plugin2'));
|
|
|
|
$this->assertNotContains('plugin1', array_keys($c->getPlugins()));
|
|
|
|
$this->assertNotContains('plugin2', array_keys($c->getPlugins()));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testDisablePluginsByMultipleStringParameters() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins('plugin1', 'plugin2');
|
|
|
|
$c->disablePlugins('plugin1', 'plugin2');
|
|
|
|
$this->assertNotContains('plugin1', array_keys($c->getPlugins()));
|
|
|
|
$this->assertNotContains('plugin2', array_keys($c->getPlugins()));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testDisablePluginsByArrayWithPaths() {
|
2009-12-16 06:30:46 +01:00
|
|
|
$c = new HtmlEditorConfig();
|
|
|
|
$c->enablePlugins(array('plugin1' => '/mypath/plugin1', 'plugin2' => '/mypath/plugin2'));
|
|
|
|
$c->disablePlugins(array('plugin1', 'plugin2'));
|
|
|
|
$plugins = $c->getPlugins();
|
|
|
|
$this->assertNotContains('plugin1', array_keys($plugins));
|
|
|
|
$this->assertNotContains('plugin2', array_keys($plugins));
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2015-06-09 02:01:21 +02:00
|
|
|
public function testRequireJSIncludesAllExternalPlugins() {
|
|
|
|
$c = HtmlEditorConfig::get('config');
|
|
|
|
$c->enablePlugins(array('plugin1' => '/mypath/plugin1'));
|
2009-12-16 06:30:46 +01:00
|
|
|
$c->enablePlugins(array('plugin2' => '/mypath/plugin2'));
|
|
|
|
|
2015-06-09 02:01:21 +02:00
|
|
|
HtmlEditorConfig::require_js();
|
|
|
|
$js = Requirements::get_custom_scripts();
|
|
|
|
|
|
|
|
$this->assertContains('tinymce.PluginManager.load("plugin1", "/mypath/plugin1");', $js);
|
|
|
|
$this->assertContains('tinymce.PluginManager.load("plugin2", "/mypath/plugin2");', $js);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testRequireJSIncludesAllConfigs() {
|
|
|
|
$c = HtmlEditorConfig::get('configA');
|
|
|
|
$c = HtmlEditorConfig::get('configB');
|
|
|
|
|
|
|
|
HtmlEditorConfig::require_js();
|
|
|
|
$js = Requirements::get_custom_scripts();
|
|
|
|
|
|
|
|
$this->assertContains('"configA":{', $js);
|
|
|
|
$this->assertContains('"configB":{', $js);
|
2009-12-16 06:30:46 +01:00
|
|
|
}
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|