summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/CharArmorTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/CharArmorTest.php')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/CharArmorTest.php104
1 files changed, 104 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/CharArmorTest.php b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/CharArmorTest.php
new file mode 100644
index 00000000..e2e4e8e8
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/tests/phpunit/Unit/Utils/CharArmorTest.php
@@ -0,0 +1,104 @@
+<?php
+
+namespace SMW\Tests\Utils;
+
+use SMW\Utils\CharArmor;
+
+/**
+ * @covers \SMW\Utils\CharArmor
+ * @group semantic-mediawiki
+ *
+ * @license GNU GPL v2+
+ * @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-Width​Space::"​"]]',
+ '[[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;
+ }
+
+}