Skip to content

Commit

Permalink
Merge branch 'master' into coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria authored Jan 19, 2025
2 parents 7f32aaa + a836c2d commit f45b16d
Show file tree
Hide file tree
Showing 35 changed files with 211 additions and 184 deletions.
72 changes: 72 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# This is a comment.
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in
# the repo. Unless a later match takes precedence,
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.

# Default owner for everything in the repo are members of the reviewers team.

* @LycheeOrg/reviewers

# Comments bellow are kept for reference

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
# modifies JS files, only @js-owner and not the global
# owner(s) will be requested for a review.
# *.js @js-owner #This is an inline comment.

# You can also use email addresses if you prefer. They'll be
# used to look up users just like we do for commit author
# emails.
# *.go [email protected]

# Teams can be specified as code owners as well. Teams should
# be identified in the format @org/team-name. Teams must have
# explicit write access to the repository. In this example,
# the octocats team in the octo-org organization owns all .txt files.
# *.txt @octo-org/octocats

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
# /build/logs/ @doctocat

# The `docs/*` pattern will match files like
# `docs/getting-started.md` but not further nested files like
# `docs/build-app/troubleshooting.md`.
# docs/* [email protected]

# In this example, @octocat owns any file in an apps directory
# anywhere in your repository.
# apps/ @octocat

# In this example, @doctocat owns any file in the `/docs`
# directory in the root of your repository and any of its
# subdirectories.
# /docs/ @doctocat

# In this example, any change inside the `/scripts` directory
# will require approval from @doctocat or @octocat.
# /scripts/ @doctocat @octocat

# In this example, @octocat owns any file in a `/logs` directory such as
# `/build/logs`, `/scripts/logs`, and `/deeply/nested/logs`. Any changes
# in a `/logs` directory will require approval from @octocat.
# **/logs @octocat

# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as its owners are left empty. Without an owner, changes
# to `apps/github` can be made with the approval of any user who has
# write access to the repository.
# /apps/ @octocat
# /apps/github

# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as this subdirectory has its own owner @doctocat
# /apps/ @octocat
# /apps/github @doctocat
45 changes: 0 additions & 45 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ parameters:
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::where(Not)?(Null|In|Between|Exists|Column|Year|Month|Day)?\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::delete\(\)#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::without\(\)#'
# - '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::with\(\)#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::count\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::update\(\).#'
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::inRandomOrder\(\).#'
Expand All @@ -50,18 +49,9 @@ parameters:
- '#Dynamic call to static method (Illuminate\\Database\\Query\\Builder|Illuminate\\Database\\Eloquent\\(Builder|Relations\\.*)|App\\Models\\Builders\\.*|App\\Eloquent\\FixedQueryBuilder|App\\Relations\\.*)(<.*>)?::exists\(\).#'
- '#Dynamic call to static method App\\Models\\Builders\\.*::orderByDesc\(\).#'
- '#Dynamic call to static method App\\Models\\Builders\\.*::selectRaw\(\).#'
# - '#Call to an undefined method Illuminate\\Database\\Eloquent\\.*::with(Only)?\(\)#'
# - '#Call to an undefined method App\\Relations\\HasManyPhotosRecursively::whereNotNull\(\)#'
# - '#Call to an undefined method Illuminate\\Database\\Eloquent\\Builder|Illuminate\\Database\\Eloquent\\Relations\\Relation::whereNotNull\(\).#'
- '#Call to protected method asDateTime\(\) of class Illuminate\\Database\\Eloquent\\Model.#'

# Covariance - LSP princinple: https://en.wikipedia.org/wiki/Liskov_substitution_principle
# -
# message: '#Parameter \#1 \$column \(array<string>\|Closure\|Illuminate\\Database\\Query\\Expression\|string\) of method .* should be contravariant with parameter \$column \(array<int\|string, mixed>\|\(Closure.*\)\|\(Closure.*\)\|Illuminate\\Contracts\\Database\\Query\\Expression\|string\) of method .*#'
# paths:
# - app/Eloquent/FixedQueryBuilderTrait.php
# - '#Parameter \#1 \$models .* of method .*::initRelation\(\) should be contravariant with parameter \$models .* of method .*::initRelation\(\)#'
# - '#Parameter \#(1|2) \$(models|albums|photos|results) .* of method .*::(match|addEagerConstraints)\(\) should be contravariant with parameter \$(models|albums|photos|results) .* of method .*::(match|addEagerConstraints)\(\)#'
- '#Parameter .* of method .*::replicate\(\) should be contravariant with parameter .* of method .*::replicate\(\)#'
- '#Parameter .* of method .*::save\(\) should be contravariant with parameter .* of method .*::save\(\)#'
- '#Parameter .* of method .*::newEloquentBuilder\(\) should be contravariant with parameter .* of method Kalnoy\\Nestedset\\Node<.*>::newEloquentBuilder\(\)#'
Expand All @@ -75,23 +65,9 @@ parameters:
- '#Dynamic call to static method Illuminate\\Foundation\\Application::getCachedConfigPath\(\).#'
- '#Dynamic call to static method Illuminate\\Foundation\\Application::getCachedRoutesPath\(\).#'


# - '#Access to an undefined property Laragear\\WebAuthn\\Models\\WebAuthnCredential::\$authenticatable_id#'

# False positive as stub code for PHP has not yet been updated to 2nd parameter, see https://github.com/php/doc-en/issues/1529 and https://www.php.net/imagick.writeimagefile
# - '#Method Imagick::writeImageFile\(\) invoked with 2 parameters, 1 required#'

# Synth
# -
# message: '#Variable property access on .*#'
# paths:
# - app/Livewire/Synth

# -
# message: '#Parameter .* of method App\\Livewire\\Synth\\.* should be contravariant with parameter .* of method Livewire\\Mechanisms\\HandleComponents\\Synthesizers\\Synth::.*#'
# paths:
# - app/Livewire/Synth

# Migrations
-
message: '#Function define is unsafe to use.#'
Expand All @@ -117,26 +93,6 @@ parameters:
message: '#no value type specified in iterable type array.#'
paths:
- tests
# -
# message: '#Dynamic call to static method Illuminate\\Testing\\TestResponse::assert(Forbidden|ViewIs|Unauthorized|Ok|Status)#'
# paths:
# - tests
# -
# message: '#Call to an undefined method Illuminate\\Testing\\TestResponse::(assert)?(SeeLivewire|dispatch|call|Set|Count)#'
# paths:
# - tests
-
message: '#Dynamic call to static method PHPUnit\\Framework\\Assert::assert(Is)?(Not)?(True|False|Equals|Int|Null|Empty|Count)\(\)#'
paths:
- tests
-
message: '#Dynamic call to static method PHPUnit\\Framework\\Assert::assertFile(DoesNot)?Exists?\(\)#'
paths:
- tests
-
message: '#Dynamic call to static method PHPUnit\\Framework\\Assert::assertString(Not)?(Contains|Ends|Starts)(String|With)\(\)#'
paths:
- tests
-
message: '#Dynamic call to static method Symfony\\Component\\HttpFoundation\\Response::get(Content|StatusCode)\(\)#'
paths:
Expand All @@ -149,7 +105,6 @@ parameters:
message: '#Cannot call method .* on Illuminate\\Testing\\PendingCommand\|int.#'
paths:
- tests

-
message: '#Access to private property App\\Models\\Extensions\\SizeVariants::\$(original|small(2x)?|thumb(2x)?|medium(2x)?|placeholder)#'
paths:
Expand Down
2 changes: 1 addition & 1 deletion scripts/delete_legacy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ rm -fr routes/web-admin-v1.php
sed -i "\#^.*login_required_v1#d" ./app/Http/Kernel.php

sed -i '11d;50,56d;60,64d;68,75d' ./app/Providers/RouteServiceProvider.php
sed -i '42d;54d;55d;79d;84,94d;132,135d;136,139d;148,152d;153,156d' phpstan.neon
sed -i '104,111d' phpstan.neon


12 changes: 6 additions & 6 deletions tests/Feature_v1/AlbumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -785,15 +785,15 @@ public function testSetCoverByOwner()

$this->albums_tests->set_cover($albumID, $photoID1);
$coverID = $this->albums_tests->get($albumID)->offsetGet('cover_id');
$this->assertEquals($photoID1, $coverID);
self::assertEquals($photoID1, $coverID);

$this->albums_tests->set_cover($albumID, $photoID2);
$coverID = $this->albums_tests->get($albumID)->offsetGet('cover_id');
$this->assertEquals($photoID2, $coverID);
self::assertEquals($photoID2, $coverID);

$this->albums_tests->set_cover($albumID, null);
$coverID = $this->albums_tests->get($albumID)->offsetGet('cover_id');
$this->assertEquals($initialCoverID, $coverID);
self::assertEquals($initialCoverID, $coverID);

Auth::logout();
Session::flush();
Expand Down Expand Up @@ -847,15 +847,15 @@ public function testSetHeaderByOwner()

$this->albums_tests->set_header($albumID, $photoID1);
$headerID = $this->albums_tests->get($albumID)->offsetGet('header_id');
$this->assertEquals($photoID1, $headerID);
self::assertEquals($photoID1, $headerID);

$this->albums_tests->set_header($albumID, $photoID2);
$headerID = $this->albums_tests->get($albumID)->offsetGet('header_id');
$this->assertEquals($photoID2, $headerID);
self::assertEquals($photoID2, $headerID);

$this->albums_tests->set_header($albumID, null);
$headerID = $this->albums_tests->get($albumID)->offsetGet('header_id');
$this->assertEquals($initialHeaderID, $headerID);
self::assertEquals($initialHeaderID, $headerID);

Auth::logout();
Session::flush();
Expand Down
32 changes: 16 additions & 16 deletions tests/Feature_v1/BasePhotosAddHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function testPNGUpload(): void
$photo = static::convertJsonToObject($this->photos_tests->upload(
AbstractTestCase::createUploadedFile(TestConstants::SAMPLE_FILE_PNG)
));
$this->assertStringEndsWith('.png', $photo->size_variants->original->url);
self::assertStringEndsWith('.png', $photo->size_variants->original->url);
}

public function testGIFUpload(): void
Expand All @@ -250,7 +250,7 @@ public function testGIFUpload(): void
$photo = static::convertJsonToObject($this->photos_tests->upload(
AbstractTestCase::createUploadedFile(TestConstants::SAMPLE_FILE_GIF)
));
$this->assertStringEndsWith('.gif', $photo->size_variants->original->url);
self::assertStringEndsWith('.gif', $photo->size_variants->original->url);
}

public function testWEBPUpload(): void
Expand All @@ -259,7 +259,7 @@ public function testWEBPUpload(): void
$photo = static::convertJsonToObject($this->photos_tests->upload(
AbstractTestCase::createUploadedFile(TestConstants::SAMPLE_FILE_WEBP)
));
$this->assertStringEndsWith('.webp', $photo->size_variants->original->url);
self::assertStringEndsWith('.webp', $photo->size_variants->original->url);
}

/**
Expand All @@ -281,11 +281,11 @@ public function testAppleLivePhotoUpload1(): void
null,
[200, 201]
));
$this->assertEquals($photo->id, $video->id);
$this->assertEquals('E905E6C6-C747-4805-942F-9904A0281F02', $video->live_photo_content_id);
$this->assertStringEndsWith('.mov', $video->live_photo_url);
$this->assertEquals(pathinfo($video->live_photo_url, PATHINFO_DIRNAME), pathinfo($video->size_variants->original->url, PATHINFO_DIRNAME));
$this->assertEquals(pathinfo($video->live_photo_url, PATHINFO_FILENAME), pathinfo($video->size_variants->original->url, PATHINFO_FILENAME));
self::assertEquals($photo->id, $video->id);
self::assertEquals('E905E6C6-C747-4805-942F-9904A0281F02', $video->live_photo_content_id);
self::assertStringEndsWith('.mov', $video->live_photo_url);
self::assertEquals(pathinfo($video->live_photo_url, PATHINFO_DIRNAME), pathinfo($video->size_variants->original->url, PATHINFO_DIRNAME));
self::assertEquals(pathinfo($video->live_photo_url, PATHINFO_FILENAME), pathinfo($video->size_variants->original->url, PATHINFO_FILENAME));
}

/**
Expand All @@ -307,13 +307,13 @@ public function testAppleLivePhotoUpload2(): void
null,
[200, 201] // associated image to video.
));
$this->assertEquals('E905E6C6-C747-4805-942F-9904A0281F02', $photo->live_photo_content_id);
$this->assertStringEndsWith('.mov', $photo->live_photo_url);
$this->assertEquals(pathinfo($photo->live_photo_url, PATHINFO_DIRNAME), pathinfo($photo->size_variants->original->url, PATHINFO_DIRNAME));
$this->assertEquals(pathinfo($photo->live_photo_url, PATHINFO_FILENAME), pathinfo($photo->size_variants->original->url, PATHINFO_FILENAME));
self::assertEquals('E905E6C6-C747-4805-942F-9904A0281F02', $photo->live_photo_content_id);
self::assertStringEndsWith('.mov', $photo->live_photo_url);
self::assertEquals(pathinfo($photo->live_photo_url, PATHINFO_DIRNAME), pathinfo($photo->size_variants->original->url, PATHINFO_DIRNAME));
self::assertEquals(pathinfo($photo->live_photo_url, PATHINFO_FILENAME), pathinfo($photo->size_variants->original->url, PATHINFO_FILENAME));

// The initially uploaded video should have been deleted
$this->assertEquals(0, DB::table('photos')->where('id', '=', $video->id)->count());
self::assertEquals(0, DB::table('photos')->where('id', '=', $video->id)->count());
}

/**
Expand All @@ -331,9 +331,9 @@ public function testGoogleMotionPhotoUpload(): void
AbstractTestCase::createUploadedFile(TestConstants::SAMPLE_FILE_GMP_IMAGE)
));

$this->assertStringEndsWith('.mov', $photo->live_photo_url);
$this->assertEquals(pathinfo($photo->live_photo_url, PATHINFO_DIRNAME), pathinfo($photo->size_variants->original->url, PATHINFO_DIRNAME));
$this->assertEquals(pathinfo($photo->live_photo_url, PATHINFO_FILENAME), pathinfo($photo->size_variants->original->url, PATHINFO_FILENAME));
self::assertStringEndsWith('.mov', $photo->live_photo_url);
self::assertEquals(pathinfo($photo->live_photo_url, PATHINFO_DIRNAME), pathinfo($photo->size_variants->original->url, PATHINFO_DIRNAME));
self::assertEquals(pathinfo($photo->live_photo_url, PATHINFO_FILENAME), pathinfo($photo->size_variants->original->url, PATHINFO_FILENAME));
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/Feature_v1/CommandFixPermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ public function testFixPermissions(): void
$this->artisan(self::COMMAND, ['--dry-run' => 0])->assertSuccessful();

clearstatcache(true);
$this->assertEquals(00664, fileperms($filePath) & 07777);
$this->assertEquals(02775, fileperms($dirPath) & 07777);
self::assertEquals(00664, fileperms($filePath) & 07777);
self::assertEquals(02775, fileperms($dirPath) & 07777);

chmod($filePath, 00777);
chmod($dirPath, 06777);

$this->artisan(self::COMMAND, ['--dry-run' => 0])->assertSuccessful();

clearstatcache(true);
$this->assertEquals(00664, fileperms($filePath) & 07777);
$this->assertEquals(02775, fileperms($dirPath) & 07777);
self::assertEquals(00664, fileperms($filePath) & 07777);
self::assertEquals(02775, fileperms($dirPath) & 07777);
}
}
8 changes: 4 additions & 4 deletions tests/Feature_v1/CommandGenerateThumbsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ public function testThumbRecreation(): void
// Get updated photo and check if size variant has been re-created
/** @var \App\Models\Photo $photo2 */
$photo2 = static::convertJsonToObject($this->photos_tests->get($photo1->id));
$this->assertNotNull($photo2->size_variants->small);
$this->assertEquals($photo1->size_variants->small->width, $photo2->size_variants->small->width);
$this->assertEquals($photo1->size_variants->small->height, $photo2->size_variants->small->height);
$this->assertFileExists(public_path($this->dropUrlPrefix($photo2->size_variants->small->url)));
self::assertNotNull($photo2->size_variants->small);
self::assertEquals($photo1->size_variants->small->width, $photo2->size_variants->small->width);
self::assertEquals($photo1->size_variants->small->height, $photo2->size_variants->small->height);
self::assertFileExists(public_path($this->dropUrlPrefix($photo2->size_variants->small->url)));
}
}
14 changes: 7 additions & 7 deletions tests/Feature_v1/CommandGhostbusterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testRemoveOrphanedFiles(): void
$this->dropUrlPrefix($photo->size_variants->thumb2x?->url),
$this->dropUrlPrefix($photo->size_variants->thumb->url),
], [null]);
$this->assertNotEmpty($fileURLs);
self::assertNotEmpty($fileURLs);

// Remove photo and size variants from DB manually; note we must
// not use an API call as this would also remove the files, and we
Expand All @@ -58,7 +58,7 @@ public function testRemoveOrphanedFiles(): void

// Ensure that files are still there
foreach ($fileURLs as $fileURL) {
$this->assertFileExists(public_path($fileURL));
self::assertFileExists(public_path($fileURL));
}

// Ghostbuster, ...
Expand All @@ -69,7 +69,7 @@ public function testRemoveOrphanedFiles(): void

// Ensure that files are gone
foreach ($fileURLs as $fileURL) {
$this->assertFileDoesNotExist(public_path($fileURL));
self::assertFileDoesNotExist(public_path($fileURL));
}
}

Expand All @@ -93,7 +93,7 @@ public function testRemoveZombiePhotos(): void
$this->dropUrlPrefix($photo->size_variants->thumb2x?->url),
$this->dropUrlPrefix($photo->size_variants->thumb->url),
], [null]);
$this->assertNotEmpty($fileURLs);
self::assertNotEmpty($fileURLs);

// Remove original file
\Safe\unlink(public_path($this->dropUrlPrefix($originalFileURL)));
Expand All @@ -106,20 +106,20 @@ public function testRemoveZombiePhotos(): void
->assertSuccessful();

// Ensure that photo, size variants and all other size variants are gone
$this->assertEquals(
self::assertEquals(
0,
DB::table('photos')
->where('id', '=', $photo->id)
->count()
);
$this->assertEquals(
self::assertEquals(
0,
DB::table('size_variants')
->where('photo_id', '=', $photo->id)
->count()
);
foreach ($fileURLs as $fileURL) {
$this->assertFileDoesNotExist(public_path($fileURL));
self::assertFileDoesNotExist(public_path($fileURL));
}
}
}
2 changes: 1 addition & 1 deletion tests/Feature_v1/CommandTakeDateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@ public function testSetUploadTimeFromFileTime(): void
$file_time = \Safe\filemtime(public_path($this->dropUrlPrefix($photo->size_variants->original->url)));
$carbon = new Carbon($photo->created_at);

$this->assertEquals($file_time, $carbon->getTimestamp());
self::assertEquals($file_time, $carbon->getTimestamp());
}
}
8 changes: 4 additions & 4 deletions tests/Feature_v1/CommandVideoDataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ public function testThumbRecreation(): void
// Get updated video and check if thumb has been re-created
/** @var \App\Models\Photo $photo2 */
$photo2 = static::convertJsonToObject($this->photos_tests->get($photo1->id));
$this->assertNotNull($photo2->size_variants->thumb);
$this->assertEquals($photo1->size_variants->thumb->width, $photo2->size_variants->thumb->width);
$this->assertEquals($photo1->size_variants->thumb->height, $photo2->size_variants->thumb->height);
$this->assertFileExists(public_path($this->dropUrlPrefix($photo2->size_variants->thumb->url)));
self::assertNotNull($photo2->size_variants->thumb);
self::assertEquals($photo1->size_variants->thumb->width, $photo2->size_variants->thumb->width);
self::assertEquals($photo1->size_variants->thumb->height, $photo2->size_variants->thumb->height);
self::assertFileExists(public_path($this->dropUrlPrefix($photo2->size_variants->thumb->url)));
}
}
Loading

0 comments on commit f45b16d

Please sign in to comment.