MDL-34990 improve custom toolbar setting parsing
[moodle.git] / lib / editor / tinymce / tests / editor_test.php
CommitLineData
b3aefe3c
PS
1<?php
2// This file is part of Moodle - http://moodle.org/
3//
4// Moodle is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// Moodle is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
16
17/**
18 * TinyMCE tests.
19 *
20 * @package editor_tinymce
21 * @category phpunit
22 * @copyright 2012 Petr Skoda {@link http://skodak.org}
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 */
25
26defined('MOODLE_INTERNAL') || die();
27
28
29/**
30 * TinyMCE tests.
31 *
32 * @package editor_tinymce
33 * @category phpunit
34 * @copyright 2012 Petr Skoda {@link http://skodak.org}
35 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36 */
37class editor_tinymce_testcase extends advanced_testcase {
38
39 public function test_toolbar_parsing() {
40 global $CFG;
41 require_once("$CFG->dirroot/lib/editorlib.php");
42 require_once("$CFG->dirroot/lib/editor/tinymce/lib.php");
43
44 $result = tinymce_texteditor::parse_toolbar_setting("bold,italic\npreview");
45 $this->assertSame(array('bold,italic', 'preview'), $result);
46
47 $result = tinymce_texteditor::parse_toolbar_setting("| bold,|italic*blink\rpreview\n\n| \n paste STYLE | ");
48 $this->assertSame(array('bold,|,italic,blink', 'preview', 'paste,style'), $result);
49
50 $result = tinymce_texteditor::parse_toolbar_setting("| \n\n| \n \r");
51 $this->assertSame(array(), $result);
52 }
53}