Reference to unknown chart.

This commit is contained in:
James Cole 2018-08-28 14:20:04 +02:00
parent e1c829f4fa
commit 40ca72c656
2 changed files with 17 additions and 6 deletions

View File

@ -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'];
}

View File

@ -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;
@ -54,10 +56,19 @@ class BillControllerTest extends TestCase
{
$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);