. */ declare(strict_types=1); namespace Tests\Feature\Console\Commands\Integrity; use FireflyIII\Models\Account; use FireflyIII\Models\Budget; use FireflyIII\Models\Category; use FireflyIII\Models\Tag; use Log; use Tests\TestCase; /** * Class ReportEmptyObjectsTest * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.TooManyPublicMethods) */ class ReportEmptyObjectsTest extends TestCase { /** * */ public function setUp(): void { self::markTestIncomplete('Incomplete for refactor.'); return; parent::setUp(); Log::info(sprintf('Now in %s.', get_class($this))); } /** * Run basic test routine. * * @covers \FireflyIII\Console\Commands\Integrity\ReportEmptyObjects */ public function testHandleBudget(): void { $user = $this->user(); $budget = Budget::create( [ 'user_id' => $user->id, 'name' => 'Some budget', ]); $budgetLine = sprintf('User #%d (%s) has budget #%d ("%s") which has no transaction journals.', $user->id, $user->email, $budget->id, $budget->name); $budgetLimitLine = sprintf('User #%d (%s) has budget #%d ("%s") which has no budget limits.', $user->id, $user->email, $budget->id, $budget->name); $this->artisan('firefly-iii:report-empty-objects') ->expectsOutput($budgetLine) ->expectsOutput($budgetLimitLine) ->assertExitCode(0); $budget->forceDelete(); // this method changes no objects so there is nothing to verify. } /** * Run basic test routine. * * @covers \FireflyIII\Console\Commands\Integrity\ReportEmptyObjects */ public function testHandleCategory(): void { $user = $this->user(); $category = Category::create( [ 'user_id' => $user->id, 'name' => 'Some category', ]); $categoryLine = sprintf('User #%d (%s) has category #%d ("%s") which has no transaction journals.', $user->id, $user->email, $category->id, $category->name); $this->artisan('firefly-iii:report-empty-objects') ->expectsOutput($categoryLine) ->assertExitCode(0); $category->forceDelete(); // this method changes no objects so there is nothing to verify. } /** * Run basic test routine. * * @covers \FireflyIII\Console\Commands\Integrity\ReportEmptyObjects */ public function testHandleTag(): void { $user = $this->user(); $tag = Tag::create( [ 'user_id' => $user->id, 'tag' => 'Some tag', 'tagMode' => 'nothing', ]); $tagLine = sprintf('User #%d (%s) has tag #%d ("%s") which has no transaction journals.', $user->id, $user->email, $tag->id, $tag->tag); $this->artisan('firefly-iii:report-empty-objects') ->expectsOutput($tagLine) ->assertExitCode(0); $tag->forceDelete(); // this method changes no objects so there is nothing to verify. } /** * Run basic test routine. * * @covers \FireflyIII\Console\Commands\Integrity\ReportEmptyObjects */ public function testHandleAccount(): void { $user = $this->user(); $account = Account::create( [ 'user_id' => $user->id, 'name' => 'Some account', 'account_type_id' => 1, ]); $tagLine = sprintf('User #%d (%s) has account #%d ("%s") which has no transactions.', $user->id, $user->email, $account->id, $account->name); $this->artisan('firefly-iii:report-empty-objects') ->expectsOutput($tagLine) ->assertExitCode(0); $account->forceDelete(); // this method changes no objects so there is nothing to verify. } }