Blame view

framework/tests/forms/HtmlEditorConfigTest.php 2.82 KB
0084d336   Administrator   Importers CRUD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
  <?php
  /**
   * @package framework
   * @subpackage tests
   */
  class HtmlEditorConfigTest extends SapphireTest {
  
  	public function testEnablePluginsByString() {
  		$c = new HtmlEditorConfig();
  		$c->enablePlugins('plugin1');
  		$this->assertContains('plugin1', array_keys($c->getPlugins()));
  	}
  	
  	public function testEnablePluginsByArray() {
  		$c = new HtmlEditorConfig();
  		$c->enablePlugins(array('plugin1', 'plugin2'));
  		$this->assertContains('plugin1', array_keys($c->getPlugins()));
  		$this->assertContains('plugin2', array_keys($c->getPlugins()));
  	}
  	
  	public function testEnablePluginsByMultipleStringParameters() {
  		$c = new HtmlEditorConfig();
  		$c->enablePlugins('plugin1', 'plugin2');
  		$this->assertContains('plugin1', array_keys($c->getPlugins()));
  		$this->assertContains('plugin2', array_keys($c->getPlugins()));
  	}
  	
  	public 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']);
  	}
  	
  	public function testDisablePluginsByString() {
  		$c = new HtmlEditorConfig();
  		$c->enablePlugins('plugin1');
  		$c->disablePlugins('plugin1');
  		$this->assertNotContains('plugin1', array_keys($c->getPlugins()));
  	}
  	
  	public 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()));
  	}
  	
  	public 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()));
  	}
  	
  	public 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));
  	}
  	
  	public 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());
  	}
  }