trypost/tests/Unit/Enums/AspectRatioTest.php
Paulo Castellano efe49c34de Make AspectRatio the single source for crop math; fill test gaps
Review follow-ups:
- AspectRatio::toFloat() now owns the crop ratio math; CropsImageForAspectRatio
  delegates to it so the enum is the single source of truth for both validation
  and cropping (no more parallel literal map).
- API update controller now reloads postPlatforms before returning, so the
  update response reflects the persisted platform meta/content_type (was stale).
- Tests: AspectRatio enum unit test; API valid-update read-back + 'original'
  on create; MCP response read-back + valid update.
2026-06-10 15:52:41 -03:00

19 lines
576 B
PHP

<?php
declare(strict_types=1);
use App\Enums\PostPlatform\AspectRatio;
test('aspect ratio has the expected cases and values', function () {
expect(array_column(AspectRatio::cases(), 'value'))
->toEqualCanonicalizing(['1:1', '4:5', '16:9', 'original']);
});
test('aspect ratio maps to the correct crop float', function (string $value, float $expected) {
expect(AspectRatio::from($value)->toFloat())->toBe($expected);
})->with([
'1:1' => ['1:1', 1.0],
'4:5' => ['4:5', 4 / 5],
'16:9' => ['16:9', 16 / 9],
'original' => ['original', 1.0],
]);