2015-03-28 00:48:38 -05:00
|
|
|
<?php
|
2015-03-31 12:21:49 -05:00
|
|
|
use FireflyIII\Models\Preference;
|
2015-04-02 15:39:31 -05:00
|
|
|
use FireflyIII\Models\TransactionCurrency;
|
2015-04-03 01:31:50 -05:00
|
|
|
use League\FactoryMuffin\Facade as FactoryMuffin;
|
|
|
|
|
2015-03-28 00:48:38 -05:00
|
|
|
/**
|
|
|
|
* Generated by PHPUnit_SkeletonGenerator on 2015-03-08 at 20:05:14.
|
|
|
|
*/
|
|
|
|
class AccountControllerTest extends TestCase
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets up the fixture, for example, opens a network connection.
|
|
|
|
* This method is called before a test is executed.
|
|
|
|
*/
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-04-02 15:51:00 -05:00
|
|
|
|
2015-03-28 00:48:38 -05:00
|
|
|
/**
|
|
|
|
* Tears down the fixture, for example, closes a network connection.
|
|
|
|
* This method is called after a test is executed.
|
|
|
|
*/
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testCreate()
|
|
|
|
{
|
2015-04-03 01:31:50 -05:00
|
|
|
$pref = FactoryMuffin::create('FireflyIII\Models\Preference');
|
2015-03-31 12:21:49 -05:00
|
|
|
$pref->data = '1M';
|
2015-04-03 01:31:50 -05:00
|
|
|
$this->be($pref->user);
|
|
|
|
|
2015-03-31 12:21:49 -05:00
|
|
|
|
|
|
|
Preferences::shouldReceive('get', 'viewRange')->andReturn($pref);
|
2015-04-03 01:55:24 -05:00
|
|
|
|
|
|
|
// CURRENCY:
|
|
|
|
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
|
|
|
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
|
|
|
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
2015-03-31 12:21:49 -05:00
|
|
|
|
2015-04-03 01:31:50 -05:00
|
|
|
$this->call('GET', '/accounts/create/asset');
|
2015-03-28 00:48:38 -05:00
|
|
|
$this->assertResponseOk();
|
2015-03-31 12:21:49 -05:00
|
|
|
|
|
|
|
|
2015-03-28 00:48:38 -05:00
|
|
|
$this->assertViewHas('subTitle', 'Create a new asset account');
|
|
|
|
$this->assertViewHas('subTitleIcon', 'fa-money');
|
|
|
|
$this->assertViewHas('what', 'asset');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testDelete()
|
|
|
|
{
|
2015-04-03 01:31:50 -05:00
|
|
|
// fake an account.
|
2015-04-03 01:55:24 -05:00
|
|
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
2015-04-03 01:31:50 -05:00
|
|
|
$account->accountType->type = 'Asset account';
|
|
|
|
$account->accountType->save();
|
|
|
|
|
|
|
|
$this->be($account->user);
|
|
|
|
$this->call('GET', '/accounts/delete/' . $account->id);
|
|
|
|
$this->assertResponseOk();
|
|
|
|
$this->assertViewHas('subTitle', 'Delete ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"');
|
|
|
|
|
2015-03-28 00:48:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testDestroy()
|
|
|
|
{
|
2015-04-03 01:55:24 -05:00
|
|
|
// fake an account.
|
|
|
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
|
|
|
$account->accountType->type = 'Asset account';
|
|
|
|
$account->accountType->save();
|
|
|
|
|
|
|
|
$this->be($account->user);
|
|
|
|
$this->assertCount(1, DB::table('accounts')->where('id', $account->id)->whereNull('deleted_at')->get());
|
|
|
|
|
|
|
|
// post it!
|
|
|
|
$this->call('POST', '/accounts/destroy/' . $account->id, ['_token' => 'replaceme']);
|
|
|
|
$this->assertSessionHas('success');
|
|
|
|
$this->assertCount(0, DB::table('accounts')->where('id', $account->id)->whereNull('deleted_at')->get());
|
2015-03-28 00:48:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testEdit()
|
|
|
|
{
|
2015-04-03 01:55:24 -05:00
|
|
|
// fake an account.
|
|
|
|
$account = FactoryMuffin::create('FireflyIII\Models\Account');
|
|
|
|
$account->accountType->type = 'Asset account';
|
|
|
|
$account->accountType->save();
|
|
|
|
|
|
|
|
$this->be($account->user);
|
|
|
|
$this->assertCount(1, DB::table('accounts')->where('id', $account->id)->whereNull('deleted_at')->get());
|
|
|
|
|
|
|
|
// CURRENCY:
|
|
|
|
$currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
|
|
|
|
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
|
|
|
|
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
|
|
|
|
|
|
|
|
// get edit page:
|
|
|
|
$this->call('GET', '/accounts/edit/' . $account->id);
|
|
|
|
|
|
|
|
// assert stuff:
|
|
|
|
$this->assertResponseOk();
|
|
|
|
$this->assertSessionHas('preFilled');
|
|
|
|
$this->assertViewHas('subTitle', 'Edit ' . strtolower(e($account->accountType->type)) . ' "' . e($account->name) . '"');
|
|
|
|
|
|
|
|
|
2015-03-28 00:48:38 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testIndex()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testShow()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testStore()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testUpdate()
|
|
|
|
{
|
|
|
|
$this->markTestIncomplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|