silverstripe-framework/tests/HtmlEditorConfigTest.php
Sean Harvey 1588da54d8 ENHANCEMENT Added support for loading external plugins (with relative paths) in HtmlEditorConfig. This means relative paths can be separate from the plugin name, and fixes a bug where paths containing dashes were ignored by TinyMCE.init().
ENHANCEMENT Changed sapphire/thirdparty/tinymce-advcode to use the original plugin name, and specify its relative path through HtmlEditorConfig instead. (from r94060)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95582 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-12-16 05:30:46 +00:00

78 lines
2.8 KiB
PHP

<?php
/**
* @package sapphire
* @subpackage tests
*/
class HtmlEditorConfigTest extends SapphireTest {
function testEnablePluginsByString() {
$c = new HtmlEditorConfig();
$c->enablePlugins('plugin1');
$this->assertContains('plugin1', array_keys($c->getPlugins()));
}
function testEnablePluginsByArray() {
$c = new HtmlEditorConfig();
$c->enablePlugins(array('plugin1', 'plugin2'));
$this->assertContains('plugin1', array_keys($c->getPlugins()));
$this->assertContains('plugin2', array_keys($c->getPlugins()));
}
function testEnablePluginsByMultipleStringParameters() {
$c = new HtmlEditorConfig();
$c->enablePlugins('plugin1', 'plugin2');
$this->assertContains('plugin1', array_keys($c->getPlugins()));
$this->assertContains('plugin2', array_keys($c->getPlugins()));
}
function testEnablePluginsByArrayWithPaths() {
$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']);
}
function testDisablePluginsByString() {
$c = new HtmlEditorConfig();
$c->enablePlugins('plugin1');
$c->disablePlugins('plugin1');
$this->assertNotContains('plugin1', array_keys($c->getPlugins()));
}
function testDisablePluginsByArray() {
$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()));
}
function testDisablePluginsByMultipleStringParameters() {
$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()));
}
function testDisablePluginsByArrayWithPaths() {
$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));
}
function testGenerateJSWritesPlugins() {
$c = new HtmlEditorConfig();
$c->enablePlugins(array('plugin1'));
$c->enablePlugins(array('plugin2' => '/mypath/plugin2'));
$this->assertContains('plugin1', $c->generateJS());
$this->assertContains('tinymce.PluginManager.load("plugin2", "/mypath/plugin2");', $c->generateJS());
}
}