be($this->user());
$this->call('GET', route('accounts.create', ['asset']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('
');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::delete
*/
public function testDelete()
{
$this->be($this->user());
$this->call('GET', route('accounts.delete', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::destroy
*/
public function testDestroy()
{
$repository = $this->mock(AccountRepositoryInterface::class);
$repository->shouldReceive('find')->withArgs([0])->once()->andReturn(new Account);
$repository->shouldReceive('destroy')->andReturn(true);
$this->session(['accounts.delete.url' => 'http://localhost']);
$this->be($this->user());
$this->call('post', route('accounts.destroy', [1]));
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::edit
*/
public function testEdit()
{
$this->be($this->user());
$this->call('GET', route('accounts.edit', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::index
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testIndex(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('accounts.index', ['asset']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::show
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShow(string $range)
{
$tasker = $this->mock(\FireflyIII\Repositories\Account\AccountTaskerInterface::class);
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('accounts.show', [1]));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::showWithDate
* @dataProvider dateRangeProvider
*
* @param string $range
*/
public function testShowByDate(string $range)
{
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
$this->call('GET', route('accounts.show.date', [1, '2016-01-01']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::store
*/
public function testStore()
{
$this->session(['accounts.create.url' => 'http://localhost']);
$this->be($this->user());
$data = [
'name' => 'new account ' . rand(1000, 9999),
'what' => 'asset',
];
$this->call('post', route('accounts.store', ['asset']), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// list should have this new account.
$this->call('GET', route('accounts.index', ['asset']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
$this->see($data['name']);
}
/**
* @covers FireflyIII\Http\Controllers\AccountController::update
*/
public function testUpdate()
{
$this->session(['accounts.edit.url' => 'http://localhost']);
$this->be($this->user());
$data = [
'name' => 'updated account ' . rand(1000, 9999),
'active' => 1,
'what' => 'asset',
];
$this->call('post', route('accounts.update', [1]), $data);
$this->assertResponseStatus(302);
$this->assertSessionHas('success');
// list should have this new account.
$this->call('GET', route('accounts.index', ['asset']));
$this->assertResponseStatus(200);
// has bread crumb
$this->see('');
$this->see($data['name']);
}
}