2019-06-10 13:14:00 -05:00
|
|
|
<?php
|
2019-10-01 23:45:03 -05:00
|
|
|
/**
|
|
|
|
* EnableCurrenciesTest.php
|
2020-02-16 06:59:55 -06:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2019-10-01 23:45:03 -05:00
|
|
|
*
|
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-08-17 05:09:03 -05:00
|
|
|
declare(strict_types=1);
|
2019-06-10 13:14:00 -05:00
|
|
|
|
|
|
|
namespace Tests\Unit\Console\Commands\Correction;
|
|
|
|
|
|
|
|
|
|
|
|
use FireflyIII\Models\BudgetLimit;
|
|
|
|
use FireflyIII\Models\TransactionCurrency;
|
|
|
|
use Log;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class EnableCurrenciesTest
|
2019-08-17 03:48:28 -05:00
|
|
|
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
|
|
|
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
|
|
|
|
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
|
2019-06-10 13:14:00 -05:00
|
|
|
*/
|
|
|
|
class EnableCurrenciesTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2020-07-30 13:49:40 -05:00
|
|
|
self::markTestIncomplete('Incomplete for refactor.');
|
|
|
|
|
|
|
|
return;
|
2019-06-10 13:14:00 -05:00
|
|
|
parent::setUp();
|
|
|
|
Log::info(sprintf('Now in %s.', get_class($this)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Console\Commands\Correction\EnableCurrencies
|
|
|
|
*/
|
|
|
|
public function testHandle(): void
|
|
|
|
{
|
|
|
|
// assume the current database is intact.
|
|
|
|
$count = TransactionCurrency::where('enabled', 1)->count();
|
|
|
|
|
|
|
|
$this->artisan('firefly-iii:enable-currencies')
|
2019-06-13 11:07:49 -05:00
|
|
|
->expectsOutput('All currencies are correctly enabled or disabled.')
|
2019-06-10 13:14:00 -05:00
|
|
|
->assertExitCode(0);
|
|
|
|
|
|
|
|
|
|
|
|
$this->assertCount($count, TransactionCurrency::where('enabled', 1)->get());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @covers \FireflyIII\Console\Commands\Correction\EnableCurrencies
|
|
|
|
*/
|
|
|
|
public function testHandleDisabled(): void
|
|
|
|
{
|
|
|
|
// find a disabled currency, update a budget limit with it.
|
|
|
|
$currency = TransactionCurrency::where('enabled', 0)->first();
|
|
|
|
/** @var BudgetLimit $budgetLimit */
|
|
|
|
$budgetLimit = BudgetLimit::inRandomOrder()->first();
|
|
|
|
$budgetLimit->transaction_currency_id = $currency->id;
|
|
|
|
$budgetLimit->save();
|
|
|
|
|
|
|
|
// assume the current database is intact.
|
|
|
|
$count = TransactionCurrency::where('enabled', 1)->count();
|
|
|
|
$this->artisan('firefly-iii:enable-currencies')
|
|
|
|
->expectsOutput(sprintf('%d were (was) still disabled. This has been corrected.', 1))
|
|
|
|
->assertExitCode(0);
|
|
|
|
|
|
|
|
// assume its been enabled.
|
|
|
|
$this->assertCount($count + 1, TransactionCurrency::where('enabled', 1)->get());
|
|
|
|
}
|
|
|
|
|
2019-08-17 05:09:03 -05:00
|
|
|
}
|