mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-26 00:34:28 +02:00
* refactor: migration from laravel-enum package to native php enums * style: fix StyleCI findings
84 lines
1.9 KiB
PHP
84 lines
1.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit\Actions\Storage\Base;
|
|
|
|
use App\Actions\Storage\Base\DeleteResults;
|
|
use App\Enums\Actions\ActionStatus;
|
|
use App\Models\Wiki\Video;
|
|
use Illuminate\Foundation\Testing\WithFaker;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Class DeleteResultsTest.
|
|
*/
|
|
class DeleteResultsTest extends TestCase
|
|
{
|
|
use WithFaker;
|
|
|
|
/**
|
|
* The Action result has failed if there are no deletions.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testDefault(): void
|
|
{
|
|
$video = Video::factory()->createOne();
|
|
|
|
$deleteResults = new DeleteResults($video);
|
|
|
|
$result = $deleteResults->toActionResult();
|
|
|
|
static::assertTrue($result->hasFailed());
|
|
}
|
|
|
|
/**
|
|
* The Action result has failed if any deletions have returned false.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testFailed(): void
|
|
{
|
|
$video = Video::factory()->createOne();
|
|
|
|
$deletions = [];
|
|
|
|
foreach (range(0, $this->faker->randomDigitNotNull()) as $ignored) {
|
|
$deletions[$this->faker->word()] = true;
|
|
}
|
|
|
|
foreach (range(0, $this->faker->randomDigitNotNull()) as $ignored) {
|
|
$deletions[$this->faker->word()] = false;
|
|
}
|
|
|
|
$deleteResults = new DeleteResults($video, $deletions);
|
|
|
|
$result = $deleteResults->toActionResult();
|
|
|
|
static::assertTrue($result->hasFailed());
|
|
}
|
|
|
|
/**
|
|
* The Action result has passed if all deletions have returned true.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testPassed(): void
|
|
{
|
|
$video = Video::factory()->createOne();
|
|
|
|
$deletions = [];
|
|
|
|
foreach (range(0, $this->faker->randomDigitNotNull()) as $ignored) {
|
|
$deletions[$this->faker->word()] = true;
|
|
}
|
|
|
|
$deleteResults = new DeleteResults($video, $deletions);
|
|
|
|
$result = $deleteResults->toActionResult();
|
|
|
|
static::assertTrue(ActionStatus::PASSED === $result->getStatus());
|
|
}
|
|
}
|