nur-sery/nur_tests/pathTest.php

51 lines
1.9 KiB
PHP
Raw Normal View History

2023-12-03 22:11:29 +04:00
<?php
namespace nur;
use nur\t\TestCase;
class pathTest extends TestCase {
function testSplit() {
self::assertSame([false, false], path::split(false));
self::assertSame([null, null], path::split(null));
self::assertSame(["", ""], path::split(""));
self::assertSame(["/", "a"], path::split("/a"));
self::assertSame(["/a", ""], path::split("/a/"));
self::assertSame(["/a", "b"], path::split("/a/b"));
self::assertSame(["/a/b", "c"], path::split("/a/b/c"));
self::assertSame(["", "a"], path::split("a"));
self::assertSame(["a", ""], path::split("a/"));
self::assertSame(["a", "b"], path::split("a/b"));
self::assertSame(["a/b", "c"], path::split("a/b/c"));
}
function testJoin() {
self::assertNull(path::join());
self::assertNull(path::join(null));
self::assertNull(path::join(false));
self::assertNull(path::join(null, null));
self::assertNull(path::join(null, false));
self::assertSame(".", path::join(""));
self::assertSame("a", path::join("a", ""));
self::assertSame("a", path::join("", "a"));
self::assertSame("a/b", path::join("a", "b"));
self::assertSame("a/b", path::join("a/", "b"));
self::assertSame("a/b", path::join("a", "/b"));
self::assertSame("a/b", path::join("a/", "/b"));
}
function testReljoin() {
self::assertNull(path::reljoin());
self::assertNull(path::reljoin(null));
self::assertNull(path::reljoin(false));
self::assertNull(path::reljoin(null, null));
self::assertNull(path::reljoin(null, false));
self::assertSame(".", path::reljoin(""));
self::assertSame("a", path::reljoin("a", ""));
self::assertSame("a", path::reljoin("", "a"));
self::assertSame("a/b", path::reljoin("a", "b"));
self::assertSame("a/b", path::reljoin("a/", "b"));
self::assertSame("/b", path::reljoin("a", "/b"));
self::assertSame("/b", path::reljoin("a/", "/b"));
}
}