diff --git a/Math/Stochastic/Distribution/FDistribution.php b/Math/Stochastic/Distribution/FDistribution.php index 25f55847c..6fa6852e6 100644 --- a/Math/Stochastic/Distribution/FDistribution.php +++ b/Math/Stochastic/Distribution/FDistribution.php @@ -53,6 +53,10 @@ final class FDistribution */ public static function getMode(int $d1, int $d2) : float { + if ($d1 === 0) { + return 0.0; + } + return ($d1 - 2) / $d1 * $d2 / ($d2 + 2); } diff --git a/System/File/FileUtils.php b/System/File/FileUtils.php index 49296ebd8..c17ac0a9c 100644 --- a/System/File/FileUtils.php +++ b/System/File/FileUtils.php @@ -98,30 +98,30 @@ final class FileUtils */ public static function absolute(string $origPath) : string { - if (!\file_exists($origPath) || \realpath($origPath) === false) { - $startsWithSlash = \strpos($origPath, '/') === 0 ? '/' : ''; - - $path = []; - $parts = \explode('/', $origPath); - - foreach ($parts as $part) { - if (empty($part) || $part === '.') { - continue; - } - - if ($part !== '..') { - $path[] = $part; - } elseif (!empty($path)) { - \array_pop($path); - } else { - throw new PathException($origPath); - } - } - - return $startsWithSlash . \implode('/', $path); + if (\file_exists($origPath) || \realpath($origPath) !== false) { + return \realpath($origPath); } - return \realpath($origPath); + $startsWithSlash = \strpos($origPath, '/') === 0 ? '/' : ''; + + $path = []; + $parts = \explode('/', $origPath); + + foreach ($parts as $part) { + if (empty($part) || $part === '.') { + continue; + } + + if ($part !== '..') { + $path[] = $part; + } elseif (!empty($path)) { + \array_pop($path); + } else { + throw new PathException($origPath); + } + } + + return $startsWithSlash . \implode('/', $path); } /** diff --git a/tests/Account/AccountTest.php b/tests/Account/AccountTest.php index 1c54b31ca..c3ccca6bd 100644 --- a/tests/Account/AccountTest.php +++ b/tests/Account/AccountTest.php @@ -221,6 +221,12 @@ class AccountTest extends \PHPUnit\Framework\TestCase new class() extends PermissionAbstract {}, ]); self::assertCount(4, $account->getPermissions()); + + $account->addPermissions([[ + new class() extends PermissionAbstract {}, + new class() extends PermissionAbstract {}, + ]]); + self::assertCount(6, $account->getPermissions()); } /** diff --git a/tests/Account/GroupTest.php b/tests/Account/GroupTest.php index a24b8115a..f2a5c4607 100644 --- a/tests/Account/GroupTest.php +++ b/tests/Account/GroupTest.php @@ -100,22 +100,28 @@ class GroupTest extends \PHPUnit\Framework\TestCase */ public function testPermissionAdd() : void { - $account = new Group(); + $group = new Group(); - $account->addPermission(new class() extends PermissionAbstract {}); - self::assertCount(1, $account->getPermissions()); + $group->addPermission(new class() extends PermissionAbstract {}); + self::assertCount(1, $group->getPermissions()); - $account->setPermissions([ + $group->setPermissions([ new class() extends PermissionAbstract {}, new class() extends PermissionAbstract {}, ]); - self::assertCount(2, $account->getPermissions()); + self::assertCount(2, $group->getPermissions()); - $account->addPermissions([ + $group->addPermissions([ new class() extends PermissionAbstract {}, new class() extends PermissionAbstract {}, ]); - self::assertCount(4, $account->getPermissions()); + self::assertCount(4, $group->getPermissions()); + + $group->addPermissions([[ + new class() extends PermissionAbstract {}, + new class() extends PermissionAbstract {}, + ]]); + self::assertCount(6, $group->getPermissions()); } /** @@ -125,13 +131,13 @@ class GroupTest extends \PHPUnit\Framework\TestCase */ public function testPermissionExists() : void { - $account = new Group(); + $group = new Group(); - $account->addPermission(new class() extends PermissionAbstract {}); - self::assertCount(1, $account->getPermissions()); + $group->addPermission(new class() extends PermissionAbstract {}); + self::assertCount(1, $group->getPermissions()); - self::assertFalse($account->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1)); - self::assertTrue($account->hasPermission(PermissionType::NONE)); + self::assertFalse($group->hasPermission(PermissionType::READ, 1, 'a', 'a', 1, 1, 1)); + self::assertTrue($group->hasPermission(PermissionType::NONE)); } /** @@ -141,16 +147,16 @@ class GroupTest extends \PHPUnit\Framework\TestCase */ public function testPermissionRemove() : void { - $account = new Group(); + $group = new Group(); $perm = new class() extends PermissionAbstract {}; $perm->setPermission(PermissionType::READ); - $account->addPermission($perm); - self::assertCount(1, $account->getPermissions()); + $group->addPermission($perm); + self::assertCount(1, $group->getPermissions()); - $account->removePermission($perm); - self::assertCount(0, $account->getPermissions()); + $group->removePermission($perm); + self::assertCount(0, $group->getPermissions()); } /** diff --git a/tests/Ai/Ocr/BasicOcrTest.php b/tests/Ai/Ocr/BasicOcrTest.php new file mode 100644 index 000000000..6ea8367ff --- /dev/null +++ b/tests/Ai/Ocr/BasicOcrTest.php @@ -0,0 +1,26 @@ +setData('gdata', 'abc')); self::assertEquals('abc', REST::request($request)->getJsonData()['args']['gdata']); } + + public function testJsonRequest() : void + { + self::markTestIncomplete(); + } + + public function testMultiRequest() : void + { + self::markTestIncomplete(); + } } diff --git a/tests/Router/WebRouterTest.php b/tests/Router/WebRouterTest.php index 4be07fe71..266c12b47 100644 --- a/tests/Router/WebRouterTest.php +++ b/tests/Router/WebRouterTest.php @@ -295,4 +295,14 @@ class WebRouterTest extends \PHPUnit\Framework\TestCase ) ); } + + public function testDataValidation() : void + { + self::markTestIncomplete(); + } + + public function testDataFromPattern() : void + { + self::markTestIncomplete(); + } } diff --git a/tests/System/File/FileUtilsTest.php b/tests/System/File/FileUtilsTest.php index f0b2db0c9..d7aa74a89 100644 --- a/tests/System/File/FileUtilsTest.php +++ b/tests/System/File/FileUtilsTest.php @@ -54,6 +54,7 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase */ public function testAbsolute() : void { + self::assertEquals(\realpath(__DIR__ . '/..'), FileUtils::absolute(__DIR__ . '/..')); self::assertEquals('/test/ative', FileUtils::absolute('/test/path/for/../rel/../../ative')); } @@ -66,4 +67,9 @@ class FileUtilsTest extends \PHPUnit\Framework\TestCase { self::assertEquals(0742, FileUtils::permissionToOctal('rwxr---w-')); } + + public function testChangeFileEncoding() : void + { + self::markTestIncomplete(); + } } diff --git a/tests/Utils/MbStringUtilsTest.php b/tests/Utils/MbStringUtilsTest.php index 273734369..71f9e6952 100644 --- a/tests/Utils/MbStringUtilsTest.php +++ b/tests/Utils/MbStringUtilsTest.php @@ -27,7 +27,7 @@ class MbStringUtilsTest extends \PHPUnit\Framework\TestCase { /** * @testdox The entropy of a string can be calculated - * @covers phpOMS\Utils\StringUtils + * @covers phpOMS\Utils\MbStringUtils * @group framework */ public function testEntropy() : void @@ -37,7 +37,7 @@ class MbStringUtilsTest extends \PHPUnit\Framework\TestCase /** * @testdox A string can be checked for multi-byte characters - * @covers phpOMS\Utils\StringUtils + * @covers phpOMS\Utils\MbStringUtils * @group framework */ public function testHasMultiBytes() : void @@ -151,4 +151,9 @@ class MbStringUtilsTest extends \PHPUnit\Framework\TestCase { self::assertEquals(5, MbStringUtils::mb_count_chars('αααααΕεΙιΜμΨψ')['α']); } + + public function testUtf8CharBoundary() : void + { + self::markTestIncomplete(); + } }