summaryrefslogtreecommitdiff
path: root/www/wiki/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php')
-rw-r--r--www/wiki/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php93
1 files changed, 93 insertions, 0 deletions
diff --git a/www/wiki/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php b/www/wiki/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
new file mode 100644
index 00000000..eae5588b
--- /dev/null
+++ b/www/wiki/tests/phpunit/includes/GlobalFunctions/wfRemoveDotSegmentsTest.php
@@ -0,0 +1,93 @@
+<?php
+
+/**
+ * @group GlobalFunctions
+ * @covers ::wfRemoveDotSegments
+ */
+class WfRemoveDotSegmentsTest extends MediaWikiTestCase {
+ /**
+ * @dataProvider providePaths
+ */
+ public function testWfRemoveDotSegments( $inputPath, $outputPath ) {
+ $this->assertEquals(
+ $outputPath,
+ wfRemoveDotSegments( $inputPath ),
+ "Testing $inputPath expands to $outputPath"
+ );
+ }
+
+ /**
+ * Provider of URL paths for testing wfRemoveDotSegments()
+ *
+ * @return array
+ */
+ public static function providePaths() {
+ return [
+ [ '/a/b/c/./../../g', '/a/g' ],
+ [ 'mid/content=5/../6', 'mid/6' ],
+ [ '/a//../b', '/a/b' ],
+ [ '/.../a', '/.../a' ],
+ [ '.../a', '.../a' ],
+ [ '', '' ],
+ [ '/', '/' ],
+ [ '//', '//' ],
+ [ '.', '' ],
+ [ '..', '' ],
+ [ '...', '...' ],
+ [ '/.', '/' ],
+ [ '/..', '/' ],
+ [ './', '' ],
+ [ '../', '' ],
+ [ './a', 'a' ],
+ [ '../a', 'a' ],
+ [ '../../a', 'a' ],
+ [ '.././a', 'a' ],
+ [ './../a', 'a' ],
+ [ '././a', 'a' ],
+ [ '../../', '' ],
+ [ '.././', '' ],
+ [ './../', '' ],
+ [ '././', '' ],
+ [ '../..', '' ],
+ [ '../.', '' ],
+ [ './..', '' ],
+ [ './.', '' ],
+ [ '/../../a', '/a' ],
+ [ '/.././a', '/a' ],
+ [ '/./../a', '/a' ],
+ [ '/././a', '/a' ],
+ [ '/../../', '/' ],
+ [ '/.././', '/' ],
+ [ '/./../', '/' ],
+ [ '/././', '/' ],
+ [ '/../..', '/' ],
+ [ '/../.', '/' ],
+ [ '/./..', '/' ],
+ [ '/./.', '/' ],
+ [ 'b/../../a', '/a' ],
+ [ 'b/.././a', '/a' ],
+ [ 'b/./../a', '/a' ],
+ [ 'b/././a', 'b/a' ],
+ [ 'b/../../', '/' ],
+ [ 'b/.././', '/' ],
+ [ 'b/./../', '/' ],
+ [ 'b/././', 'b/' ],
+ [ 'b/../..', '/' ],
+ [ 'b/../.', '/' ],
+ [ 'b/./..', '/' ],
+ [ 'b/./.', 'b/' ],
+ [ '/b/../../a', '/a' ],
+ [ '/b/.././a', '/a' ],
+ [ '/b/./../a', '/a' ],
+ [ '/b/././a', '/b/a' ],
+ [ '/b/../../', '/' ],
+ [ '/b/.././', '/' ],
+ [ '/b/./../', '/' ],
+ [ '/b/././', '/b/' ],
+ [ '/b/../..', '/' ],
+ [ '/b/../.', '/' ],
+ [ '/b/./..', '/' ],
+ [ '/b/./.', '/b/' ],
+ ];
+ }
+}