2009-06-17 13:36:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class TextareaFieldTest extends SapphireTest {
|
|
|
|
|
2016-12-16 04:51:15 +01:00
|
|
|
public function testCasting() {
|
|
|
|
// Test special characters
|
|
|
|
$inputText = "These are some unicodes: ä, ö, & ü";
|
|
|
|
$field = new TextareaField("Test", "Test");
|
|
|
|
$field->setValue($inputText);
|
|
|
|
$this->assertContains('These are some unicodes: ä, ö, & ü', $field->Field());
|
|
|
|
|
|
|
|
// Test shortcodes
|
|
|
|
$inputText = "Shortcode: [file_link id=4]";
|
|
|
|
$field = new TextareaField("Test", "Test");
|
|
|
|
$field->setValue($inputText);
|
|
|
|
$this->assertContains('Shortcode: [file_link id=4]', $field->Field());
|
|
|
|
}
|
|
|
|
|
2009-06-17 13:36:49 +02:00
|
|
|
/**
|
2012-05-03 04:05:38 +02:00
|
|
|
* Quick smoke test to ensure that text with unicodes is being displayed properly in readonly fields.
|
2009-06-17 13:36:49 +02:00
|
|
|
*/
|
2012-09-19 12:07:39 +02:00
|
|
|
public function testReadonlyDisplayUnicodes() {
|
2012-05-03 04:05:38 +02:00
|
|
|
$inputText = "These are some unicodes: äöü";
|
|
|
|
$field = new TextareaField("Test", "Test");
|
|
|
|
$field->setValue($inputText);
|
|
|
|
$field = $field->performReadonlyTransformation();
|
|
|
|
$this->assertContains('These are some unicodes: äöü', $field->Field());
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-05-03 04:05:38 +02:00
|
|
|
/**
|
|
|
|
* Quick smoke test to ensure that text with special html chars is being displayed properly in readonly fields.
|
|
|
|
*/
|
2016-11-15 01:34:54 +01:00
|
|
|
public function testReadonlyDisplaySpecialHTML() {
|
2012-05-03 04:05:38 +02:00
|
|
|
$inputText = "These are some special <html> chars including 'single' & \"double\" quotations";
|
2012-01-10 04:58:27 +01:00
|
|
|
$field = new TextareaField("Test", "Test");
|
2009-06-17 13:36:49 +02:00
|
|
|
$field = $field->performReadonlyTransformation();
|
|
|
|
$field->setValue($inputText);
|
2012-09-26 23:34:00 +02:00
|
|
|
$this->assertContains('These are some special <html> chars including 'single' &'
|
|
|
|
. ' "double" quotations', $field->Field());
|
2009-06-17 13:36:49 +02:00
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2016-11-15 01:34:54 +01:00
|
|
|
public function testValueEntities() {
|
|
|
|
$inputText = "These <b>are</b> some unicodes: äöü";
|
|
|
|
$field = new TextareaField("Test", "Test");
|
|
|
|
$field->setValue($inputText);
|
|
|
|
|
|
|
|
// Value should be safe-encoding only, but ValueEntities should be more aggressive
|
|
|
|
$this->assertEquals(
|
|
|
|
"These <b>are</b> some unicodes: äöü",
|
|
|
|
$field->obj('Value')->forTemplate()
|
|
|
|
);
|
|
|
|
|
|
|
|
// Shortcodes are disabled
|
|
|
|
$this->assertEquals(
|
|
|
|
false,
|
|
|
|
$field->obj('Value')->getProcessShortcodes()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|