diff --git a/tests/Unit/ResourceLimitsTest.php b/tests/Unit/ResourceLimitsTest.php index 1e656fd..7bc667a 100644 --- a/tests/Unit/ResourceLimitsTest.php +++ b/tests/Unit/ResourceLimitsTest.php @@ -3,36 +3,40 @@ use Spatie\PdfToImage\Enums\ResourceLimitType; use Spatie\PdfToImage\Pdf; +beforeEach(function () { + $this->memory128MbInBytes = 134217728; +}); + it('sets the area resource limit', function () { $pdf = new Pdf($this->testFile); - $im = $pdf->resourceLimit(ResourceLimitType::Area, 1024 * 1024 * 128) + $im = $pdf->resourceLimit(ResourceLimitType::Area, $this->memory128MbInBytes) ->getImageData($this->testFile, 1); - expect((int) $im::getResourceLimit(ResourceLimitType::Area->value))->toBeGreaterThanOrEqual((int) 1024 * 1024 * 128); + expect((int) $im::getResourceLimit(ResourceLimitType::Area->value))->toBeGreaterThanOrEqual($this->memory128MbInBytes); }); it('sets the disk resource limit', function () { $pdf = new Pdf($this->testFile); - $im = $pdf->resourceLimit(ResourceLimitType::Disk, 1024 * 1024 * 128) + $im = $pdf->resourceLimit(ResourceLimitType::Disk, $this->memory128MbInBytes) ->getImageData($this->testFile, 1); - expect((int) $im::getResourceLimit(ResourceLimitType::Disk->value))->toBeGreaterThanOrEqual((int) 1024 * 1024 * 128); + expect((int) $im::getResourceLimit(ResourceLimitType::Disk->value))->toBeGreaterThanOrEqual($this->memory128MbInBytes); }); it('sets the map resource limit', function () { $pdf = new Pdf($this->testFile); - $im = $pdf->resourceLimit(ResourceLimitType::Map, 1024 * 1024 * 128) + $im = $pdf->resourceLimit(ResourceLimitType::Map, $this->memory128MbInBytes) ->getImageData($this->testFile, 1); - expect((int) $im::getResourceLimit(ResourceLimitType::Map->value))->toBeGreaterThanOrEqual((int) 1024 * 1024 * 128); + expect((int) $im::getResourceLimit(ResourceLimitType::Map->value))->toBeGreaterThanOrEqual($this->memory128MbInBytes); }); it('sets the memory resource limit', function () { $pdf = new Pdf($this->testFile); - $im = $pdf->resourceLimit(ResourceLimitType::Memory, 1024 * 1024 * 128) + $im = $pdf->resourceLimit(ResourceLimitType::Memory, $this->memory128MbInBytes) ->getImageData($this->testFile, 1); - expect((int) $im::getResourceLimit(ResourceLimitType::Memory->value))->toBeGreaterThanOrEqual((int) 1024 * 1024 * 128); + expect((int) $im::getResourceLimit(ResourceLimitType::Memory->value))->toBeGreaterThanOrEqual($this->memory128MbInBytes); }); it('sets the time resource limit', function () {