mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-22 20:36:43 +00:00
85 lines
2.6 KiB
PHP
85 lines
2.6 KiB
PHP
![]() |
<?php
|
||
|
/**
|
||
|
* BudgetLimitCurrencyTest.php
|
||
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
||
|
*
|
||
|
* This file is part of Firefly III.
|
||
|
*
|
||
|
* Firefly III is free software: you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation, either version 3 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* Firefly III 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 General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
namespace Tests\Unit\Console\Commands\Upgrade;
|
||
|
|
||
|
|
||
|
use FireflyConfig;
|
||
|
use FireflyIII\Models\BudgetLimit;
|
||
|
use FireflyIII\Models\Configuration;
|
||
|
use Log;
|
||
|
use Tests\TestCase;
|
||
|
|
||
|
/**
|
||
|
* Class BudgetLimitCurrencyTest
|
||
|
*/
|
||
|
class BudgetLimitCurrencyTest extends TestCase
|
||
|
{
|
||
|
/**
|
||
|
*
|
||
|
*/
|
||
|
public function setUp(): void
|
||
|
{
|
||
|
parent::setUp();
|
||
|
Log::info(sprintf('Now in %s.', get_class($this)));
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @covers \FireflyIII\Console\Commands\Upgrade\BudgetLimitCurrency
|
||
|
*/
|
||
|
public function testHandle(): void
|
||
|
{
|
||
|
$this->artisan('firefly-iii:bl-currency')
|
||
|
->assertExitCode(0);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Create a bad budget limit.
|
||
|
* @covers \FireflyIII\Console\Commands\Upgrade\BudgetLimitCurrency
|
||
|
*/
|
||
|
public function testHandleBadLimit(): void
|
||
|
{
|
||
|
$false = new Configuration;
|
||
|
$false->data = false;
|
||
|
$budget = $this->user()->budgets()->first();
|
||
|
$limit = BudgetLimit::create(
|
||
|
[
|
||
|
'budget_id' => $budget->id,
|
||
|
'amount' => '10',
|
||
|
'start_date' => '2019-01-01',
|
||
|
'end_date' => '2019-01-31',
|
||
|
]);
|
||
|
|
||
|
FireflyConfig::shouldReceive('get')->withArgs(['4780_bl_currency', false])->andReturn($false);
|
||
|
FireflyConfig::shouldReceive('set')->withArgs(['4780_bl_currency', true]);
|
||
|
|
||
|
$this->artisan('firefly-iii:bl-currency')
|
||
|
->expectsOutput(
|
||
|
sprintf('Budget limit #%d (part of budget "%s") now has a currency setting (%s).',
|
||
|
$limit->id, $budget->name, 'Euro'
|
||
|
)
|
||
|
)
|
||
|
->assertExitCode(0);
|
||
|
|
||
|
// assume currency is filled in.
|
||
|
$this->assertCount(1, BudgetLimit::where('id', $limit->id)->where('transaction_currency_id', 1)->get());
|
||
|
}
|
||
|
}
|