2009-06-17 13:36:49 +02:00
|
|
|
<?php
|
|
|
|
|
2016-10-14 03:30:05 +02:00
|
|
|
namespace SilverStripe\Forms\Tests;
|
|
|
|
|
2016-08-19 00:51:35 +02:00
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\Forms\TextareaField;
|
|
|
|
|
2009-06-17 13:36:49 +02:00
|
|
|
class TextareaFieldTest extends SapphireTest {
|
|
|
|
|
|
|
|
/**
|
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: äöü",
|
2016-11-29 13:45:41 +01:00
|
|
|
$field->obj('ValueEntities')->forTemplate()
|
2016-11-15 01:34:54 +01:00
|
|
|
);
|
|
|
|
|
|
|
|
// Shortcodes are disabled
|
|
|
|
$this->assertEquals(
|
|
|
|
false,
|
2016-11-29 13:45:41 +01:00
|
|
|
$field->obj('ValueEntities')->getProcessShortcodes()
|
2016-11-15 01:34:54 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|