101 lines
1.7 KiB
PHP
101 lines
1.7 KiB
PHP
<?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­ness',
|
||
'visible shyness'
|
||
];
|
||
|
||
$provider[] = [
|
||
'leftToRight‎Mark',
|
||
'leftToRightMark'
|
||
];
|
||
|
||
$provider[] = [
|
||
'[[Figure Space::" "]]',
|
||
'[[Figure Space::" "]]'
|
||
];
|
||
|
||
$provider[] = [
|
||
'[[En Quad::" "]]',
|
||
'[[En Quad::" "]]'
|
||
];
|
||
|
||
$provider[] = [
|
||
'[[Hair Space::" "]]',
|
||
'[[Hair Space::" "]]'
|
||
];
|
||
|
||
return $provider;
|
||
}
|
||
|
||
}
|