gplx/mediawiki/extensions/SemanticMediaWiki/tests/phpunit/Utils/CharArmorTest.php

101 lines
1.7 KiB
PHP
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace SMW\Tests\Utils;
use SMW\Utils\CharArmor;
/**
* @covers \SMW\Utils\CharArmor
* @group semantic-mediawiki
*
* @license GPL-2.0-or-later
* @since 3.0
*
* @author mwjames
*/
class CharArmorTest extends \PHPUnit\Framework\TestCase {
/**
* @dataProvider invisibleControlCharactersProvider
*/
public function testRemoveControlChars( $withControlChar, $expected ) {
$this->assertFalse(
$expected === $withControlChar
);
$this->assertEquals(
$expected,
CharArmor::removeControlChars( $withControlChar )
);
}
/**
* @dataProvider specialCharactersProvider
*/
public function testRemoveSpecialChars( $withSpecialChar, $expected ) {
$this->assertEquals(
$expected,
CharArmor::removeSpecialChars( $withSpecialChar )
);
}
public function invisibleControlCharactersProvider() {
$provider[] = [
'[[Left-To-Right Mark::""]]',
'[[Left-To-Right Mark::""]]'
];
$provider[] = [
'[[Right-To-Left Mark::""]]',
'[[Right-To-Left Mark::""]]'
];
$provider[] = [
'[[Zero-WidthSpace::""]]',
'[[Zero-WidthSpace::""]]'
];
$provider[] = [
'[[Zero Width Non-Joiner::""]]',
'[[Zero Width Non-Joiner::""]]'
];
$provider[] = [
'[[Zero Width Joiner::""]]',
'[[Zero Width Joiner::""]]'
];
return $provider;
}
public function specialCharactersProvider() {
$provider[] = [
'visible shy&shy;ness',
'visible shyness'
];
$provider[] = [
'leftToRight&lrm;Mark',
'leftToRightMark'
];
$provider[] = [
'[[Figure Space::""]]',
'[[Figure Space::" "]]'
];
$provider[] = [
'[[En Quad::" "]]',
'[[En Quad::" "]]'
];
$provider[] = [
'[[Hair Space::""]]',
'[[Hair Space::" "]]'
];
return $provider;
}
}