Skip to content

Commit

Permalink
MDL-53544 lib: Update unit tests and thirdpartylibs
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Dias committed May 26, 2021
1 parent 490c72f commit f991397
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ lib/pear/PEAR.php
lib/phpmailer/
lib/simplepie/
lib/tcpdf/
lib/typo3/
lib/yuilib/
lib/yuilib/gallery/
lib/jquery/
Expand Down
1 change: 0 additions & 1 deletion .stylelintignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ lib/pear/PEAR.php
lib/phpmailer/
lib/simplepie/
lib/tcpdf/
lib/typo3/
lib/yuilib/
lib/yuilib/gallery/
lib/jquery/
Expand Down
42 changes: 36 additions & 6 deletions lib/tests/text_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class core_text_testcase extends advanced_testcase {
class text_test extends advanced_testcase {

/**
* Tests the static parse charset method.
*/
public function test_parse_charset() {
$this->assertSame('windows-1250', core_text::parse_charset('Cp1250'));
// Does typo3 work? Some encoding moodle does not use.
// Some encoding moodle does not use.
$this->assertSame('windows-1252', core_text::parse_charset('ms-ansi'));
}

Expand Down Expand Up @@ -93,9 +93,12 @@ public function test_convert() {
$this->assertSame('Zlutoucky konicek', core_text::convert($utf8, 'utf-8', 'ascii'));
$this->assertSame($utf8, core_text::convert($utf8.chr(130), 'utf-8', 'utf-8'));
$utf8 = "Der eine stößt den Speer zum Mann";
$this->assertSame('Der eine stoesst den Speer zum Mann', core_text::convert($utf8, 'utf-8', 'ascii'));
$this->assertSame('Der eine stosst den Speer zum Mann', core_text::convert($utf8, 'utf-8', 'ascii'));
$iso1 = core_text::convert($utf8, 'utf-8', 'iso-8859-1');
$this->assertSame('Der eine stoesst den Speer zum Mann', core_text::convert($iso1, 'iso-8859-1', 'ascii'));
$this->assertSame('Der eine stosst den Speer zum Mann', core_text::convert($iso1, 'iso-8859-1', 'ascii'));
$utf8 = "A æ Übérmensch på høyeste nivå! И я люблю PHP! есть. アクセシビリティ. fi";
$this->assertSame("A ae Ubermensch pa hoyeste niva! I a lublu PHP! est'. akuseshibiriti. fi",
core_text::convert($utf8, 'utf-8', 'ascii'));
}

/**
Expand Down Expand Up @@ -261,7 +264,6 @@ public function test_strtolower() {
$str = pack("H*", "bcf2cce5d6d0cec4"); // GB18030
$this->assertSame($str, core_text::strtolower($str, 'GB18030'));

// Typo3 has problems with integers.
$str = 1309528800;
$this->assertSame((string)$str, core_text::strtolower($str));
}
Expand Down Expand Up @@ -341,6 +343,8 @@ public function test_strrpos() {
public function test_specialtoascii() {
$str = "Žluťoučký koníček";
$this->assertSame('Zlutoucky konicek', core_text::specialtoascii($str));
$utf8 = "Der eine stößt den Speer zum Mann";
$this->assertSame('Der eine stosst den Speer zum Mann', core_text::specialtoascii($utf8));
}

/**
Expand Down Expand Up @@ -480,5 +484,31 @@ public function test_strrchr() {
$this->assertFalse(core_text::strrchr($str, 'A'));
$this->assertFalse(core_text::strrchr($str, 'ç', true));
}
}

/**
* Tests the static checker is_charset_supported
*
* @dataProvider is_charset_supported_provider()
* @param string $charset
* @param bool $expected
*/
public function test_is_charset_supported(string $charset, bool $expected) {
$charset = core_text::parse_charset($charset);
$this->assertEquals($expected, core_text::is_charset_supported($charset));
}

/**
* Provider for the test_is_charset_supported()
* @return array[]
*/
public function is_charset_supported_provider() {
return [
"Check unsupported windows charset" => [
"cp1250", false
],
"Check supported windows charset" => [
"cp1252", true
]
];
}
}
7 changes: 0 additions & 7 deletions lib/thirdpartylibs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,6 @@
<version>6.4.1</version>
<licenseversion>3.0-only</licenseversion>
</library>
<library>
<location>typo3</location>
<name>Typo3</name>
<license>GPL</license>
<version>4.7.19</version>
<licenseversion>2.0+</licenseversion>
</library>
<library>
<location>yuilib</location>
<name>YUI</name>
Expand Down
1 change: 1 addition & 0 deletions lib/upgrade.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ information provided here is intended especially for developers.
will be called. The following behaviour will be the new standard for nodes added via callbacks:
- Module nodes added will be appended to the end and will appear within the hamburger option.
- Course nodes added will also be appended and appear within the 'More' option/page.
* Typo3 has now been removed. Use native mbstring or iconv functions.

=== 3.11 ===
* PHPUnit has been upgraded to 9.5 (see MDL-71036 for details).
Expand Down

0 comments on commit f991397

Please sign in to comment.