aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/includes/NetworkTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/includes/NetworkTest.php')
-rw-r--r--tests/unit/includes/NetworkTest.php52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/unit/includes/NetworkTest.php b/tests/unit/includes/NetworkTest.php
index ea1fd6fa0..0d99fc9c3 100644
--- a/tests/unit/includes/NetworkTest.php
+++ b/tests/unit/includes/NetworkTest.php
@@ -67,4 +67,56 @@ class NetworkTest extends Zotlabs\Tests\Unit\UnitTestCase {
['address-tag@example.com', true],
];
}
+
+ /**
+ * Test the unparse_url function.
+ *
+ */
+ public function test_unparse_url_full()
+ {
+ $parsed_url = [
+ 'scheme' => 'https',
+ 'host' => 'www.example.com',
+ 'port' => '8080',
+ 'user' => 'username',
+ 'pass' => 'password',
+ 'path' => '/path',
+ 'query' => 'param=value',
+ 'fragment' => 'section'
+ ];
+
+ $expected = 'https://username:password@www.example.com:8080/path?param=value#section';
+ $this->assertEquals($expected, unparse_url($parsed_url));
+ }
+
+ public function test_unparse_url_partial()
+ {
+ $parsed_url = [
+ 'scheme' => 'http',
+ 'host' => 'example.com',
+ 'path' => '/index.php'
+ ];
+
+ $expected = 'http://example.com/index.php';
+ $this->assertEquals($expected, unparse_url($parsed_url));
+ }
+
+ public function test_unparse_url_custom()
+ {
+ $parsed_url = [
+ 'scheme' => 'https',
+ 'host' => 'www.example.com',
+ 'port' => '443',
+ 'path' => '/api'
+ ];
+
+ $parts = ['scheme', 'host'];
+ $expected = 'https://www.example.com';
+ $this->assertEquals($expected, unparse_url($parsed_url, $parts));
+ }
+
+ public function test_unparse_url_empty()
+ {
+ $this->assertEquals('', unparse_url([]));
+ }
}