|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class TextareaFieldTest extends SapphireTest { |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Quick smoke test to ensure that text with unicodes is being displayed properly in readonly fields. |
|
7
|
|
|
*/ |
|
8
|
|
|
public function testReadonlyDisplayUnicodes() { |
|
9
|
|
|
$inputText = "These are some unicodes: äöü"; |
|
10
|
|
|
$field = new TextareaField("Test", "Test"); |
|
11
|
|
|
$field->setValue($inputText); |
|
12
|
|
|
$field = $field->performReadonlyTransformation(); |
|
13
|
|
|
$this->assertContains('These are some unicodes: äöü', $field->Field()); |
|
14
|
|
|
} |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Quick smoke test to ensure that text with special html chars is being displayed properly in readonly fields. |
|
18
|
|
|
*/ |
|
19
|
|
|
public function testReadonlyDisplaySpecialHTML() { |
|
20
|
|
|
$inputText = "These are some special <html> chars including 'single' & \"double\" quotations"; |
|
21
|
|
|
$field = new TextareaField("Test", "Test"); |
|
22
|
|
|
$field = $field->performReadonlyTransformation(); |
|
23
|
|
|
$field->setValue($inputText); |
|
24
|
|
|
$this->assertContains('These are some special <html> chars including 'single' &' |
|
25
|
|
|
. ' "double" quotations', $field->Field()); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function testValueEntities() { |
|
29
|
|
|
$inputText = "These <b>are</b> some unicodes: äöü"; |
|
30
|
|
|
$field = new TextareaField("Test", "Test"); |
|
31
|
|
|
$field->setValue($inputText); |
|
32
|
|
|
|
|
33
|
|
|
// Value should be safe-encoding only, but ValueEntities should be more aggressive |
|
34
|
|
|
$this->assertEquals( |
|
35
|
|
|
"These <b>are</b> some unicodes: äöü", |
|
36
|
|
|
$field->obj('Value')->forTemplate() |
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
// Shortcodes are disabled |
|
40
|
|
|
$this->assertEquals( |
|
41
|
|
|
false, |
|
42
|
|
|
$field->obj('Value')->getProcessShortcodes() |
|
43
|
|
|
); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|