Skip to content

Firefly III: a personal finances manager

Reference to unknown chart.

James Cole40ca72c65699
diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php
index 423151b2fa..ff75bc676c 100644
--- a/app/Http/Controllers/Chart/AccountController.php
+++ b/app/Http/Controllers/Chart/AccountController.php
@@ -298,7 +298,7 @@ class AccountController extends Controller
foreach ($result as $row) {
$categoryId = $row['category_id'];
- $name = $names[$categoryId];
+ $name = $names[$categoryId] ?? '(unknown)';
$label = (string)trans('firefly.name_in_currency', ['name' => $name, 'currency' => $row['currency']]);
$chartData[$label] = $row['total'];
}
diff --git a/tests/Feature/Controllers/Chart/BillControllerTest.php b/tests/Feature/Controllers/Chart/BillControllerTest.php
index 24f70f528e..62c6324314 100644
--- a/tests/Feature/Controllers/Chart/BillControllerTest.php
+++ b/tests/Feature/Controllers/Chart/BillControllerTest.php
@@ -25,7 +25,9 @@ namespace Tests\Feature\Controllers\Chart;
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Transaction;
+use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
+use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Tests\TestCase;
@@ -52,12 +54,21 @@ class BillControllerTest extends TestCase
*/
public function testFrontpage(string $range): void
{
- $generator = $this->mock(GeneratorInterface::class);
- $repository = $this->mock(BillRepositoryInterface::class);
+ $generator = $this->mock(GeneratorInterface::class);
+ $repository = $this->mock(BillRepositoryInterface::class);
+ $currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
- $repository->shouldReceive('getBillsPaidInRange')->once()->andReturn('-1');
- $repository->shouldReceive('getBillsUnpaidInRange')->once()->andReturn('2');
- $generator->shouldReceive('pieChart')->once()->andReturn([]);
+ $amounts = [
+ 1 => '100',
+ 2 => '100',
+ ];
+
+ $currencyRepos->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1))->withArgs([1]);
+ $currencyRepos->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(2))->withArgs([2]);
+
+ $repository->shouldReceive('getBillsPaidInRangePerCurrency')->once()->andReturn($amounts);
+ $repository->shouldReceive('getBillsUnpaidInRangePerCurrency')->once()->andReturn($amounts);
+ $generator->shouldReceive('multiCurrencyPieChart')->once()->andReturn([]);
$this->be($this->user());
$this->changeDateRange($this->user(), $range);