Skip to content

Commit

Permalink
MDL-74097 core_text: Add coverage info to better see what's missing
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Mar 8, 2022
1 parent 2def805 commit 3255c42
Showing 1 changed file with 46 additions and 1 deletion.
47 changes: 46 additions & 1 deletion lib/tests/text_test.php
Expand Up @@ -33,11 +33,15 @@
* @category phpunit
* @copyright 2010 Petr Skoda (http://skodak.org)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \core_text
*
*/
class text_test extends advanced_testcase {

/**
* Tests the static parse charset method.
*
* @covers ::parse_charset()
*/
public function test_parse_charset() {
$this->assertSame('windows-1250', core_text::parse_charset('Cp1250'));
Expand All @@ -47,6 +51,8 @@ public function test_parse_charset() {

/**
* Tests the static convert method.
*
* @covers ::convert()
*/
public function test_convert() {
$utf8 = "Žluťoučký koníček";
Expand Down Expand Up @@ -103,6 +109,8 @@ public function test_convert() {

/**
* Tests the static sub string method.
*
* @covers ::substr()
*/
public function test_substr() {
$str = "Žluťoučký koníček";
Expand Down Expand Up @@ -145,6 +153,8 @@ public function test_substr() {

/**
* Tests the static string length method.
*
* @covers ::strlen()
*/
public function test_strlen() {
$str = "Žluťoučký koníček";
Expand Down Expand Up @@ -184,6 +194,8 @@ public function test_strlen() {

/**
* Test unicode safe string truncation.
*
* @covers ::str_max_bytes()
*/
public function test_str_max_bytes() {
// These are all 3 byte characters, so this is a 12-byte string.
Expand Down Expand Up @@ -234,6 +246,8 @@ public function test_str_max_bytes() {

/**
* Tests the static strtolower method.
*
* @covers ::strtolower()
*/
public function test_strtolower() {
$str = "Žluťoučký koníček";
Expand Down Expand Up @@ -270,6 +284,8 @@ public function test_strtolower() {

/**
* Tests the static strtoupper.
*
* @covers ::strtoupper()
*/
public function test_strtoupper() {
$str = "Žluťoučký koníček";
Expand Down Expand Up @@ -303,6 +319,8 @@ public function test_strtoupper() {

/**
* Test the strrev method.
*
* @covers ::strrev()
*/
public function test_strrev() {
$strings = array(
Expand All @@ -323,6 +341,8 @@ public function test_strrev() {

/**
* Tests the static strpos method.
*
* @covers ::strpos()
*/
public function test_strpos() {
$str = "Žluťoučký koníček";
Expand All @@ -331,6 +351,8 @@ public function test_strpos() {

/**
* Tests the static strrpos.
*
* @covers ::strrpos()
*/
public function test_strrpos() {
$str = "Žluťoučký koníček";
Expand All @@ -339,6 +361,8 @@ public function test_strrpos() {

/**
* Tests the static specialtoascii method.
*
* @covers ::specialtoascii()
*/
public function test_specialtoascii() {
$str = "Žluťoučký koníček";
Expand All @@ -349,7 +373,9 @@ public function test_specialtoascii() {

/**
* Tests the static encode_mimeheader method.
* This also tests method moodle_phpmailer::encodeHeader that calls core_text::encode_mimeheader
*
* @covers ::encode_mimeheader()
* @covers \moodle_phpmailer::encodeHeader()
*/
public function test_encode_mimeheader() {
global $CFG;
Expand Down Expand Up @@ -388,6 +414,8 @@ public function test_encode_mimeheader() {

/**
* Tests the static entities_to_utf8 method.
*
* @covers ::entities_to_utf8()
*/
public function test_entities_to_utf8() {
$str = "Žluťoučký koníček©"&<>§«";
Expand All @@ -396,6 +424,8 @@ public function test_entities_to_utf8() {

/**
* Tests the static utf8_to_entities method.
*
* @covers ::utf8_to_entities()
*/
public function test_utf8_to_entities() {
$str = "Žluťoučký koníček©"&<>§«";
Expand All @@ -409,6 +439,8 @@ public function test_utf8_to_entities() {

/**
* Tests the static trim_utf8_bom method.
*
* @covers ::trim_utf8_bom()
*/
public function test_trim_utf8_bom() {
$bom = "\xef\xbb\xbf";
Expand All @@ -418,6 +450,8 @@ public function test_trim_utf8_bom() {

/**
* Tests the static remove_unicode_non_characters method.
*
* @covers ::remove_unicode_non_characters()
*/
public function test_remove_unicode_non_characters() {
// Confirm that texts which don't contain these characters are unchanged.
Expand All @@ -439,6 +473,8 @@ public function test_remove_unicode_non_characters() {

/**
* Tests the static get_encodings method.
*
* @covers ::get_encodings()
*/
public function test_get_encodings() {
$encodings = core_text::get_encodings();
Expand All @@ -449,13 +485,17 @@ public function test_get_encodings() {

/**
* Tests the static code2utf8 method.
*
* @covers ::code2utf8()
*/
public function test_code2utf8() {
$this->assertSame('Ž', core_text::code2utf8(381));
}

/**
* Tests the static utf8ord method.
*
* @covers ::utf8ord()
*/
public function test_utf8ord() {
$this->assertSame(ord(''), core_text::utf8ord(''));
Expand All @@ -468,6 +508,8 @@ public function test_utf8ord() {

/**
* Tests the static strtotitle method.
*
* @covers ::strtotitle()
*/
public function test_strtotitle() {
$str = "žluťoučký koníček";
Expand All @@ -476,6 +518,8 @@ public function test_strtotitle() {

/**
* Test strrchr.
*
* @covers ::strrchr()
*/
public function test_strrchr() {
$str = "Žluťoučký koníček";
Expand All @@ -491,6 +535,7 @@ public function test_strrchr() {
* @dataProvider is_charset_supported_provider()
* @param string $charset
* @param bool $expected
* @covers ::is_charset_supported()
*/
public function test_is_charset_supported(string $charset, bool $expected) {
$charset = core_text::parse_charset($charset);
Expand Down

0 comments on commit 3255c42

Please sign in to comment.