.dev/tests/unit/functions/function_prepare_html_test.Test.php
<?php
require_once dirname(__DIR__) . '/yf_unit_tests_setup.php';
class function_prepare_html_test extends yf\tests\wrapper
{
public function test_prepare_html()
{
$this->assertEquals('test', _prepare_html('test'));
$this->assertEquals('test' . PHP_EOL . 'test', _prepare_html('test' . PHP_EOL . 'test'));
$this->assertEquals('{', _prepare_html('{'));
$this->assertEquals('}', _prepare_html('}'));
$this->assertEquals('\', _prepare_html('\\\\'));
$this->assertEquals('(', _prepare_html('('));
$this->assertEquals(')', _prepare_html(')'));
$this->assertEquals('?', _prepare_html('?'));
$this->assertEquals(''', _prepare_html('\''));
$this->assertEquals('"', _prepare_html('"'));
$this->assertEquals('<', _prepare_html('<'));
$this->assertEquals('>', _prepare_html('>'));
$this->assertEquals('<script>', _prepare_html('<script>'));
$this->assertEquals(
'<script type="text/javascript">$(function(alert('Hello')))</script>',
_prepare_html('<script type="text/javascript">$(function(alert(\'Hello\')))</script>')
);
$this->assertEquals(
'<a href="#" onclick="return confirm('Are you sure?')">Link</a>',
_prepare_html('<a href="#" onclick="return confirm(\'Are you sure?\')">Link</a>')
);
$this->assertEquals(
'<a href="#" onclick="return confirm('{i18n_text}')">Link</a>',
_prepare_html('<a href="#" onclick="return confirm(\'{i18n_text}\')">Link</a>')
);
$this->assertEquals([], _prepare_html([]));
$this->assertEquals(['test'], _prepare_html(['test']));
$this->assertEquals(['k1' => '<', 'k2' => '>'], _prepare_html(['k1' => '<', 'k2' => '>']));
$this->assertEquals(['k1' => [['<']], 'k2' => '>'], _prepare_html(['k1' => [['<']], 'k2' => '>']));
$this->assertEquals('>', _prepare_html('>'));
$this->assertEquals(''', _prepare_html('''));
$this->assertEquals('\', _prepare_html('\\', $strip_slashes = false));
$this->assertEquals('&#039;', _prepare_html(''', 1, $smart = false));
}
}