summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2022-03-22 14:32:32 +0300
committerAndrew Dolgov <[email protected]>2022-03-22 14:32:32 +0300
commite35a4a1306d7fe0736d2f6ba3e0284308d29ebd0 (patch)
tree03c9b765938c1fdabf55b40bc1247af2b2b6d9b0 /tests
parent1c4f7ab3b838b23afb2ee4dab14acbf75956e952 (diff)
tests: add stub autoloader, add a few more rewrite_relative tests
Diffstat (limited to 'tests')
-rw-r--r--tests/UrlHelperTest.php32
-rw-r--r--tests/autoload.php6
2 files changed, 22 insertions, 16 deletions
diff --git a/tests/UrlHelperTest.php b/tests/UrlHelperTest.php
index 2d92c332b..fe4eb5db2 100644
--- a/tests/UrlHelperTest.php
+++ b/tests/UrlHelperTest.php
@@ -1,24 +1,9 @@
<?php
-set_include_path(dirname(__DIR__) ."/include" . PATH_SEPARATOR .
- get_include_path());
-
-require_once "autoload.php";
-require_once "functions.php";
use PHPUnit\Framework\TestCase;
final class UrlHelperTest extends TestCase {
- public function testCanBeUsedAsString(): void {
- /*$this->assertEquals(
- 'http://example.com/example.html',
- UrlHelper::rewrite_relative('http://example.com/example/', '/example.html')
- );
-
- $this->assertEquals(
- 'http://example.com/example/example.html',
- UrlHelper::rewrite_relative('http://example.com/example/', 'example.html')
- );*/
-
+ public function test_rewrite_relative(): void {
// protocol-neutral URL
$this->assertEquals(
'https://example.com/example.html',
@@ -50,5 +35,20 @@ final class UrlHelperTest extends TestCase {
UrlHelper::rewrite_relative('https://apod.nasa.gov/apod/ap220315.html', './image/2203/Road2Stars_EsoHoralek_1080.jpg')
);
+ $this->assertEquals(
+ 'http://example.com/test/url',
+ UrlHelper::rewrite_relative('http://example.com/test/url', '')
+ );
+
+ $this->assertEquals(
+ 'http://www.example.com/test',
+ UrlHelper::rewrite_relative('http://www.example2.com ', 'http://www.example.com/test')
+ );
+
+ $this->assertEquals(
+ 'http://www.example.com/test',
+ UrlHelper::rewrite_relative('http://www.example.com/test2 ', 'http://www.example.com/test')
+ );
+
}
}
diff --git a/tests/autoload.php b/tests/autoload.php
new file mode 100644
index 000000000..1fb33424e
--- /dev/null
+++ b/tests/autoload.php
@@ -0,0 +1,6 @@
+<?php
+ set_include_path(dirname(__DIR__) ."/include" . PATH_SEPARATOR .
+ get_include_path());
+
+ require_once "autoload.php";
+ require_once "functions.php";