Built chart tests.

This commit is contained in:
James Cole
2015-05-22 18:31:57 +02:00
parent 1f865d3ea4
commit eecb4db34c
6 changed files with 368 additions and 16 deletions

View File

@@ -1,5 +1,9 @@
<?php
use Carbon\Carbon;
use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class ChartBillControllerTest
*/
@@ -20,17 +24,62 @@ class ChartBillControllerTest extends TestCase
*/
public function tearDown()
{
parent::tearDown();
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
}
public function testFrontpage()
{
$this->markTestIncomplete();
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// set!
$bills = new Collection([FactoryMuffin::create('FireflyIII\Models\Bill'), FactoryMuffin::create('FireflyIII\Models\Bill')]);
$journals = new Collection(
[FactoryMuffin::create('FireflyIII\Models\TransactionJournal'), FactoryMuffin::create('FireflyIII\Models\TransactionJournal')]
);
$creditCards = new Collection([FactoryMuffin::create('FireflyIII\Models\Account'), FactoryMuffin::create('FireflyIII\Models\Account')]);
$ranges = [['start' => new Carbon, 'end' => new Carbon]];
// mock!
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
$accounts = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// fake!
$repository->shouldReceive('getActiveBills')->andReturn($bills);
$repository->shouldReceive('getRanges')->andReturn($ranges);
$repository->shouldReceive('getJournalsInRange')->andReturn(new Collection, $journals);
$accounts->shouldReceive('getCreditCards')->andReturn($creditCards);
$accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection);
$repository->shouldReceive('createFakeBill')->andReturn($bills->first());
Steam::shouldReceive('balance')->andReturn(-10,0);
$this->call('GET', '/chart/bill/frontpage');
$this->assertResponseOk();
}
public function testSingle()
{
$this->markTestIncomplete();
$bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$this->be($bill->user);
// set
$journals = new Collection([FactoryMuffin::create('FireflyIII\Models\TransactionJournal')]);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
$repository->shouldReceive('getJournals')->andReturn($journals);
// fake!
$this->call('GET', '/chart/bill/' . $bill->id);
$this->assertResponseOk();
}