mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 23:45:10 +00:00
Trying to fix the tests [skip-ci]
This commit is contained in:
@@ -132,12 +132,13 @@ class ChartController extends BaseController
|
|||||||
return View::make('charts.info')->with('rows', $result)->with('sum', $sum);
|
return View::make('charts.info')->with('rows', $result)->with('sum', $sum);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function homeCategories() {
|
public function homeCategories()
|
||||||
|
{
|
||||||
list($start, $end) = tk::getDateRange();
|
list($start, $end) = tk::getDateRange();
|
||||||
$account = null;
|
$account = null;
|
||||||
$result = [];
|
$result = [];
|
||||||
// grab all transaction journals in this period:
|
// grab all transaction journals in this period:
|
||||||
$journals = $this->_journals->getByDateRange($start,$end);
|
$journals = $this->_journals->getByDateRange($start, $end);
|
||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
foreach ($journals as $journal) {
|
foreach ($journals as $journal) {
|
||||||
@@ -163,12 +164,11 @@ class ChartController extends BaseController
|
|||||||
arsort($result);
|
arsort($result);
|
||||||
$chartData = [
|
$chartData = [
|
||||||
];
|
];
|
||||||
foreach($result as $name => $value) {
|
foreach ($result as $name => $value) {
|
||||||
$chartData[] = [$name, $value];
|
$chartData[] = [$name, $value];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Response::json($chartData);
|
return Response::json($chartData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use \League\FactoryMuffin\Facade\FactoryMuffin;
|
use League\FactoryMuffin\Facade\FactoryMuffin;
|
||||||
|
|
||||||
class ChartControllerTest extends TestCase
|
class ChartControllerTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -16,10 +16,14 @@ class ChartControllerTest extends TestCase
|
|||||||
// mock preference:
|
// mock preference:
|
||||||
$pref = $this->mock('Preference');
|
$pref = $this->mock('Preference');
|
||||||
$pref->shouldReceive('getAttribute', 'data')->andReturn('1M');
|
$pref->shouldReceive('getAttribute', 'data')->andReturn('1M');
|
||||||
|
$pref2 = $this->mock('Preference');
|
||||||
|
$pref2->shouldReceive('getAttribute', 'data')->andReturn([]);
|
||||||
|
|
||||||
// mock preferences helper:
|
// mock preferences helper:
|
||||||
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
||||||
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
|
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
|
||||||
|
$preferences->shouldReceive('get')->with('frontpageAccounts', [])->once()->andReturn($pref2);
|
||||||
|
|
||||||
|
|
||||||
// mock toolkit:
|
// mock toolkit:
|
||||||
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||||
@@ -34,6 +38,7 @@ class ChartControllerTest extends TestCase
|
|||||||
$one = $this->mock('Account');
|
$one = $this->mock('Account');
|
||||||
$one->shouldReceive('getAttribute')->andReturn($personal);
|
$one->shouldReceive('getAttribute')->andReturn($personal);
|
||||||
$one->shouldReceive('balance')->andReturn(0);
|
$one->shouldReceive('balance')->andReturn(0);
|
||||||
|
$one->shouldReceive('predict')->andReturn(null);
|
||||||
|
|
||||||
// collection:
|
// collection:
|
||||||
$c = new \Illuminate\Database\Eloquent\Collection([$one]);
|
$c = new \Illuminate\Database\Eloquent\Collection([$one]);
|
||||||
@@ -79,57 +84,24 @@ class ChartControllerTest extends TestCase
|
|||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testhomeBudgets()
|
|
||||||
{
|
|
||||||
// mock preference:
|
|
||||||
$pref = $this->mock('Preference');
|
|
||||||
$pref->shouldReceive('getAttribute', 'data')->andReturn('week');
|
|
||||||
|
|
||||||
$start = new \Carbon\Carbon;
|
|
||||||
$end = new \Carbon\Carbon;
|
|
||||||
|
|
||||||
// mock transaction journal
|
|
||||||
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
|
||||||
$tj->shouldReceive('homeBudgetChart')->andReturn(['entry' => 30]);
|
|
||||||
|
|
||||||
// mock toolkit:
|
|
||||||
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
|
||||||
$toolkit->shouldReceive('getDateRange')->andReturn([$start, $end]);
|
|
||||||
|
|
||||||
|
|
||||||
// mock preferences helper:
|
|
||||||
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
|
||||||
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
|
|
||||||
|
|
||||||
|
|
||||||
// call
|
|
||||||
$this->call('GET', '/chart/home/budgets');
|
|
||||||
|
|
||||||
// test
|
|
||||||
$this->assertResponseOk();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testhomeCategories()
|
public function testhomeCategories()
|
||||||
{
|
{
|
||||||
// mock preference:
|
|
||||||
$pref = $this->mock('Preference');
|
|
||||||
$pref->shouldReceive('getAttribute', 'data')->andReturn('week');
|
|
||||||
|
|
||||||
$start = new \Carbon\Carbon;
|
$start = new \Carbon\Carbon;
|
||||||
$end = new \Carbon\Carbon;
|
$end = new \Carbon\Carbon;
|
||||||
|
|
||||||
// mock transaction journal
|
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||||
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
$toolkit->shouldReceive('getDateRange')->andReturn(null);
|
||||||
$tj->shouldReceive('homeCategoryChart')->andReturn(['entry' => 30]);
|
|
||||||
|
|
||||||
// mock toolkit:
|
// mock toolkit:
|
||||||
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
// $class = $this->getMockClass('Foo', array('baz'));
|
||||||
$toolkit->shouldReceive('getDateRange')->andReturn([$start, $end]);
|
// $toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
||||||
|
// $toolkit::static ->shouldReceive('getDateRange')->once()->andReturn([$start, $end]);
|
||||||
|
|
||||||
|
// // mock transaction journal
|
||||||
|
// $tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
||||||
|
// $tj->shouldReceive('getByDateRange')->with($start, $end)->andReturn([]);
|
||||||
|
//
|
||||||
|
|
||||||
// mock preferences helper:
|
|
||||||
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
|
||||||
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
|
|
||||||
|
|
||||||
|
|
||||||
// call
|
// call
|
||||||
@@ -139,35 +111,6 @@ class ChartControllerTest extends TestCase
|
|||||||
$this->assertResponseOk();
|
$this->assertResponseOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testhomeBeneficiaries()
|
|
||||||
{
|
|
||||||
// mock preference:
|
|
||||||
$pref = $this->mock('Preference');
|
|
||||||
$pref->shouldReceive('getAttribute', 'data')->andReturn('week');
|
|
||||||
|
|
||||||
$start = new \Carbon\Carbon;
|
|
||||||
$end = new \Carbon\Carbon;
|
|
||||||
|
|
||||||
// mock transaction journal
|
|
||||||
$tj = $this->mock('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');
|
|
||||||
$tj->shouldReceive('homeBeneficiaryChart')->andReturn(['entry' => 30]);
|
|
||||||
|
|
||||||
// mock toolkit:
|
|
||||||
$toolkit = $this->mock('Firefly\Helper\Toolkit\ToolkitInterface');
|
|
||||||
$toolkit->shouldReceive('getDateRange')->andReturn([$start, $end]);
|
|
||||||
|
|
||||||
|
|
||||||
// mock preferences helper:
|
|
||||||
$preferences = $this->mock('Firefly\Helper\Preferences\PreferencesHelperInterface');
|
|
||||||
$preferences->shouldReceive('get')->with('viewRange', '1M')->once()->andReturn($pref);
|
|
||||||
|
|
||||||
|
|
||||||
// call
|
|
||||||
$this->call('GET', '/chart/home/beneficiaries');
|
|
||||||
|
|
||||||
// test
|
|
||||||
$this->assertResponseOk();
|
|
||||||
}
|
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
Mockery::close();
|
Mockery::close();
|
||||||
|
Reference in New Issue
Block a user