-
-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
280 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
|
||
namespace Tests\Feature_v2\Album; | ||
|
||
use Tests\Feature_v2\Base\BaseApiV2Test; | ||
|
||
class AlbumListTest extends BaseApiV2Test | ||
{ | ||
public function testListTargetAlbumUnauthorizedForbidden(): void | ||
{ | ||
$response = $this->getJson('Album::getTargetListAlbums?album_id=' . $this->album1->id); | ||
$this->assertUnauthorized($response); | ||
|
||
$response = $this->actingAs($this->userLocked)->getJson('Album::getTargetListAlbums?album_id=' . $this->album1->id); | ||
$this->assertForbidden($response); | ||
} | ||
|
||
public function testListTargetAlbumAuthorizedOwner(): void | ||
{ | ||
$response = $this->actingAs($this->admin)->getJson('Album::getTargetListAlbums?album_id=' . $this->album1->id); | ||
$this->assertOk($response); | ||
$response->assertDontSee($this->subAlbum1->id); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
// Route::get('/Statistics::albumSpace', [StatisticsController::class, 'getSpacePerAlbum'])->middleware(['support:se']); | ||
// Route::get('/Statistics::totalAlbumSpace', [StatisticsController::class, 'getTotalSpacePerAlbum'])->middleware(['support:se']); | ||
|
||
namespace Tests\Feature_v2\Statistics; | ||
|
||
use LycheeVerify\Http\Middleware\VerifySupporterStatus; | ||
use Tests\Feature_v2\Base\BaseApiV2Test; | ||
|
||
class AlbumSpaceTest extends BaseApiV2Test | ||
{ | ||
public function testAlbumSpaceTestUnauthorized(): void | ||
{ | ||
$response = $this->getJson('Statistics::albumSpace'); | ||
$this->assertSupporterRequired($response); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->getJson('Statistics::albumSpace'); | ||
$this->assertUnauthorized($response); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->userMayUpload1)->getJson('Statistics::albumSpace'); | ||
$this->assertForbidden($response); | ||
} | ||
|
||
public function testAlbumSpaceTestAuthorized(): void | ||
{ | ||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->userMayUpload1)->getJson('Statistics::albumSpace?album_id=' . $this->album1->id); | ||
$this->assertOk($response); | ||
$this->assertCount(1, $response->json()); | ||
$this->assertEquals($this->album1->title, $response->json()[0]['title']); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->admin)->getJson('Statistics::albumSpace'); | ||
$this->assertOk($response); | ||
$this->assertCount(7, $response->json()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
// Route::get('/Statistics::userSpace', [StatisticsController::class, 'getSpacePerUser'])->middleware(['support:se']); | ||
// Route::get('/Statistics::sizeVariantSpace', [StatisticsController::class, 'getSpacePerSizeVariantType'])->middleware(['support:se']); | ||
// Route::get('/Statistics::albumSpace', [StatisticsController::class, 'getSpacePerAlbum'])->middleware(['support:se']); | ||
// Route::get('/Statistics::totalAlbumSpace', [StatisticsController::class, 'getTotalSpacePerAlbum'])->middleware(['support:se']); | ||
|
||
namespace Tests\Feature_v2\Statistics; | ||
|
||
use App\Enum\SizeVariantType; | ||
use LycheeVerify\Http\Middleware\VerifySupporterStatus; | ||
use Tests\Feature_v2\Base\BaseApiV2Test; | ||
|
||
class SizeVariantSpaceTest extends BaseApiV2Test | ||
{ | ||
public function testSizeVariantSpaceUnauthorized(): void | ||
{ | ||
$response = $this->getJson('Statistics::sizeVariantSpace'); | ||
$this->assertSupporterRequired($response); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->getJson('Statistics::sizeVariantSpace'); | ||
$this->assertUnauthorized($response); | ||
} | ||
|
||
public function testSizeVariantSpaceAuthorized(): void | ||
{ | ||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->userMayUpload1)->getJson('Statistics::sizeVariantSpace'); | ||
$this->assertOk($response); | ||
$this->assertCount(7, $response->json()); | ||
$this->assertEquals(SizeVariantType::ORIGINAL->value, $response->json()[0]['type']); | ||
$this->assertEquals(SizeVariantType::MEDIUM2X->value, $response->json()[1]['type']); | ||
$this->assertEquals(SizeVariantType::MEDIUM->value, $response->json()[2]['type']); | ||
$this->assertEquals(SizeVariantType::SMALL2X->value, $response->json()[3]['type']); | ||
$this->assertEquals(SizeVariantType::SMALL->value, $response->json()[4]['type']); | ||
$this->assertEquals(SizeVariantType::THUMB2X->value, $response->json()[5]['type']); | ||
$this->assertEquals(SizeVariantType::THUMB->value, $response->json()[6]['type']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
|
||
namespace Tests\Feature_v2\Statistics; | ||
|
||
use LycheeVerify\Http\Middleware\VerifySupporterStatus; | ||
use Tests\Feature_v2\Base\BaseApiV2Test; | ||
|
||
class TotalAlbumSpaceTest extends BaseApiV2Test | ||
{ | ||
public function testTotalAlbumSpaceTestUnauthorized(): void | ||
{ | ||
$response = $this->getJson('Statistics::totalAlbumSpace'); | ||
$this->assertSupporterRequired($response); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->getJson('Statistics::totalAlbumSpace'); | ||
$this->assertUnauthorized($response); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->userMayUpload1)->getJson('Statistics::totalAlbumSpace'); | ||
$this->assertForbidden($response); | ||
} | ||
|
||
public function testTotalAlbumSpaceTestAuthorized(): void | ||
{ | ||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->userMayUpload1)->getJson('Statistics::totalAlbumSpace?album_id=' . $this->album1->id); | ||
$this->assertOk($response); | ||
$this->assertCount(1, $response->json()); | ||
$this->assertEquals($this->album1->title, $response->json()[0]['title']); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->admin)->getJson('Statistics::totalAlbumSpace'); | ||
$this->assertOk($response); | ||
$this->assertCount(7, $response->json()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/** | ||
* We don't care for unhandled exceptions in tests. | ||
* It is the nature of a test to throw an exception. | ||
* Without this suppression we had 100+ Linter warning in this file which | ||
* don't help anything. | ||
* | ||
* @noinspection PhpDocMissingThrowsInspection | ||
* @noinspection PhpUnhandledExceptionInspection | ||
*/ | ||
|
||
namespace Tests\Feature_v2\Statistics; | ||
|
||
use LycheeVerify\Http\Middleware\VerifySupporterStatus; | ||
use Tests\Feature_v2\Base\BaseApiV2Test; | ||
|
||
class UserSpaceTest extends BaseApiV2Test | ||
{ | ||
public function testUserSpaceUnauthorized(): void | ||
{ | ||
$response = $this->getJson('Statistics::userSpace'); | ||
$this->assertSupporterRequired($response); | ||
|
||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->getJson('Statistics::userSpace'); | ||
$this->assertUnauthorized($response); | ||
} | ||
|
||
public function testUserSpaceAuthorized(): void | ||
{ | ||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->userMayUpload1)->getJson('Statistics::userSpace'); | ||
$this->assertOk($response); | ||
$this->assertCount(1, $response->json()); | ||
$this->assertEquals($this->userMayUpload1->username(), $response->json()[0]['username']); | ||
} | ||
|
||
public function testUserSpaceAdmin(): void | ||
{ | ||
$response = $this->withoutMiddleware(VerifySupporterStatus::class)->actingAs($this->admin)->getJson('Statistics::userSpace'); | ||
$this->assertOk($response); | ||
// We have 5 registered users during the tests. | ||
$this->assertCount(5, $response->json()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters