firefly-iii/tests/acceptance/Controllers/BudgetControllerTest.php

189 lines
5.1 KiB
PHP
Raw Normal View History

2016-01-19 23:20:09 -06:00
<?php
/**
* BudgetControllerTest.php
* Copyright (C) 2016 Sander Dorigo
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-01-19 at 15:39:27.
*/
class BudgetControllerTest extends TestCase
{
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BudgetController::amount
* @covers FireflyIII\Http\Controllers\BudgetController::__construct
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testAmount($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$args = [
'amount' => 1200,
];
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-20 09:15:23 -06:00
2016-01-24 11:11:57 -06:00
$this->call('POST', '/budgets/amount/1', $args);
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::create
*/
public function testCreate()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets/create');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::delete
*/
public function testDelete()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets/delete/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::destroy
*/
public function testDestroy()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->session(['budgets.delete.url' => 'http://localhost']);
2016-01-24 11:11:57 -06:00
$this->call('POST', '/budgets/destroy/2');
2016-01-20 09:15:23 -06:00
$this->assertSessionHas('success');
2016-01-24 11:11:57 -06:00
$this->assertResponseStatus(302);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::edit
*/
public function testEdit()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets/edit/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BudgetController::index
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testIndex($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BudgetController::noBudget
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testNoBudget($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets/list/noBudget');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BudgetController::postUpdateIncome
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testPostUpdateIncome($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$args = [
'amount' => 1200,
];
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-20 09:15:23 -06:00
2016-01-24 11:11:57 -06:00
$this->call('POST', '/budgets/income', $args);
$this->assertResponseStatus(302);
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BudgetController::show
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testShow($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets/show/1');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::store
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\BudgetFormRequest::authorize
* @covers FireflyIII\Http\Requests\BudgetFormRequest::rules
2016-01-19 23:20:09 -06:00
*/
public function testStore()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->session(['budgets.create.url' => 'http://localhost']);
$args = [
2016-02-04 00:30:48 -06:00
'name' => 'Some kind of test budget.',
2016-01-20 09:15:23 -06:00
];
2016-01-24 11:11:57 -06:00
$this->call('POST', '/budgets/store', $args);
$this->assertResponseStatus(302);
2016-01-20 09:15:23 -06:00
$this->assertSessionHas('success');
2016-01-19 23:20:09 -06:00
}
/**
* @covers FireflyIII\Http\Controllers\BudgetController::update
2016-02-04 00:30:48 -06:00
* @covers FireflyIII\Http\Requests\BudgetFormRequest::authorize
* @covers FireflyIII\Http\Requests\BudgetFormRequest::rules
2016-01-19 23:20:09 -06:00
*/
public function testUpdate()
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->session(['budgets.edit.url' => 'http://localhost']);
$args = [
2016-02-04 00:30:48 -06:00
'name' => 'Some kind of test budget.',
'id' => 1,
2016-01-20 09:15:23 -06:00
];
2016-01-24 11:11:57 -06:00
$this->call('POST', '/budgets/update/1', $args);
$this->assertResponseStatus(302);
2016-01-20 09:15:23 -06:00
$this->assertSessionHas('success');
2016-01-19 23:20:09 -06:00
}
/**
2016-02-05 08:41:40 -06:00
* @covers FireflyIII\Http\Controllers\BudgetController::updateIncome
* @dataProvider dateRangeProvider
2016-02-05 08:41:40 -06:00
*
* @param $range
2016-01-19 23:20:09 -06:00
*/
public function testUpdateIncome($range)
2016-01-19 23:20:09 -06:00
{
2016-01-20 09:15:23 -06:00
$this->be($this->user());
$this->changeDateRange($this->user(), $range);
2016-01-24 11:11:57 -06:00
$this->call('GET', '/budgets/income');
$this->assertResponseStatus(200);
2016-01-19 23:20:09 -06:00
}
}