Repository: LycheeOrg/Lychee
Pull request #3166: test: AddAlbumRequestTest
Author: login: ppshobi
Labels: name: Review: easy
description: Easy review expected: probably just need a quick to go through.
Created: 2025-03-28T00:02:17Z | Merged: 2025-04-10T15:52:54Z

Just some unit tests
<!--
Thank you for contributing to Lychee! We only accept PR to the master branch.

In addition, please describe the benefit to end users; the reasons it does not break any existing features, etc.

If you're pushing a Feature:
- Title it: "This new feature"
- Describe what the new feature enables
- Add tests to test the new feature.
- Ensure it doesn't break any existing features.

If you're pushing a Fix:
- Title it: "Fixes the bug name"
- If it is a fix an an existing issue start the description with `fixes #xxxx` where xxxx is the issue number.
- Describe how it fixes in a few words.
- Add a test that triggered the bug before fixing it.
- Ensure it doesn't break any feature.

All Pull Requests run with extensive tests for stable and latest versions of PHP. 
Ensure your tests pass or your PR may be taken down.

Additionally you can run `make phpstan` and `make formatting` on your own machine as they will be required to pass for your PR to be accepted.

Don't worry if your code styling isn't perfect! php-cs-fixer will automatically create a pull request with any style fixes. This allows us to focus on the content of the contribution and not the code style.
-->


Diff:
diff --git a/app/Http/Requests/Album/AddAlbumRequest.php b/app/Http/Requests/Album/AddAlbumRequest.php
index 23ea99b2b4c..ebc19499a4f 100644
--- a/app/Http/Requests/Album/AddAlbumRequest.php
+++ b/app/Http/Requests/Album/AddAlbumRequest.php
@@ -57,4 +57,4 @@ protected function processValidatedValues(array $values, array $files): void
 			Album::query()->findOrFail($parent_album_id);
 		$this->title = $values[RequestAttribute::TITLE_ATTRIBUTE];
 	}
-}
+}
\ No newline at end of file
diff --git a/app/Http/Requests/Album/MergeAlbumsRequest.php b/app/Http/Requests/Album/MergeAlbumsRequest.php
index 6c1d988df3f..6599107c0b7 100644
--- a/app/Http/Requests/Album/MergeAlbumsRequest.php
+++ b/app/Http/Requests/Album/MergeAlbumsRequest.php
@@ -18,6 +18,7 @@
 use App\Models\Album;
 use App\Rules\AlbumIDRule;
 use App\Rules\RandomIDRule;
+use Illuminate\Support\Collection;
 
 /**
  * @implements HasAlbums<Album>
@@ -29,6 +30,13 @@ class MergeAlbumsRequest extends BaseApiRequest implements HasAlbum, HasAlbums
 	use HasAlbumsTrait;
 	use AuthorizeCanEditAlbumAlbumsTrait;
 
+	public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
+	{
+		parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content);
+
+		$this->albums = new Collection(); // initialize with empty collection to avoid error MergeAlbumsRequest::$albums must not be accessed before initialization
+	}
+
 	/**
 	 * {@inheritDoc}
 	 */
@@ -55,4 +63,4 @@ protected function processValidatedValues(array $values, array $files): void
 			->with(['children'])
 			->findOrFail($ids);
 	}
-}
+}
\ No newline at end of file
diff --git a/tests/Unit/Http/Requests/Album/AddAlbumRequestTest.php b/tests/Unit/Http/Requests/Album/AddAlbumRequestTest.php
new file mode 100644
index 00000000000..a65e1270bc3
--- /dev/null
+++ b/tests/Unit/Http/Requests/Album/AddAlbumRequestTest.php
@@ -0,0 +1,57 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\AddAlbumRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\RandomIDRule;
+use App\Rules\TitleRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class AddAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
+	}
+
+	public function testAuthorization()
+	{
+		Gate::shouldReceive('check')
+			->with(AlbumPolicy::CAN_EDIT, [AbstractAlbum::class, null])
+			->andReturn(true);
+
+		$request = new AddAlbumRequest();
+		$request->merge([RequestAttribute::PARENT_ID_ATTRIBUTE => null]);
+
+		$this->assertTrue($request->authorize());
+	}
+
+	public function testRules(): void
+	{
+		$request = new AddAlbumRequest();
+
+		$rules = $request->rules();
+
+		$this->assertArrayHasKey(RequestAttribute::PARENT_ID_ATTRIBUTE, $rules);
+		$this->assertArrayHasKey(RequestAttribute::TITLE_ATTRIBUTE, $rules);
+
+		$this->assertEquals(['present', new RandomIDRule(true)], $rules[RequestAttribute::PARENT_ID_ATTRIBUTE]);
+		$this->assertEquals(['required', new TitleRule()], $rules[RequestAttribute::TITLE_ATTRIBUTE]);
+	}
+}
\ No newline at end of file
diff --git a/tests/Unit/Http/Requests/Album/AddTagAlbumRequestTest.php b/tests/Unit/Http/Requests/Album/AddTagAlbumRequestTest.php
new file mode 100644
index 00000000000..f567ff0bd95
--- /dev/null
+++ b/tests/Unit/Http/Requests/Album/AddTagAlbumRequestTest.php
@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\AddTagAlbumRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\TitleRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class AddTagAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
+	}
+
+	public function testAuthorization()
+	{
+		Gate::shouldReceive('check')
+			->with(AlbumPolicy::CAN_EDIT, [AbstractAlbum::class, null])
+			->andReturn(true);
+
+		$request = new AddTagAlbumRequest();
+		$request->merge([RequestAttribute::PARENT_ID_ATTRIBUTE => null]);
+
+		$this->assertTrue($request->authorize());
+	}
+
+	public function testRules(): void
+	{
+		$request = new AddTagAlbumRequest();
+
+		$rules = $request->rules();
+
+		$this->assertArrayHasKey(RequestAttribute::TITLE_ATTRIBUTE, $rules);
+		$this->assertArrayHasKey(RequestAttribute::TAGS_ATTRIBUTE, $rules);
+		$this->assertArrayHasKey(RequestAttribute::TAGS_ATTRIBUTE . '.*', $rules);
+
+		$this->assertEquals(['required', new TitleRule()], $rules[RequestAttribute::TITLE_ATTRIBUTE]);
+		$this->assertEquals('required|array|min:1', $rules[RequestAttribute::TAGS_ATTRIBUTE]);
+		$this->assertEquals('required|string|min:1', $rules[RequestAttribute::TAGS_ATTRIBUTE . '.*']);
+	}
+}
\ No newline at end of file
diff --git a/tests/Unit/Http/Requests/Album/DeleteAlbumsRequestTest.php b/tests/Unit/Http/Requests/Album/DeleteAlbumsRequestTest.php
new file mode 100644
index 00000000000..b8a7713247e
--- /dev/null
+++ b/tests/Unit/Http/Requests/Album/DeleteAlbumsRequestTest.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\DeleteAlbumsRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\AlbumIDRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class DeleteAlbumsRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
+	}
+
+	public function testAuthorization()
+	{
+		Gate::shouldReceive('check')
+			->with(AlbumPolicy::CAN_DELETE_ID, [AbstractAlbum::class, null])
+			->andReturn(true);
+
+		$request = new DeleteAlbumsRequest();
+		$request->merge([RequestAttribute::PARENT_ID_ATTRIBUTE => null]);
+
+		$this->assertTrue($request->authorize());
+	}
+
+	public function testRules(): void
+	{
+		$request = new DeleteAlbumsRequest();
+
+		$rules = $request->rules();
+
+		$expectedRuleMap = [
+			RequestAttribute::ALBUM_IDS_ATTRIBUTE => 'required|array|min:1',
+			RequestAttribute::ALBUM_IDS_ATTRIBUTE . '.*' => ['required', new AlbumIDRule(false)],
+		];
+
+		$this->assertCount(count($expectedRuleMap), $rules);
+
+		foreach ($expectedRuleMap as $key => $value) {
+			$this->assertEquals($value, $rules[$key]);
+		}
+	}
+}
\ No newline at end of file
diff --git a/tests/Unit/Http/Requests/Album/DeleteTrackRequestTest.php b/tests/Unit/Http/Requests/Album/DeleteTrackRequestTest.php
new file mode 100644
index 00000000000..e8c637bb408
--- /dev/null
+++ b/tests/Unit/Http/Requests/Album/DeleteTrackRequestTest.php
@@ -0,0 +1,60 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\DeleteTrackRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\AlbumIDRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class DeleteTrackRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
+	}
+
+	public function testAuthorization()
+	{
+		Gate::shouldReceive('check')
+			->with(AlbumPolicy::CAN_EDIT, [AbstractAlbum::class, null])
+			->andReturn(true);
+
+		$request = new DeleteTrackRequest();
+		$request->merge([RequestAttribute::PARENT_ID_ATTRIBUTE => null]);
+
+		$this->assertTrue($request->authorize());
+	}
+
+	public function testRules(): void
+	{
+		$request = new DeleteTrackRequest();
+
+		$rules = $request->rules();
+
+		$expectedRuleMap = [
+			RequestAttribute::ALBUM_ID_ATTRIBUTE => ['required', new AlbumIDRule(false)],
+		];
+
+		$this->assertCount(count($expectedRuleMap), $rules);
+
+		foreach ($expectedRuleMap as $key => $value) {
+			$this->assertEquals($value, $rules[$key]);
+		}
+	}
+}
\ No newline at end of file
diff --git a/tests/Unit/Http/Requests/Album/GetAlbumRequestTest.php b/tests/Unit/Http/Requests/Album/GetAlbumRequestTest.php
new file mode 100644
index 00000000000..58e6c6dd4bc
--- /dev/null
+++ b/tests/Unit/Http/Requests/Album/GetAlbumRequestTest.php
@@ -0,0 +1,61 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\DeleteTrackRequest;
+use App\Http\Requests\Album\GetAlbumRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\AlbumIDRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class GetAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
+	}
+
+	public function testAuthorization()
+	{
+		Gate::shouldReceive('check')
+			->with(AlbumPolicy::CAN_ACCESS, [AbstractAlbum::class, null])
+			->andReturn(true);
+
+		$request = new GetAlbumRequest();
+		$request->merge([RequestAttribute::PARENT_ID_ATTRIBUTE => null]);
+
+		$this->assertTrue($request->authorize());
+	}
+
+	public function testRules(): void
+	{
+		$request = new DeleteTrackRequest();
+
+		$rules = $request->rules();
+
+		$expectedRuleMap = [
+			RequestAttribute::ALBUM_ID_ATTRIBUTE => ['required', new AlbumIDRule(false)],
+		];
+
+		$this->assertCount(count($expectedRuleMap), $rules);
+
+		foreach ($expectedRuleMap as $key => $value) {
+			$this->assertEquals($value, $rules[$key]);
+		}
+	}
+}
\ No newline at end of file
diff --git a/tests/Unit/Http/Requests/Album/MergeAlbumRequestTest.php b/tests/Unit/Http/Requests/Album/MergeAlbumRequestTest.php
new file mode 100644
index 00000000000..1ba3b864d8a
--- /dev/null
+++ b/tests/Unit/Http/Requests/Album/MergeAlbumRequestTest.php
@@ -0,0 +1,62 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\MergeAlbumsRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\AlbumIDRule;
+use App\Rules\RandomIDRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class MergeAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
+	}
+
+	public function testAuthorization()
+	{
+		Gate::shouldReceive('check')
+			->with(AlbumPolicy::CAN_EDIT, [AbstractAlbum::class, null])
+			->andReturn(true);
+
+		$request = new MergeAlbumsRequest();
+		$request->merge([RequestAttribute::PARENT_ID_ATTRIBUTE => null]);
+
+		$this->assertTrue($request->authorize());
+	}
+
+	public function testRules(): void
+	{
+		$request = new MergeAlbumsRequest();
+
+		$rules = $request->rules();
+
+		$expectedRuleMap = [
+			RequestAttribute::ALBUM_ID_ATTRIBUTE => ['required', new RandomIDRule(false)],
+			RequestAttribute::ALBUM_IDS_ATTRIBUTE => 'required|array|min:1',
+			RequestAttribute::ALBUM_IDS_ATTRIBUTE . '.*' => ['required', new AlbumIDRule(false)],		];
+
+		$this->assertCount(count($expectedRuleMap), $rules);
+
+		foreach ($expectedRuleMap as $key => $value) {
+			$this->assertEquals($value, $rules[$key]);
+		}
+	}
+}
\ No newline at end of file


Reviews:
user: login: ppshobi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-03-28T00:03:30Z
user: login: ildyria
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-05T08:44:57Z
user: login: ildyria
state: COMMENTED
author_association: MEMBER
submitted_at: 2025-04-09T18:50:19Z
user: login: ppshobi
state: COMMENTED
author_association: CONTRIBUTOR
submitted_at: 2025-04-09T21:09:18Z
user: login: ildyria
state: APPROVED
author_association: MEMBER
submitted_at: 2025-04-10T15:52:47Z

Review comments:
diff_hunk: @@ -29,6 +30,13 @@ class MergeAlbumsRequest extends BaseApiRequest implements HasAlbum, HasAlbums
 	use HasAlbumsTrait;
 	use AuthorizeCanEditAlbumAlbumsTrait;
 
+	public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
+	{
+		parent::__construct($query, $request, $attributes, $cookies, $files, $server, $content);
+
+		$this->albums = new Collection(); // initialize with empty collection to avoid error MergeAlbumsRequest::$albums must not be accessed before initialization
path: app/Http/Requests/Album/MergeAlbumsRequest.php
user: login: ppshobi
body: I'm not sure if i am doing this correctly, I was getting an error 
> MergeAlbumsRequest::$albums must not be accessed before initialization

when i comment this line and run MerglbRequestTest
created_at: 2025-03-28T00:03:30Z
author_association: CONTRIBUTOR
diff_hunk: @@ -0,0 +1,57 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\AddAlbumRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\RandomIDRule;
+use App\Rules\TitleRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class AddAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
path: tests/Unit/Http/Requests/Album/AddAlbumRequestTest.php
user: login: ildyria
body: > that is not needed for Request classes

What do you mean ? :)
created_at: 2025-04-05T08:44:57Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,57 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\AddAlbumRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\RandomIDRule;
+use App\Rules\TitleRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class AddAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
path: tests/Unit/Http/Requests/Album/AddAlbumRequestTest.php
user: login: ildyria
body: @ppshobi  ? :)
created_at: 2025-04-09T18:50:19Z
author_association: MEMBER
diff_hunk: @@ -0,0 +1,57 @@
+<?php
+
+/**
+ * SPDX-License-Identifier: MIT
+ * Copyright (c) 2017-2018 Tobias Reich
+ * Copyright (c) 2018-2025 LycheeOrg.
+ */
+
+declare(strict_types=1);
+
+namespace Tests\Unit\Http\Requests\Album;
+
+use App\Contracts\Http\Requests\RequestAttribute;
+use App\Contracts\Models\AbstractAlbum;
+use App\Http\Requests\Album\AddAlbumRequest;
+use App\Policies\AlbumPolicy;
+use App\Rules\RandomIDRule;
+use App\Rules\TitleRule;
+use Illuminate\Support\Facades\App;
+use Illuminate\Support\Facades\Gate;
+use LycheeVerify\Contract\VerifyInterface;
+use Tests\AbstractTestCase;
+
+class AddAlbumRequestTest extends AbstractTestCase
+{
+	protected function setUp(): void
+	{
+		parent::setUp();
+		$mockVerify = $this->createMock(VerifyInterface::class);
+		App::instance(VerifyInterface::class, $mockVerify); // VerifyInterface is talking to DB & that is not needed for Request classes
path: tests/Unit/Http/Requests/Album/AddAlbumRequestTest.php
user: login: ppshobi
body: was with some work, what I mean here is that these tests are unit tests. (which should only test that particualr class). Request classes like `AddalbumRequest` those are  small and only need to be tested on the functionalities that they actually contain. but becauase of the class hierarchy, those classes have the following parent
```php
abstract class BaseApiRequest extends FormRequest
{
	protected readonly VerifyInterface $verify;

	/**
	 * @throws FrameworkException
	 */
	public function __construct(
	....
	) {
	....
			$this->verify = resolve(Verify::class); // now this resolve() makes it hard to test because this object can't be passed from outside
    }
...
```

while the `resolve(Verify::class)` is looking in the container and trying to get it. its getting the class `Verify implements VerifyInterface` from LycheeVerify package

in that class the constructor talks to the database to fetch some config values
```php
public function __construct(
		....
       ....
	) {
		$this->config_email = $config_email ?? DB::table('configs')->where('key', 'email')->first()?->value ?? ''; // @phpstan-ignore-line
		$this->license_key = $license_key ?? DB::table('configs')->where('key', 'license_key')->first()?->value ?? ''; // @phpstan-ignore-line
		$this->validateSignature = new ValidateSignature($public_key);
		$this->validateHash = new ValidateHash($hash);
	}
```

makes complete sense for an integration test, but for a unit test connecting to database is not needed, Hence I mock the `Verify` class and repalce it in the container for the unit test. 

so I can test only the `AddAlbumRequest` class. 

these tests not only helps for increasing the coverage rather makes sure [something like this does not happen](https://github.com/LycheeOrg/Lychee/pull/3167/files#r2027509753) when we do a whole project level refactoring. 

created_at: 2025-04-09T21:09:18Z
author_association: CONTRIBUTOR

PR comments:
user: login: codecov[bot]
created_at: 2025-04-03T19:09:27Z
body: ## [Codecov](https://app.codecov.io/gh/LycheeOrg/Lychee/pull/3166?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LycheeOrg) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 90.83%. Comparing base [(`8ccaf03`)](https://app.codecov.io/gh/LycheeOrg/Lychee/commit/8ccaf032888ea46889ec4a4f39e7c35e7edf54b8?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LycheeOrg) to head [(`89d0578`)](https://app.codecov.io/gh/LycheeOrg/Lychee/commit/89d057839ba197c92c1b1a987351729e331b53ae?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=LycheeOrg).
> Report is 16 commits behind head on master.

<details><summary> :rocket: New features to boost your workflow: </summary>

- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
author_association: NONE
user: login: ildyria
created_at: 2025-04-04T14:49:33Z
body: It took me a bit of time to understand why you wanted those.
![image](https://github.com/user-attachments/assets/2d91352e-f648-49ae-b304-d59dabfec1b7)
Looking at the coverage I understand better.

However this is not the best way to do it.
It is way more interesting to directly make "queries" in Feature_v2.
The reason being that you are able to also at the same time cover the missing functions here:
https://app.codecov.io/gh/LycheeOrg/Lychee/blob/master/app%2FHttp%2FControllers%2FGallery%2FAlbumController.php
And the associated actions (which are currently only green because we still test with Legacy endpoints).

author_association: MEMBER