mirror of
https://github.com/notf0und/SGS
synced 2026-07-18 02:31:08 +00:00
### Changes
Fixes #3: Error on DBI when files or folders contains special characters. ### Additional changes * Added unit and feature tests * Fix file size display * Run tests on CI/CD * Publish docker image on release
This commit is contained in:
parent
15b9c17b99
commit
0993bfa666
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
test('that true is true', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use App\Helpers\FileSize;
|
||||
|
||||
test('formats zero bytes as "0"', function () {
|
||||
expect(FileSize::format(0))->toBe('0');
|
||||
});
|
||||
|
||||
test('formats byte values without decimal places', function () {
|
||||
expect(FileSize::format(1))->toBe('1');
|
||||
expect(FileSize::format(512))->toBe('512');
|
||||
expect(FileSize::format(1001))->toBe('1001');
|
||||
expect(FileSize::format(1023))->toBe('1023');
|
||||
});
|
||||
|
||||
test('formats kilobytes', function () {
|
||||
expect(FileSize::format(1024))->toBe('1.00K');
|
||||
expect(FileSize::format(1536))->toBe('1.50K');
|
||||
});
|
||||
|
||||
test('formats megabytes', function () {
|
||||
expect(FileSize::format(1024 * 1024))->toBe('1.00M');
|
||||
expect(FileSize::format((int) (1.5 * 1024 * 1024)))->toBe('1.50M');
|
||||
});
|
||||
|
||||
test('formats gigabytes', function () {
|
||||
expect(FileSize::format(1024 * 1024 * 1024))->toBe('1.00G');
|
||||
});
|
||||
|
||||
test('formats terabytes', function () {
|
||||
expect(FileSize::format(1024 * 1024 * 1024 * 1024))->toBe('1.00T');
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use App\Enums\NintendoFileExtension;
|
||||
|
||||
test('values() returns all four supported extensions', function () {
|
||||
expect(NintendoFileExtension::values())->toBe(['nsp', 'nsz', 'xci', 'xcz']);
|
||||
});
|
||||
|
||||
test('isSupported() returns true for each supported extension', function (string $filename) {
|
||||
expect(NintendoFileExtension::isSupported($filename))->toBeTrue();
|
||||
})->with(['game.nsp', 'game.nsz', 'game.xci', 'game.xcz']);
|
||||
|
||||
test('isSupported() is case-insensitive', function (string $filename) {
|
||||
expect(NintendoFileExtension::isSupported($filename))->toBeTrue();
|
||||
})->with(['game.NSP', 'game.NSZ', 'game.XCI', 'game.XCZ', 'game.Nsp', 'game.Xci']);
|
||||
|
||||
test('isSupported() returns false for unsupported extensions', function (string $filename) {
|
||||
expect(NintendoFileExtension::isSupported($filename))->toBeFalse();
|
||||
})->with(['game.txt', 'game.exe', 'game.zip', 'game.iso', 'game.php', 'game.rom']);
|
||||
|
||||
test('isSupported() returns false for files without an extension', function () {
|
||||
expect(NintendoFileExtension::isSupported('gamefile'))->toBeFalse();
|
||||
});
|
||||
|
||||
test('isSupported() works with paths containing directory separators', function () {
|
||||
expect(NintendoFileExtension::isSupported('folder/game.nsp'))->toBeTrue();
|
||||
expect(NintendoFileExtension::isSupported('folder/sub/game.xci'))->toBeTrue();
|
||||
expect(NintendoFileExtension::isSupported('folder/game.txt'))->toBeFalse();
|
||||
});
|
||||
Reference in New Issue
Block a user