aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2022-03-20 14:35:25 +0100
committerHarald Eilertsen <haraldei@anduin.net>2022-03-20 15:34:24 +0100
commitb02f6a1dae3e3fae4af4b24e65256cdf653b2515 (patch)
tree61a6ae0c29b681b699374a38806ce0c3c7331dd3 /tests/unit
parentd35609f33a3679043b8fa4dc3ad2570b425c06f5 (diff)
downloadvolse-hubzilla-b02f6a1dae3e3fae4af4b24e65256cdf653b2515.tar.gz
volse-hubzilla-b02f6a1dae3e3fae4af4b24e65256cdf653b2515.tar.bz2
volse-hubzilla-b02f6a1dae3e3fae4af4b24e65256cdf653b2515.zip
Add function is_local_url() to check if url is local.
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/includes/NetworkTest.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/unit/includes/NetworkTest.php b/tests/unit/includes/NetworkTest.php
new file mode 100644
index 000000000..0b9b42e00
--- /dev/null
+++ b/tests/unit/includes/NetworkTest.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * tests function from include/network.php
+ *
+ * @package test.util
+ */
+
+use PHPUnit\Framework\TestCase;
+
+require_once('include/network.php');
+
+class NetworkTest extends TestCase {
+
+ public function setup() : void {
+ \App::set_baseurl("https://mytest.org");
+ }
+
+ /**
+ * @dataProvider localUrlTestProvider
+ */
+ public function testIsLocalURL($url, $expected) {
+ $this->assertEquals($expected, is_local_url($url));
+ }
+
+ public function localUrlTestProvider() : array {
+ return [
+ [ '/some/path', true ],
+ [ 'https://mytest.org/some/path', true ],
+ [ 'https://other.site/some/path', false ],
+ ];
+ }
+}
+