Files
roundcubemail/tests/Framework/Html.php
Michael Voříšek 332c165d28 Fix some basic JS CS (#9328)
* fix "nonblock-statement-body-position" (fixed already)

* fix "comma-dangle"

* fix "no-regex-spaces"

* fix "new-parens"

* fix "object-curly-newline"

* fix "object-property-newline"

* fix "spaced-comment" semimanually

* fix "no-constant-condition" manually

* fix "unicorn/no-hex-escape"

* fix "unicorn/escape-case"

* fix "quote-props"

* fix "no-whitespace-before-property" - fix bug/typo

* fix "unicorn/empty-brace-spaces"

* fix "keyword-spacing"

* fix "dot-notation"

* fix "no-return-assign" manually

* fix "padding-line-between-statements"

* fix "key-spacing"

* fix "no-else-return" semimanually

* fix some "no-undef"

* fix case cs

* Revert "fix "padding-line-between-statements""

* improve switch/case format I.

* improve switch/case format II.

regex: (^ *(break|return).*)\n *(\n)

* fix safe "eqeqeq"

* fix "radix"

* fix v3.49.0 CS (static providers)

* fix "string_implicit_backslashes" in php files

* fix comments align

* fix test static providers

* fix stan

* disable "final_internal_class" rule
2024-02-06 08:28:19 +01:00

138 lines
3.3 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
/**
* Test class to test html class
*/
class Framework_Html extends TestCase
{
/**
* Class constructor
*/
public function test_class()
{
$object = new html();
$this->assertInstanceOf('html', $object, 'Class constructor');
}
/**
* Data for test_attrib_string()
*/
public static function provide_attrib_string_cases(): iterable
{
return [
[
[], null, '',
],
[
['test' => 'test'], null, ' test="test"',
],
[
['test' => 'test'], ['test'], ' test="test"',
],
[
['test' => 'test'], ['other'], '',
],
[
['checked' => true], null, ' checked="checked"',
],
[
['checked' => ''], null, '',
],
[
['onclick' => ''], null, '',
],
[
['size' => 5], null, ' size="5"',
],
[
['size' => 'test'], null, '',
],
[
['data-test' => 'test'], null, ' data-test="test"',
],
];
}
/**
* Test for attrib_string()
*
* @dataProvider provide_attrib_string_cases
*/
public function test_attrib_string($arg1, $arg2, $expected)
{
$this->assertSame($expected, html::attrib_string($arg1, $arg2));
}
/**
* Data for test_quote()
*/
public static function provide_quote_cases(): iterable
{
return [
['abc', 'abc'],
['?', '?'],
['"', '&quot;'],
['<', '&lt;'],
['>', '&gt;'],
['&', '&amp;'],
['&amp;', '&amp;amp;'],
];
}
/**
* Test for quote()
*
* @dataProvider provide_quote_cases
*/
public function test_quote($str, $expected)
{
$this->assertSame($expected, html::quote($str));
}
/**
* Data for test_parse_attrib_string()
*/
public static function provide_parse_attrib_string_cases(): iterable
{
return [
[
'',
[],
],
[
'test="test1-val"',
['test' => 'test1-val'],
],
[
'test1="test1-val" test2=test2-val',
['test1' => 'test1-val', 'test2' => 'test2-val'],
],
[
' test1="test1\'val" test2=\'test2"val\' ',
['test1' => 'test1\'val', 'test2' => 'test2"val'],
],
[
'expression="test == true ? \' test\' : \'\'" ',
['expression' => 'test == true ? \' test\' : \'\''],
],
[
'href="http://domain.tld/страница"',
['href' => 'http://domain.tld/страница'],
],
];
}
/**
* Test for parse_attrib_string()
*
* @dataProvider provide_parse_attrib_string_cases
*/
public function test_parse_attrib_string($arg1, $expected)
{
$this->assertSame($expected, html::parse_attrib_string($arg1));
}
}