. */ namespace App\Tests\Settings\SystemSettings; use App\Settings\SystemSettings\AttachmentsSettings; use App\Tests\SettingsTestHelper; use PHPUnit\Framework\TestCase; class AttachmentsSettingsTest extends TestCase { public function testGetMaxFileSizeInMegabytes(): void { $settings = SettingsTestHelper::createSettingsDummy(AttachmentsSettings::class); $settings->maxFileSize = '100M'; $this->assertEquals(100, $settings->getMaxFileSizeInMegabytes()); $settings->maxFileSize = '1G'; $this->assertEquals(1024, $settings->getMaxFileSizeInMegabytes()); //We round up to the next megabyte if the file size is smaller than 1 MB $settings->maxFileSize = '500K'; $this->assertEquals(1, $settings->getMaxFileSizeInMegabytes()); $settings->maxFileSize = '13.5M'; $this->assertEquals(13, $settings->getMaxFileSizeInMegabytes()); } }