Skip to content

Commit

Permalink
Fix styling
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze authored and github-actions[bot] committed Jan 29, 2024
1 parent 04766fe commit 3c4021c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
30 changes: 15 additions & 15 deletions tests/Conversions/ConversionCustomWidthCalculator.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
<?php


use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Spatie\MediaLibrary\Tests\TestSupport\TestModels\TestModel;
use Spatie\MediaLibrary\Tests\TestSupport\WidthCalculators\FixedWidthCalculator;

it('can utilize various width calculators for conversions across different models', function () {
$testModel3Sizes = (new class() extends TestModel {
$testModel3Sizes = (new class() extends TestModel
{
public function registerMediaConversions(?Media $media = null): void
{
$this->addMediaConversion('fixed_width')->withWidthCalculator(new FixedWidthCalculator([99, 60, 33]))->withResponsiveImages();
}
})::create(['name' => 'test.jpg']);;
})::create(['name' => 'test.jpg']);

$testModel5Sizes = (new class() extends TestModel {
$testModel5Sizes = (new class() extends TestModel
{
public function registerMediaConversions(?Media $media = null): void
{
$this->addMediaConversion('fixed_width')->withWidthCalculator(new FixedWidthCalculator([76, 59, 44, 23, 11]))->withResponsiveImages();
Expand All @@ -23,19 +24,18 @@ public function registerMediaConversions(?Media $media = null): void
$testModel3Sizes->addMedia($this->getTestJpg())->toMediaCollection();

$this->assertSame([
"/media/1/responsive-images/test___fixed_width_99_82.jpg",
"/media/1/responsive-images/test___fixed_width_60_49.jpg",
"/media/1/responsive-images/test___fixed_width_33_27.jpg",
], $testModel3Sizes->getFirstMedia()->getResponsiveImageUrls("fixed_width"));

'/media/1/responsive-images/test___fixed_width_99_82.jpg',
'/media/1/responsive-images/test___fixed_width_60_49.jpg',
'/media/1/responsive-images/test___fixed_width_33_27.jpg',
], $testModel3Sizes->getFirstMedia()->getResponsiveImageUrls('fixed_width'));

$testModel5Sizes->addMedia($this->getTestPng())->toMediaCollection();

$this->assertSame([
"/media/2/responsive-images/test___fixed_width_76_96.jpg",
"/media/2/responsive-images/test___fixed_width_59_74.jpg",
"/media/2/responsive-images/test___fixed_width_44_56.jpg",
"/media/2/responsive-images/test___fixed_width_23_29.jpg",
"/media/2/responsive-images/test___fixed_width_11_14.jpg",
], $testModel5Sizes->getFirstMedia()->getResponsiveImageUrls("fixed_width"));
'/media/2/responsive-images/test___fixed_width_76_96.jpg',
'/media/2/responsive-images/test___fixed_width_59_74.jpg',
'/media/2/responsive-images/test___fixed_width_44_56.jpg',
'/media/2/responsive-images/test___fixed_width_23_29.jpg',
'/media/2/responsive-images/test___fixed_width_11_14.jpg',
], $testModel5Sizes->getFirstMedia()->getResponsiveImageUrls('fixed_width'));
});
5 changes: 3 additions & 2 deletions tests/TestSupport/WidthCalculators/FixedWidthCalculator.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php

namespace Spatie\MediaLibrary\Tests\TestSupport\WidthCalculators;

use Illuminate\Support\Collection;
use Spatie\MediaLibrary\ResponsiveImages\WidthCalculator\WidthCalculator;

class FixedWidthCalculator implements WidthCalculator {

class FixedWidthCalculator implements WidthCalculator
{
public function __construct(public array $widths)
{
}
Expand Down

0 comments on commit 3c4021c

Please sign in to comment.