|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the Ivory CKEditor package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Eric GELOEN <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please read the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Ivory\CKEditorBundle\Tests\Model; |
|
13
|
|
|
|
|
14
|
|
|
use Ivory\CKEditorBundle\Model\ToolbarManager; |
|
15
|
|
|
use Ivory\CKEditorBundle\Tests\AbstractTestCase; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* @author GeLo <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class ToolbarManagerTest extends AbstractTestCase |
|
21
|
|
|
{ |
|
22
|
|
|
/** |
|
23
|
|
|
* @var ToolbarManager |
|
24
|
|
|
*/ |
|
25
|
|
|
private $toolbarManager; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
protected function setUp() |
|
31
|
|
|
{ |
|
32
|
|
|
$this->toolbarManager = new ToolbarManager(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testDefaultState() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->assertTrue($this->toolbarManager->hasItems()); |
|
38
|
|
|
$this->assertCount(25, $this->toolbarManager->getItems()); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertTrue($this->toolbarManager->hasToolbars()); |
|
41
|
|
|
$this->assertCount(3, $this->toolbarManager->getToolbars()); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function testInitialState() |
|
45
|
|
|
{ |
|
46
|
|
|
$items = [ |
|
47
|
|
|
'document' => ['Source', '-', 'Save'], |
|
48
|
|
|
'tools' => ['Maximize'], |
|
49
|
|
|
]; |
|
50
|
|
|
|
|
51
|
|
|
$toolbars = [ |
|
52
|
|
|
'default' => ['@document', '/', ['Anchor'], '/', '@tools'], |
|
53
|
|
|
'custom' => ['@document', '/', ['Anchor']], |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
$this->toolbarManager = new ToolbarManager($items, $toolbars); |
|
57
|
|
|
|
|
58
|
|
|
$this->assertTrue($this->toolbarManager->hasItems()); |
|
59
|
|
|
$this->assertCount(27, $this->toolbarManager->getItems()); |
|
60
|
|
|
|
|
61
|
|
|
$this->assertTrue($this->toolbarManager->hasToolbars()); |
|
62
|
|
|
$this->assertCount(5, $this->toolbarManager->getToolbars()); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @expectedException \Ivory\CKEditorBundle\Exception\ToolbarManagerException |
|
67
|
|
|
* @expectedExceptionMessage The CKEditor toolbar item "foo" does not exist. |
|
68
|
|
|
*/ |
|
69
|
|
|
public function testInvalidItem() |
|
70
|
|
|
{ |
|
71
|
|
|
$this->toolbarManager->getItem('foo'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @expectedException \Ivory\CKEditorBundle\Exception\ToolbarManagerException |
|
76
|
|
|
* @expectedExceptionMessage The CKEditor toolbar "foo" does not exist. |
|
77
|
|
|
*/ |
|
78
|
|
|
public function testInvalidToolbar() |
|
79
|
|
|
{ |
|
80
|
|
|
$this->toolbarManager->getToolbar('foo'); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @expectedException \Ivory\CKEditorBundle\Exception\ToolbarManagerException |
|
85
|
|
|
* @expectedExceptionMessage The CKEditor toolbar "foo" does not exist. |
|
86
|
|
|
*/ |
|
87
|
|
|
public function testInvalidResolvedToolbar() |
|
88
|
|
|
{ |
|
89
|
|
|
$this->toolbarManager->resolveToolbar('foo'); |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param string $name |
|
94
|
|
|
* @param array $expected |
|
95
|
|
|
* |
|
96
|
|
|
* @dataProvider toolbarProvider |
|
97
|
|
|
*/ |
|
98
|
|
|
public function testResolveToolbar($name, array $expected) |
|
99
|
|
|
{ |
|
100
|
|
|
$this->assertEquals($expected, $this->toolbarManager->resolveToolbar($name)); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
|
|
public function toolbarProvider() |
|
107
|
|
|
{ |
|
108
|
|
|
return [ |
|
109
|
|
|
'basic' => ['basic', [ |
|
110
|
|
|
['Bold', 'Italic'], |
|
111
|
|
|
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'], |
|
112
|
|
|
['Link', 'Unlink'], |
|
113
|
|
|
['About'], |
|
114
|
|
|
]], |
|
115
|
|
|
'standard' => ['standard', [ |
|
116
|
|
|
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'], |
|
117
|
|
|
['Scayt'], |
|
118
|
|
|
['Link', 'Unlink', 'Anchor'], |
|
119
|
|
|
['Image', 'Table', 'HorizontalRule', 'SpecialChar'], |
|
120
|
|
|
['Maximize'], |
|
121
|
|
|
['Source'], |
|
122
|
|
|
'/', |
|
123
|
|
|
['Bold', 'Italic', 'Strike', '-', 'RemoveFormat'], |
|
124
|
|
|
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote'], |
|
125
|
|
|
['Styles', 'Format', 'About'], |
|
126
|
|
|
]], |
|
127
|
|
|
'full' => ['full', [ |
|
128
|
|
|
['Source', '-', 'NewPage', 'Preview', 'Print', '-', 'Templates'], |
|
129
|
|
|
['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'], |
|
130
|
|
|
['Find', 'Replace', '-', 'SelectAll', '-', 'Scayt'], |
|
131
|
|
|
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'SelectField', 'Button', 'ImageButton', 'HiddenField'], |
|
132
|
|
|
'/', |
|
133
|
|
|
['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'], |
|
134
|
|
|
['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl'], |
|
135
|
|
|
['Link', 'Unlink', 'Anchor'], |
|
136
|
|
|
['Image', 'Flash', 'Table', 'HorizontalRule', 'SpecialChar', 'Smiley', 'PageBreak', 'Iframe'], |
|
137
|
|
|
'/', |
|
138
|
|
|
['Styles', 'Format', 'Font', 'FontSize', 'TextColor', 'BGColor'], |
|
139
|
|
|
['TextColor', 'BGColor'], |
|
140
|
|
|
['Maximize', 'ShowBlocks'], |
|
141
|
|
|
['About'], |
|
142
|
|
|
]], |
|
143
|
|
|
]; |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
|