Skip to content

Commit

Permalink
10.0.1 (#29)
Browse files Browse the repository at this point in the history
* Replaced `phpcs/phpcbf` by `laravel/pint`
  • Loading branch information
Okipa authored Aug 1, 2022
1 parent bf651a9 commit b92ecd6
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 105 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/.composer/cache/files
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
Expand All @@ -46,7 +46,7 @@ jobs:
# Lower PHP and laravel versions.

- name: PHPUnit
- name: PHPUnit without code coverage
if: matrix.php != '8.1' || matrix.laravel != '9.*'
run: vendor/bin/testbench package:test --parallel --no-coverage

Expand All @@ -55,11 +55,11 @@ jobs:
- name: Code analysis
if: matrix.php == '8.1' && matrix.laravel == '9.*'
run: |
vendor/bin/phpcs
vendor/bin/pint --test -vvv
vendor/bin/phpmd src,tests text phpmd.xml
vendor/bin/phpstan analyse
- name: PHPUnit + Code coverage
- name: PHPUnit with code coverage
if: matrix.php == '8.1' && matrix.laravel == '9.*'
run: |
mkdir -p build/logs
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [10.0.1](https://github.com/Okipa/laravel-medialibrary-ext/compare/10.0.0...10.0.1)

2022-08-01

* Replaced `phpcs/phpcbf` by `laravel/pint`

## [10.0.0](https://github.com/Okipa/laravel-medialibrary-ext/compare/9.2.0...10.0.0)

2021-01-24
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"nunomaduro/larastan": "^1.0",
"orchestra/testbench": "^7.0",
"phpmd/phpmd": "^2.11",
"squizlabs/php_codesniffer": "^3.6"
"laravel/pint": "^1.1"
},
"autoload": {
"psr-4": {
Expand All @@ -48,11 +48,11 @@
}
},
"scripts": {
"phpcs": ["vendor/bin/phpcbf", "vendor/bin/phpcs"],
"pint": ["vendor/bin/pint"],
"phpmd": "vendor/bin/phpmd src,tests text phpmd.xml",
"phpstan": "vendor/bin/phpstan analyse --memory-limit=2G",
"phpunit" : "vendor/bin/testbench package:test --parallel --no-coverage",
"test": ["@phpcs", "@phpmd", "@phpstan", "@phpunit"]
"test": ["@pint", "@phpmd", "@phpstan", "@phpunit"]
},
"extra": {
"laravel": {
Expand Down
21 changes: 0 additions & 21 deletions phpcs.xml

This file was deleted.

10 changes: 10 additions & 0 deletions pint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"preset": "laravel",
"rules": {
"concat_space": {
"spacing": "one"
},
"heredoc_to_nowdoc": false,
"Laravel/laravel_phpdoc_alignment": false
}
}
22 changes: 11 additions & 11 deletions src/ExtendsMediaAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ abstract public function registerAllMediaConversions(Media $media = null): void;

/**
* @param string $collectionName
*
* @return string
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaCaption(string $collectionName): string
Expand Down Expand Up @@ -52,8 +52,8 @@ protected function checkIfMediaCollectionExist(string $collectionName): void

/**
* @param string $collectionName
*
* @return string
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaDimensionsCaption(string $collectionName): string
Expand All @@ -74,8 +74,8 @@ public function getMediaDimensionsCaption(string $collectionName): string

/**
* @param string $collectionName
*
* @return array
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
protected function getMediaMaxDimensions(string $collectionName): array
Expand All @@ -99,8 +99,8 @@ protected function getMediaMaxDimensions(string $collectionName): array

/**
* @param string $collectionName
*
* @return bool
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
protected function mediaHasDimensions(string $collectionName): bool
Expand All @@ -113,14 +113,14 @@ protected function mediaHasDimensions(string $collectionName): bool

return ! count(array_filter(
$mediaCollection->acceptsMimeTypes,
static fn($mimeTypes) => ! Str::startsWith($mimeTypes, 'image')
static fn ($mimeTypes) => ! Str::startsWith($mimeTypes, 'image')
));
}

/**
* @param string $collectionName
*
* @return \Spatie\MediaLibrary\MediaCollections\MediaCollection
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
protected function getMediaCollectionOrFail(string $collectionName = 'default'): MediaCollection
Expand Down Expand Up @@ -152,8 +152,8 @@ protected function getMaxWidthAndMaxHeight(array $sizes): array

/**
* @param string $collectionName
*
* @return string
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaMimeTypesCaption(string $collectionName): string
Expand Down Expand Up @@ -198,8 +198,8 @@ public function getMediaSizeCaption(): string

/**
* @param string $collectionName
*
* @return array
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaValidationRules(string $collectionName): array
Expand All @@ -220,8 +220,8 @@ public function getMediaValidationRules(string $collectionName): array

/**
* @param string $collectionName
*
* @return string
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaMimesValidationRules(string $collectionName): string
Expand All @@ -240,8 +240,8 @@ public function getMediaMimesValidationRules(string $collectionName): string

/**
* @param string $collectionName
*
* @return string
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaMimeTypesValidationRules(string $collectionName): string
Expand All @@ -261,8 +261,8 @@ public function getMediaMimeTypesValidationRules(string $collectionName): string

/**
* @param string $collectionName
*
* @return string
*
* @throws \Okipa\MediaLibraryExt\Exceptions\CollectionNotFound
*/
public function getMediaDimensionValidationRules(string $collectionName): string
Expand Down
42 changes: 23 additions & 19 deletions tests/Unit/Captions/CollectionCaptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Okipa\MediaLibraryExt\Tests\Unit\Captions;

use Okipa\MediaLibraryExt\Exceptions\CollectionNotFound;
use Okipa\MediaLibraryExt\Tests\TestCase;
use Okipa\MediaLibraryExt\Tests\Models\InteractsWithMediaModel;
use Okipa\MediaLibraryExt\Tests\TestCase;
use Spatie\Image\Manipulations;
use Spatie\MediaLibrary\MediaCollections\Models\Media;

Expand All @@ -31,7 +31,8 @@ public function it_returns_only_size_when_with_no_conversions(): void
public function it_can_returns_dimensions_and_types_captions(): void
{
config()->set('media-library.max_file_size', null);
$testModel = new class extends InteractsWithMediaModel {
$testModel = new class extends InteractsWithMediaModel
{
public function registerMediaCollections(): void
{
$this->addMediaCollection('avatar')
Expand Down Expand Up @@ -64,27 +65,29 @@ public function registerMediaConversions(Media $media = null): void
public function it_can_returns_dimensions_and_size_captions(): void
{
config()->set('media-library.max_file_size', 1000000);
$testModel = new class extends InteractsWithMediaModel {
$testModel = new class extends InteractsWithMediaModel
{
public function registerMediaConversions(Media $media = null): void
{
$this->addMediaConversion('card')->crop(Manipulations::CROP_CENTER, 100, 70);
}
};
$captionString = $testModel->getMediaCaption('avatar');
self::assertEquals(__('Min. width: :width px.', [
'width' => 100,
]) . ' ' . __('Min. height: :height px.', [
'height' => 70,
]) . ' ' . __('Max. file size: :size Mb.', [
'size' => 1,
]), $captionString);
'width' => 100,
]) . ' ' . __('Min. height: :height px.', [
'height' => 70,
]) . ' ' . __('Max. file size: :size Mb.', [
'size' => 1,
]), $captionString);
}

/** @test */
public function it_can_returns_types_and_size_captions(): void
{
config()->set('media-library.max_file_size', 1000000);
$testModel = new class extends InteractsWithMediaModel {
$testModel = new class extends InteractsWithMediaModel
{
public function registerMediaCollections(): void
{
$this->addMediaCollection('avatar')->acceptsMimeTypes(['image/jpeg', 'image/png']);
Expand All @@ -95,18 +98,19 @@ public function registerMediaCollections(): void
'{1}Accepted type: :types.|[2,*]Accepted types: :types.',
2,
[
'types' => 'jpg, jpeg, jpe, png',
]
'types' => 'jpg, jpeg, jpe, png',
]
) . ' ' . __('Max. file size: :size Mb.', [
'size' => 1,
]), $captionString);
'size' => 1,
]), $captionString);
}

/** @test */
public function it_can_return_all_captions(): void
{
config()->set('media-library.max_file_size', 1000000);
$testModel = new class extends InteractsWithMediaModel {
$testModel = new class extends InteractsWithMediaModel
{
public function registerMediaCollections(): void
{
$this->addMediaCollection('avatar')->acceptsMimeTypes(['image/jpeg', 'image/png']);
Expand All @@ -119,10 +123,10 @@ public function registerMediaConversions(Media $media = null): void
};
$captionString = $testModel->getMediaCaption('avatar');
self::assertEquals(__('Min. width: :width px.', [
'width' => 100,
]) . ' ' . __('Min. height: :height px.', [
'height' => 70,
]) . ' ' . trans_choice(
'width' => 100,
]) . ' ' . __('Min. height: :height px.', [
'height' => 70,
]) . ' ' . trans_choice(
'{1}Accepted type: :types.|[2,*]Accepted types: :types.',
2,
[
Expand Down
Loading

0 comments on commit b92ecd6

Please sign in to comment.