-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
159 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
/** | ||
* SPDX-License-Identifier: MIT | ||
* Copyright (c) 2017-2018 Tobias Reich | ||
* Copyright (c) 2018-2025 LycheeOrg. | ||
*/ | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
|
||
namespace Tests\Unit\Models; | ||
|
||
use App\Constants\AccessPermissionConstants as APC; | ||
use App\Models\AccessPermission; | ||
use Tests\AbstractTestCase; | ||
|
||
class AccessPermissionTest extends AbstractTestCase | ||
{ | ||
public function testCreateFullAccess(): void | ||
{ | ||
$ap = AccessPermission::withGrantFullPermissionsToUser(1); | ||
|
||
self::assertEquals(1, $ap->user_id); | ||
self::assertTrue($ap->{APC::GRANTS_FULL_PHOTO_ACCESS}); // @phpstan-ignore-line: Variable property access on App\Models\AccessPermission | ||
self::assertTrue($ap->{APC::GRANTS_DOWNLOAD}); // @phpstan-ignore-line: Variable property access on App\Models\AccessPermission | ||
self::assertTrue($ap->{APC::GRANTS_UPLOAD}); // @phpstan-ignore-line: Variable property access on App\Models\AccessPermission | ||
self::assertTrue($ap->{APC::GRANTS_EDIT}); // @phpstan-ignore-line: Variable property access on App\Models\AccessPermission | ||
self::assertTrue($ap->{APC::GRANTS_DELETE}); // @phpstan-ignore-line: Variable property access on App\Models\AccessPermission | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/** | ||
* SPDX-License-Identifier: MIT | ||
* Copyright (c) 2017-2018 Tobias Reich | ||
* Copyright (c) 2018-2025 LycheeOrg. | ||
*/ | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
|
||
namespace Tests\Unit\Models; | ||
|
||
use App\Enum\ConfigType; | ||
use App\Exceptions\Internal\InvalidConfigOption; | ||
use App\Models\Configs; | ||
use Tests\AbstractTestCase; | ||
|
||
class ConfigsTest extends AbstractTestCase | ||
{ | ||
public function testSetFailing(): void | ||
{ | ||
self::expectException(InvalidConfigOption::class); | ||
Configs::set('default_license', 'something'); | ||
} | ||
|
||
public function testSanity(): void | ||
{ | ||
$config = new Configs( | ||
[ | ||
'key' => 'key', | ||
'value' => '', | ||
'type_range' => ConfigType::STRING_REQ->value, | ||
] | ||
); | ||
self::assertEquals('Error: key empty or not set', $config->sanity('')); | ||
self::assertEquals('Error: key empty or not set', $config->sanity(null)); | ||
|
||
$config->type_range = ConfigType::POSTIIVE->value; | ||
self::assertEquals('Error: Wrong property for key, expected strictly positive integer, got a.', $config->sanity('a')); | ||
self::assertEquals('Error: Wrong property for key, expected strictly positive integer, got -1.', $config->sanity('-1')); | ||
self::assertEquals('Error: Wrong property for key, expected strictly positive integer, got 0.', $config->sanity('0')); | ||
|
||
$config->type_range = ConfigType::MAP_PROVIDER->value; | ||
self::assertEquals('Error: Wrong property for key, expected a valid map provider, got something.', $config->sanity('something')); | ||
|
||
$config->type_range = '1|2|3|4'; | ||
self::assertEquals('Error: Wrong property for key, expected 1 or 2 or 3 or 4, got 5.', $config->sanity('5')); | ||
} | ||
} |
Oops, something went wrong.