Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump actions/checkout from 2 to 3 #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

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

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

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

Expand Down
9 changes: 6 additions & 3 deletions src/Models/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ public function getUrlAttribute(): string
if ($this->useProxy()) {
return $this->proxy_url;
}

return Storage::disk($this->disk)->url($this->filepath);
}

Expand All @@ -364,6 +365,7 @@ public function getUrlInlineAttribute(): string
if ($this->useProxy()) {
return $this->proxy_url_inline;
}

return Storage::disk($this->disk)->url($this->filepath);
}

Expand Down Expand Up @@ -661,6 +663,7 @@ protected function isDirectoryEmpty(?string $dir): ?bool
}

$files = $this->storageCommand('allFiles', $dir);

return (is_countable($files) ? count($files) : 0) === 0;
}

Expand Down Expand Up @@ -826,8 +829,8 @@ private static function str_base_convert($str, $fromBase = 10, $toBase = 36)
*/
protected function checkPath($destinationPath): bool
{
return !FileHelper::isDirectory($destinationPath) &&
!FileHelper::makeDirectory($destinationPath, 0777, true, true) &&
!FileHelper::isDirectory($destinationPath);
return ! FileHelper::isDirectory($destinationPath) &&
! FileHelper::makeDirectory($destinationPath, 0777, true, true) &&
! FileHelper::isDirectory($destinationPath);
}
}
5 changes: 2 additions & 3 deletions tests/PictureTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php


namespace Cruxinator\Attachments\Tests;

use Cruxinator\Attachments\Models\Picture;
Expand Down Expand Up @@ -35,7 +34,7 @@ public function testLuminance()
$file = str_replace('/', DIRECTORY_SEPARATOR, $file);
$main = File::get($file);
File::shouldReceive('get')->andReturn($main);

$att = new Picture();
$att->disk = 'local';
$att->filepath = '';
Expand All @@ -45,7 +44,7 @@ public function testLuminance()
$att->attachable_type = '';
$att->attachable_id = 0;
$this->assertTrue($att->save());

$expected = 127;
$actual = $att->luminance;
$this->assertEquals($expected, $actual, 'Unexpected luminance result');
Expand Down
16 changes: 7 additions & 9 deletions tests/ResizablePictureTest.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?php


namespace Cruxinator\Attachments\Tests;

use Cruxinator\Attachments\Models\ResizablePicture;
use Cruxinator\Attachments\Models\Picture;
use Cruxinator\Attachments\Models\ResizablePicture;
use Cruxinator\Attachments\Tests\Fixtures\User;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\File;
Expand Down Expand Up @@ -43,11 +42,11 @@ public function testKeyAttachment()
$actual = ResizablePicture::keyAttachment($foo, $key);
$this->assertEquals($att->getKey(), $actual->getKey());
}

public function testOfProfileGoodSize()
{
$sizes = [
'sample' => ['width' => 360, 'height' => 360, 'invert' => 0, 'aspect' => 1, 'rotate' => -1]
'sample' => ['width' => 360, 'height' => 360, 'invert' => 0, 'aspect' => 1, 'rotate' => -1],
];

config(['attachments.image.sizes' => $sizes]);
Expand All @@ -71,15 +70,15 @@ public function testOfProfileGoodSize()
$att->attachable_type = '';
$att->attachable_id = 0;
$this->assertTrue($att->save());

$trim = $att->ofProfile('sample');
$this->assertTrue($trim instanceof Picture);
$this->assertFalse($trim instanceof ResizablePicture);
$this->assertEquals('lain-cyberia-mix.png', $trim->filename);
$this->assertEquals(30720, $trim->filesize);
$this->assertEquals('image/png', $trim->filetype);
$this->assertEquals('360x360___0_1', $trim->key);

// check original subordinate attachment is recycled
$newTrim = $att->ofProfile('sample');
$this->assertTrue($newTrim instanceof Picture);
Expand Down Expand Up @@ -123,12 +122,12 @@ public function testOfProfileEmptySize()
$this->assertFalse($newTrim instanceof ResizablePicture);
$this->assertEquals($trim->getKey(), $newTrim->getKey(), 'Existing attachment not recycled on second call');
}

public function testOfProfileBadSize()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('An Attempt to load profile didn\'t yield a valid sizes array. received data');

$att = new ResizablePicture();
$att->disk = 'local';
$att->filepath = '';
Expand All @@ -142,4 +141,3 @@ public function testOfProfileBadSize()
$trim = $att->ofProfile('sample');
}
}