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,10 @@
<?php
use Carbon\Carbon;
use FireflyIII\Models\AccountMeta;
use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin;
/**
* Class ChartAccountControllerTest
*/
@@ -25,16 +30,93 @@ class ChartAccountControllerTest extends TestCase
public function testAll()
{
$this->markTestIncomplete();
$user = FactoryMuffin::create('FireflyIII\User');
FactoryMuffin::create('FireflyIII\Models\AccountType');
FactoryMuffin::create('FireflyIII\Models\AccountType');
$asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
$one = FactoryMuffin::create('FireflyIII\Models\Account');
$two = FactoryMuffin::create('FireflyIII\Models\Account');
$one->account_type_id = $asset->id;
$two->account_type_id = $asset->id;
$one->save();
$two->save();
$accounts = new Collection([$one, $two]);
$date = new Carbon;
$this->be($user);
// make one shared:
AccountMeta::create(
[
'account_id' => $one->id,
'name' => 'accountRole',
'data' => 'sharedAsset'
]
);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// fake!
$repository->shouldReceive('getAccounts')->once()->andReturn($accounts);
$this->call('GET', '/chart/account/month/' . $date->format('Y/m'));
$this->assertResponseOk();
}
public function testAllShared()
{
$user = FactoryMuffin::create('FireflyIII\User');
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$accounts = new Collection([$account]);
$date = new Carbon;
$this->be($user);
// make it shared:
AccountMeta::create(
[
'account_id' => $account->id,
'name' => 'accountRole',
'data' => 'sharedAsset'
]
);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// fake!
$repository->shouldReceive('getAccounts')->once()->andReturn($accounts);
$this->call('GET', '/chart/account/month/' . $date->format('Y/m') . '/shared');
$this->assertResponseOk();
}
public function testFrontpage()
{
$this->markTestIncomplete();
$accounts = new Collection([FactoryMuffin::create('FireflyIII\Models\Account')]);
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// mock!
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
// fake!
$repository->shouldReceive('getFrontpageAccounts')->andReturn($accounts);
$this->call('GET', '/chart/account/frontpage');
$this->assertResponseOk();
}
public function testSingle()
{
$this->markTestIncomplete();
$account = FactoryMuffin::create('FireflyIII\Models\Account');
$this->be($account->user);
$this->call('GET', '/chart/account/' . $account->id);
$this->assertResponseOk();
}
}