mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-09 23:15:45 -06:00
First set of new tests.
This commit is contained in:
parent
69bd292ed8
commit
018af62826
@ -17,10 +17,8 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Models\AccountType;
|
||||
use FireflyIII\Models\Tag;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface as ARI;
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use FireflyIII\Repositories\Tag\TagRepositoryInterface;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@ -86,30 +84,14 @@ class HomeController extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TagRepositoryInterface $repository
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
public function flush(TagRepositoryInterface $repository)
|
||||
public function flush(Request $request)
|
||||
{
|
||||
|
||||
Preferences::mark();
|
||||
|
||||
// get all tags.
|
||||
// update all counts:
|
||||
$tags = $repository->get();
|
||||
|
||||
/** @var Tag $tag */
|
||||
foreach ($tags as $tag) {
|
||||
foreach ($tag->transactionJournals()->get() as $journal) {
|
||||
$count = $journal->tags()->count();
|
||||
$journal->tag_count = $count;
|
||||
$journal->save();
|
||||
}
|
||||
}
|
||||
Session::forget(['start', 'end', 'viewRange', 'range', 'is_custom_range']);
|
||||
|
||||
Session::clear();
|
||||
$request->session()->forget(['start', 'end', 'viewRange', 'range', 'is_custom_range']);
|
||||
Artisan::call('cache:clear');
|
||||
|
||||
return redirect(route('index'));
|
||||
@ -159,74 +141,6 @@ class HomeController extends Controller
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a list of named routes. Excludes some that cannot be "shown". This method
|
||||
* is used to generate help files (down the road).
|
||||
*/
|
||||
public function routes()
|
||||
{
|
||||
// these routes are not relevant for the help pages:
|
||||
$ignore = [
|
||||
// login and two-factor routes:
|
||||
'login',
|
||||
'registe',
|
||||
'password.rese',
|
||||
'logout',
|
||||
'two-fac',
|
||||
'lost-two',
|
||||
// test troutes
|
||||
'test-flash',
|
||||
'all-routes',
|
||||
// json routes
|
||||
'json.',
|
||||
// routes that point to modals or that redirect immediately.
|
||||
'piggy-banks.add',
|
||||
'piggy-banks.remove',
|
||||
'rules.rule.up',
|
||||
'attachments.download',
|
||||
'bills.rescan',
|
||||
'rules.rule.down',
|
||||
'rules.rule-group.up',
|
||||
'rules.rule-group.down',
|
||||
'popup.',
|
||||
'error',
|
||||
'flush',
|
||||
//'preferences.',
|
||||
'admin.users.domains.block-',
|
||||
'help.',
|
||||
// ajax routes:
|
||||
'import.json',
|
||||
// charts:
|
||||
'chart.',
|
||||
// report data:
|
||||
'report-data.',
|
||||
|
||||
// others:
|
||||
'debugbar',
|
||||
'attachments.preview',
|
||||
'budgets.income',
|
||||
'currencies.default',
|
||||
|
||||
|
||||
];
|
||||
$routes = Route::getRoutes();
|
||||
$return = '<pre>';
|
||||
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
foreach ($routes as $route) {
|
||||
$name = $route->getName();
|
||||
$methods = $route->getMethods();
|
||||
|
||||
if (!is_null($name) && strlen($name) > 0 && in_array('GET', $methods) && !$this->startsWithAny($ignore, $name)) {
|
||||
$return .= sprintf('touch %s.md', $name) . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
$return .= '</pre><hr />';
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
|
||||
*/
|
||||
@ -240,21 +154,4 @@ class HomeController extends Controller
|
||||
return redirect(route('home'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $array
|
||||
* @param string $needle
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function startsWithAny(array $array, string $needle): bool
|
||||
{
|
||||
foreach ($array as $entry) {
|
||||
if ((substr($needle, 0, strlen($entry)) === $entry)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
var defaultChartOptions = {
|
||||
elements: {
|
||||
line : {
|
||||
line: {
|
||||
cubicInterpolationMode: 'monotone'
|
||||
}
|
||||
},
|
||||
|
@ -74,7 +74,6 @@ Route::group(
|
||||
Route::get('/flash', ['uses' => 'HomeController@testFlash', 'as' => 'test-flash']);
|
||||
Route::get('/home', ['uses' => 'HomeController@index', 'as' => 'home']);
|
||||
Route::post('/daterange', ['uses' => 'HomeController@dateRange', 'as' => 'daterange']);
|
||||
Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'all-routes']);
|
||||
}
|
||||
);
|
||||
|
||||
|
@ -12,9 +12,158 @@ declare(strict_types = 1);
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
|
||||
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BillControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.create'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->session(['bills.delete.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.index'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::rescan
|
||||
*/
|
||||
public function testRescan()
|
||||
{
|
||||
$repository = $this->mock(BillRepositoryInterface::class);
|
||||
$repository->shouldReceive('getPossiblyRelatedJournals')->once()->andReturn(new Collection);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.rescan', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::show
|
||||
*/
|
||||
public function testShow()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$data = [
|
||||
'name' => 'New Bill ' . rand(1000, 9999),
|
||||
'match' => 'some words',
|
||||
'amount_min' => '100',
|
||||
'amount_currency_id_amount_min' => 1,
|
||||
'amount_currency_id_amount_max' => 1,
|
||||
'skip' => 0,
|
||||
'amount_max' => '100',
|
||||
'date' => '2016-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
];
|
||||
$this->session(['bills.create.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
// list must be updated
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
$response->assertSee($data['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BillController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$data = [
|
||||
'name' => 'Updated Bill ' . rand(1000, 9999),
|
||||
'match' => 'some more words',
|
||||
'amount_min' => '100',
|
||||
'amount_currency_id_amount_min' => 1,
|
||||
'amount_currency_id_amount_max' => 1,
|
||||
'skip' => 0,
|
||||
'amount_max' => '100',
|
||||
'date' => '2016-01-01',
|
||||
'repeat_freq' => 'monthly',
|
||||
];
|
||||
$this->session(['bills.edit.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('bills.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
// list must be updated
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('bills.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
$response->assertSee($data['name']);
|
||||
}
|
||||
|
||||
}
|
@ -11,9 +11,262 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BudgetControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::amount
|
||||
*/
|
||||
public function testAmount()
|
||||
{
|
||||
$data = [
|
||||
'amount' => 200,
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.amount', [1]), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.create'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$this->session(['budgets.delete.url' => 'http://localhost']);
|
||||
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::index
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testIndex(string $range)
|
||||
{
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$repository->shouldReceive('cleanupBudgets');
|
||||
$repository->shouldReceive('getActiveBudgets')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getInactiveBudgets')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('budgets.index'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::noBudget
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testNoBudget(string $range)
|
||||
{
|
||||
$date = new Carbon();
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('withoutBudget')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('budgets.no-budget'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::postUpdateIncome
|
||||
*/
|
||||
public function testPostUpdateIncome()
|
||||
{
|
||||
$data = [
|
||||
'amount' => '200',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.income.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::show
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShow(string $range)
|
||||
{
|
||||
$date = new Carbon();
|
||||
$date->subDay();
|
||||
$this->session(['first' => $date]);
|
||||
|
||||
// mock account repository
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
|
||||
|
||||
// mock budget repository
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
|
||||
$budgetRepository->shouldReceive('spentInPeriod')->andReturn('1');
|
||||
// mock journal collector:
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setBudget')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('budgets.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::showByBudgetLimit()
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowByBudgetLimit(string $range)
|
||||
{
|
||||
// mock account repository
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepository->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
|
||||
// mock budget repository
|
||||
$budgetRepository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$budgetRepository->shouldReceive('spentInPeriod')->andReturn('1');
|
||||
$budgetRepository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
|
||||
|
||||
// mock journal collector:
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf();
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('setBudget')->andReturnSelf();
|
||||
$collector->shouldReceive('withCategoryInformation')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('budgets.show.limit', [1, 1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['budgets.create.url' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Budget ' . rand(1000, 9999),
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->session(['budgets.edit.url' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'Updated Budget ' . rand(1000, 9999),
|
||||
'active' => 1,
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('budgets.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\BudgetController::updateIncome
|
||||
*/
|
||||
public function testUpdateIncome()
|
||||
{
|
||||
// must be in list
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.income', [1]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
}
|
@ -11,9 +11,237 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Helpers\Collector\JournalCollectorInterface;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CategoryControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.create'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$this->session(['categories.delete.url' => 'http://localhost']);
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('categories.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.index'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::noCategory
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testNoCategory(string $range)
|
||||
{
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('categories.no-category'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::show
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShow(string $range)
|
||||
{
|
||||
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
$accRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$catRepository = $this->mock(CategoryRepositoryInterface::class);
|
||||
|
||||
$accRepository->shouldReceive('getAccountsByType')->once()->andReturn(new Collection);
|
||||
$catRepository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
|
||||
|
||||
// collector stuff:
|
||||
$collector->shouldReceive('setPage')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
|
||||
|
||||
// more repos stuff:
|
||||
$catRepository->shouldReceive('spentInPeriod')->andReturn('0');
|
||||
$catRepository->shouldReceive('earnedInPeriod')->andReturn('0');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('categories.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::showAll
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowAll(string $range)
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
|
||||
// collector stuff:
|
||||
$collector->shouldReceive('setPage')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('categories.show.all', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::showByDate
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowByDate(string $range)
|
||||
{
|
||||
$collector = $this->mock(JournalCollectorInterface::class);
|
||||
|
||||
// collector stuff:
|
||||
$collector->shouldReceive('setPage')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setLimit')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('withBudgetInformation')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('setCategory')->andReturnSelf()->once();
|
||||
$collector->shouldReceive('getPaginatedJournals')->andReturn(new LengthAwarePaginator([], 0, 10))->once();
|
||||
|
||||
// mock category repository
|
||||
$repository = $this->mock(CategoryRepositoryInterface::class);
|
||||
$repository->shouldReceive('firstUseDate')->once()->andReturn(new Carbon);
|
||||
$repository->shouldReceive('spentInPeriod')->andReturn('-1');
|
||||
$repository->shouldReceive('earnedInPeriod')->andReturn('1');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('categories.show.date', [1, '2015-01-01']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['categories.create.url' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'New Category ' . rand(1000, 9999),
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('categories.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
// must be in list
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
$response->assertSee($data['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CategoryController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->session(['categories.edit.url' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'name' => 'Updated Category ' . rand(1000, 9999),
|
||||
'active' => 1,
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('categories.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
|
||||
// must be in list
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('categories.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
$response->assertSee($data['name']);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -11,9 +11,121 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CurrencyControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('currencies.create'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::defaultCurrency
|
||||
*/
|
||||
public function testDefaultCurrency()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('currencies.default', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('currencies.delete', [2]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$this->session(['currencies.delete.url' => 'http://localhost']);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('canDeleteCurrency')->andReturn(true);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('currencies.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('currencies.edit', [2]));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('currencies.index'));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['currencies.create.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'name' => 'XX',
|
||||
'code' => 'XXX',
|
||||
'symbol' => 'x',
|
||||
'decimal_places' => 2,
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('currencies.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\CurrencyController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->session(['currencies.edit.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'name' => 'XA',
|
||||
'code' => 'XAX',
|
||||
'symbol' => 'a',
|
||||
'decimal_places' => 2,
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('currencies.update', [2]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
@ -11,9 +11,92 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Export\ProcessorInterface;
|
||||
use FireflyIII\Models\ExportJob;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\ExportJob\ExportJobRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ExportControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ExportController::download
|
||||
*/
|
||||
public function testDownload()
|
||||
{
|
||||
$repository = $this->mock(ExportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('exists')->once()->andReturn(true);
|
||||
$repository->shouldReceive('getContent')->once()->andReturn('Some content beep boop');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('export.download', ['testExport']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ExportController::getStatus
|
||||
*/
|
||||
public function testGetStatus()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('export.status', ['testExport']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ExportController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('export.index'));
|
||||
$response->assertStatus(200);
|
||||
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ExportController::postIndex
|
||||
*/
|
||||
public function testPostIndex()
|
||||
{
|
||||
$this->session(
|
||||
['first' => new Carbon('2014-01-01')]
|
||||
);
|
||||
|
||||
|
||||
$data = [
|
||||
|
||||
'export_start_range' => '2015-01-01',
|
||||
'export_end_range' => '2015-01-21',
|
||||
'exportFormat' => 'csv',
|
||||
'accounts' => [1],
|
||||
'job' => 'testExport',
|
||||
];
|
||||
|
||||
$accountRepository = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepository->shouldReceive('getAccountsById')->withArgs([$data['accounts']])->andReturn(new Collection);
|
||||
|
||||
$processor = $this->mock(ProcessorInterface::class);
|
||||
$processor->shouldReceive('setSettings')->once();
|
||||
$processor->shouldReceive('collectJournals')->once();
|
||||
$processor->shouldReceive('convertJournals')->once();
|
||||
$processor->shouldReceive('exportJournals')->once();
|
||||
$processor->shouldReceive('createZipFile')->once();
|
||||
|
||||
$repository = $this->mock(ExportJobRepositoryInterface::class);
|
||||
$repository->shouldReceive('changeStatus')->andReturn(true);
|
||||
$repository->shouldReceive('findByKey')->andReturn(new ExportJob);
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
$response = $this->post(route('export.export'), $data);
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('ok');
|
||||
}
|
||||
|
||||
}
|
@ -11,9 +11,26 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Helpers\Help\HelpInterface;
|
||||
use Tests\TestCase;
|
||||
|
||||
class HelpControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HelpController::show
|
||||
*/
|
||||
public function testShow()
|
||||
{
|
||||
$help = $this->mock(HelpInterface::class);
|
||||
$help->shouldReceive('hasRoute')->andReturn(true)->once();
|
||||
$help->shouldReceive('inCache')->andReturn(false)->once();
|
||||
$help->shouldReceive('getFromGithub')->andReturn('Help content here.')->once();
|
||||
$help->shouldReceive('putInCache')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('help.show', ['index']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
}
|
@ -15,5 +15,72 @@ use Tests\TestCase;
|
||||
|
||||
class HomeControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HomeController::dateRange
|
||||
* @covers \FireflyIII\Http\Controllers\HomeController::__construct
|
||||
*/
|
||||
public function testDateRange()
|
||||
{
|
||||
|
||||
$this->be($this->user());
|
||||
|
||||
$args = [
|
||||
'start' => '2012-01-01',
|
||||
'end' => '2012-04-01',
|
||||
];
|
||||
|
||||
$response = $this->post(route('daterange'), $args);
|
||||
$response->assertStatus(200);
|
||||
$response->assertSessionHas('warning', '91 days of data may take a while to load.');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HomeController::displayError
|
||||
*/
|
||||
public function testDisplayError()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('error'));
|
||||
$response->assertStatus(500);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HomeController::flush
|
||||
*/
|
||||
public function testFlush()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('flush'));
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HomeController::index
|
||||
* @covers \FireflyIII\Http\Controllers\Controller::__construct
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param $range
|
||||
*/
|
||||
public function testIndex(string $range)
|
||||
{
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('index'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\HomeController::testFlash
|
||||
*/
|
||||
public function testTestFlash()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('test-flash'));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertSessionHas('info');
|
||||
$response->assertSessionHas('warning');
|
||||
$response->assertSessionHas('error');
|
||||
}
|
||||
|
||||
}
|
@ -11,9 +11,158 @@ declare(strict_types = 1);
|
||||
|
||||
namespace Tests\Feature\Controllers;
|
||||
|
||||
use FireflyIII\Import\ImportProcedureInterface;
|
||||
use FireflyIII\Import\Setup\CsvSetup;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
|
||||
class ImportControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::complete
|
||||
*/
|
||||
public function testComplete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.complete', ['complete']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::configure
|
||||
*/
|
||||
public function testConfigure()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.configure', ['configure']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::download
|
||||
*/
|
||||
public function testDownload()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.download', ['configure']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('[]');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::finished
|
||||
*/
|
||||
public function testFinished()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.finished', ['finished']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.index'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::json
|
||||
*/
|
||||
public function testJson()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.json', ['configure']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::postConfigure
|
||||
*/
|
||||
public function testPostConfigure()
|
||||
{
|
||||
$importer = $this->mock(CsvSetup::class);
|
||||
$importer->shouldReceive('setJob')->once();
|
||||
$importer->shouldReceive('saveImportConfiguration')->once();
|
||||
|
||||
$data = [];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.process-configuration', ['p-configure']), $data);
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('import.settings', ['p-configure']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::postSettings
|
||||
*/
|
||||
public function testPostSettings()
|
||||
{
|
||||
$importer = $this->mock(CsvSetup::class);
|
||||
$importer->shouldReceive('setJob')->once();
|
||||
$importer->shouldReceive('storeSettings')->once();
|
||||
$data = [];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.post-settings', ['p-settings']), $data);
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('import.settings', ['p-settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::settings
|
||||
*/
|
||||
public function testSettings()
|
||||
{
|
||||
$importer = $this->mock(CsvSetup::class);
|
||||
$importer->shouldReceive('setJob')->once();
|
||||
$importer->shouldReceive('requireUserSettings')->once()->andReturn(false);
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.settings', ['settings']));
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('import.complete', ['settings']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::start
|
||||
*/
|
||||
public function testStart()
|
||||
{
|
||||
/** @var ImportProcedureInterface $procedure */
|
||||
$procedure = $this->mock(ImportProcedureInterface::class);
|
||||
|
||||
$procedure->shouldReceive('runImport');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('import.start', ['complete']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::status
|
||||
* Implement testStatus().
|
||||
*/
|
||||
public function testStatus()
|
||||
{
|
||||
// complete
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('import.status', ['complete']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ImportController::upload
|
||||
*/
|
||||
public function testUpload()
|
||||
{
|
||||
$path = resource_path('stubs/csv.csv');
|
||||
$file = new UploadedFile($path, 'upload.csv', filesize($path), 'text/csv', null, true);
|
||||
$response = $this->post(route('import.upload'), [], [], ['import_file' => $file], ['Accept' => 'application/json']);
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,134 @@ use Tests\TestCase;
|
||||
class JsonControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::action
|
||||
*/
|
||||
public function testAction()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.action'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxBillsPaid
|
||||
*/
|
||||
public function testBoxBillsPaid()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.paid'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxBillsUnpaid
|
||||
*/
|
||||
public function testBoxBillsUnpaid()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.unpaid'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxIn
|
||||
*/
|
||||
public function testBoxIn()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.in'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::boxOut
|
||||
*/
|
||||
public function testBoxOut()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.out'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::categories
|
||||
*/
|
||||
public function testCategories()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.categories'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::endTour
|
||||
*/
|
||||
public function testEndTour()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('json.end-tour'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::expenseAccounts
|
||||
*/
|
||||
public function testExpenseAccounts()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.expense-accounts'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::revenueAccounts
|
||||
*/
|
||||
public function testRevenueAccounts()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.revenue-accounts'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::tags
|
||||
*/
|
||||
public function testTags()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.tags'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::tour
|
||||
*/
|
||||
public function testTour()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.tour'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::transactionJournals
|
||||
*/
|
||||
public function testTransactionJournals()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.transaction-journals', ['deposit']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\JsonController::trigger
|
||||
*/
|
||||
public function testTrigger()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.trigger'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,30 @@ use Tests\TestCase;
|
||||
class NewUserControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\NewUserController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->emptyUser());
|
||||
$response = $this->get(route('new-user.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\NewUserController::submit
|
||||
*/
|
||||
public function testSubmit()
|
||||
{
|
||||
$data = [
|
||||
'bank_name' => 'New bank',
|
||||
'bank_balance' => 100,
|
||||
];
|
||||
$this->be($this->emptyUser());
|
||||
$response = $this->post(route('new-user.submit'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,215 @@ use Tests\TestCase;
|
||||
class PiggyBankControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::add
|
||||
*/
|
||||
public function testAdd()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.add', [1]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::addMobile
|
||||
*/
|
||||
public function testAddMobile()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.add-money-mobile', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.create'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$repository = $this->mock(PiggyBankRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
|
||||
$this->session(['piggy-banks.delete.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.destroy', [2]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::order
|
||||
*/
|
||||
public function testOrder()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.order', [1, 2]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
|
||||
*/
|
||||
public function testPostAdd()
|
||||
{
|
||||
$data = ['amount' => '1.123'];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.add', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('piggy-banks.index');
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the exact amount to fill a piggy bank
|
||||
*
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postAdd
|
||||
*/
|
||||
public function testPostAddExact()
|
||||
{
|
||||
// find a piggy with current amount = 0.
|
||||
$piggy = PiggyBank::leftJoin('piggy_bank_repetitions', 'piggy_bank_repetitions.piggy_bank_id', '=', 'piggy_banks.id')
|
||||
->where('currentamount', 0)
|
||||
->first(['piggy_banks.id', 'targetamount']);
|
||||
|
||||
|
||||
$data = ['amount' => strval($piggy->targetamount)];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.add', [$piggy->id]), $data);
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('piggy-banks.index');
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::postRemove
|
||||
*/
|
||||
public function testPostRemove()
|
||||
{
|
||||
$data = ['amount' => '1.123'];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.remove', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('piggy-banks.index');
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::remove
|
||||
*/
|
||||
public function testRemove()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.remove', [1]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::removeMobile
|
||||
*/
|
||||
public function testRemoveMobile()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.remove-money-mobile', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::show
|
||||
*/
|
||||
public function testShow()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('piggy-banks.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['piggy-banks.create.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'name' => 'Piggy ' . rand(999, 10000),
|
||||
'targetamount' => '100.123',
|
||||
'account_id' => 2,
|
||||
'amount_currency_id_targetamount' => 1,
|
||||
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PiggyBankController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->session(['piggy-banks.edit.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'name' => 'Updated Piggy ' . rand(999, 10000),
|
||||
'targetamount' => '100.123',
|
||||
'account_id' => 2,
|
||||
'amount_currency_id_targetamount' => 1,
|
||||
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('piggy-banks.update', [3]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('index');
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -16,4 +16,63 @@ use Tests\TestCase;
|
||||
class PreferencesControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PreferencesController::code
|
||||
*/
|
||||
public function testCode()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('preferences.code'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PreferencesController::deleteCode
|
||||
*/
|
||||
public function testDeleteCode()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('preferences.delete-code'));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$response->assertSessionHas('info');
|
||||
$this->assertRedirectedToRoute('preferences.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PreferencesController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('preferences.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\PreferencesController::postIndex
|
||||
*/
|
||||
public function testPostIndex()
|
||||
{
|
||||
$data = [
|
||||
'fiscalYearStart' => '2016-01-01',
|
||||
'frontPageAccounts' => [],
|
||||
'viewRange' => '1M',
|
||||
'customFiscalYear' => 0,
|
||||
'showDepositsFrontpage' => 0,
|
||||
'transactionPageSize' => 100,
|
||||
'twoFactorAuthEnabled' => 0,
|
||||
'language' => 'en_US',
|
||||
'tj' => [],
|
||||
];
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('preferences.update'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('preferences.index');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,72 @@ use Tests\TestCase;
|
||||
class ProfileControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::changePassword
|
||||
*/
|
||||
public function testChangePassword()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('profile.change-password'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::deleteAccount
|
||||
*/
|
||||
public function testDeleteAccount()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('profile.delete-account'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('profile.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postChangePassword
|
||||
*/
|
||||
public function testPostChangePassword()
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('changePassword');
|
||||
|
||||
$data = [
|
||||
'current_password' => 'james',
|
||||
'new_password' => 'james2',
|
||||
'new_password_confirmation' => 'james2',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('profile.change-password.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ProfileController::postDeleteAccount
|
||||
*/
|
||||
public function testPostDeleteAccount()
|
||||
{
|
||||
$repository = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy');
|
||||
$data = [
|
||||
'password' => 'james',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('profile.delete-account.post'), $data);
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('index');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,79 @@ use Tests\TestCase;
|
||||
class ReportControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::auditReport
|
||||
*/
|
||||
public function testAuditReport()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.report.audit', [1, '20160101', '20160131']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::budgetReport
|
||||
*/
|
||||
public function testBudgetReport()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.report.budget', [1, 1, '20160101', '20160131']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::categoryReport
|
||||
*/
|
||||
public function testCategoryReport()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.report.category', [1, 1, '20160101', '20160131']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::defaultReport
|
||||
*/
|
||||
public function testDefaultReport()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.report.default', [1, '20160101', '20160131']));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::options
|
||||
*/
|
||||
public function testOptions()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('reports.options', ['default']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\ReportController::postIndex
|
||||
*/
|
||||
public function testPostIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('reports.index.post'));
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,202 @@ use Tests\TestCase;
|
||||
class RuleControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.create', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy');
|
||||
|
||||
$this->session(['rules.delete.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rules.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::down
|
||||
*/
|
||||
public function testDown()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.down', [1]));
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('rules.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::reorderRuleActions
|
||||
*/
|
||||
public function testReorderRuleActions()
|
||||
{
|
||||
$data = [
|
||||
'triggers' => [1, 2, 3],
|
||||
];
|
||||
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$repository->shouldReceive('reorderRuleActions');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rules.reorder-actions', [1]), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::reorderRuleTriggers
|
||||
*/
|
||||
public function testReorderRuleTriggers()
|
||||
{
|
||||
$data = [
|
||||
'triggers' => [1, 2, 3],
|
||||
];
|
||||
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$repository->shouldReceive('reorderRuleTriggers');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rules.reorder-triggers', [1]), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['rules.create.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'rule_group_id' => 1,
|
||||
'active' => 1,
|
||||
'title' => 'A',
|
||||
'trigger' => 'store-journal',
|
||||
'description' => 'D',
|
||||
'rule-trigger' => [
|
||||
1 => 'from_account_starts',
|
||||
],
|
||||
'rule-trigger-value' => [
|
||||
1 => 'B',
|
||||
],
|
||||
'rule-action' => [
|
||||
1 => 'set_category',
|
||||
],
|
||||
'rule-action-value' => [
|
||||
1 => 'C',
|
||||
],
|
||||
];
|
||||
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$repository->shouldReceive('store')->andReturn(new Rule);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rules.store', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* This actually hits an error and not the actually code but OK.
|
||||
*
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::testTriggers
|
||||
*/
|
||||
public function testTestTriggers()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.test-triggers', [1]));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::up
|
||||
*/
|
||||
public function testUp()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rules.up', [1]));
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('rules.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$data = [
|
||||
'rule_group_id' => 1,
|
||||
'title' => 'Your first default rule',
|
||||
'trigger' => 'store-journal',
|
||||
'active' => 1,
|
||||
'description' => 'This rule is an example. You can safely delete it.',
|
||||
'rule-trigger' => [
|
||||
1 => 'description_is',
|
||||
],
|
||||
'rule-trigger-value' => [
|
||||
1 => 'something',
|
||||
],
|
||||
'rule-action' => [
|
||||
1 => 'prepend_description',
|
||||
],
|
||||
'rule-action-value' => [
|
||||
1 => 'Bla bla',
|
||||
],
|
||||
];
|
||||
$this->session(['rules.edit.url' => 'http://localhost']);
|
||||
|
||||
$repository = $this->mock(RuleRepositoryInterface::class);
|
||||
$repository->shouldReceive('update');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rules.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,146 @@ use Tests\TestCase;
|
||||
class RuleGroupControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rule-groups.create'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rule-groups.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy');
|
||||
|
||||
$this->session(['rule-groups.delete.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rule-groups.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::down
|
||||
*/
|
||||
public function testDown()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rule-groups.down', [1]));
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('rules.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rule-groups.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::execute
|
||||
*/
|
||||
public function testExecute()
|
||||
{
|
||||
$this->session(['first' => new Carbon('2010-01-01')]);
|
||||
$data = [
|
||||
'accounts' => [1],
|
||||
'start_date' => '2010-01-02',
|
||||
'end_date' => '2010-01-02',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rule-groups.execute', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
$this->assertRedirectedToRoute('rules.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::selectTransactions
|
||||
*/
|
||||
public function testSelectTransactions()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rule-groups.select-transactions', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['rule-groups.create.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'title' => 'A',
|
||||
'description' => '',
|
||||
];
|
||||
|
||||
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('store')->andReturn(new RuleGroup);
|
||||
$repository->shouldReceive('find')->andReturn(new RuleGroup);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rule-groups.store', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::up
|
||||
*/
|
||||
public function testUp()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('rule-groups.up', [1]));
|
||||
$response->assertStatus(302);
|
||||
$this->assertRedirectedToRoute('rules.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\RuleGroupController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$data = [
|
||||
'title' => 'C',
|
||||
'description' => 'XX',
|
||||
];
|
||||
$this->session(['rule-groups.edit.url' => 'http://localhost']);
|
||||
|
||||
$repository = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new RuleGroup);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('rule-groups.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,23 @@ use Tests\TestCase;
|
||||
class SearchControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\SearchController::index
|
||||
* Implement testIndex().
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$search = $this->mock(SearchInterface::class);
|
||||
$search->shouldReceive('setLimit')->once();
|
||||
$search->shouldReceive('searchTransactions')->andReturn(new Collection)->withArgs([['test']])->once();
|
||||
$search->shouldReceive('searchBudgets')->andReturn(new Collection)->withArgs([['test']])->once();
|
||||
$search->shouldReceive('searchTags')->andReturn(new Collection)->withArgs([['test']])->once();
|
||||
$search->shouldReceive('searchCategories')->andReturn(new Collection)->withArgs([['test']])->once();
|
||||
$search->shouldReceive('searchAccounts')->andReturn(new Collection)->withArgs([['test']])->once();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('search.index') . '?q=test');
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,109 @@ use Tests\TestCase;
|
||||
class TagControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::create
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('tags.create'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::delete
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('tags.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::destroy
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
$repository = $this->mock(TagRepositoryInterface::class);
|
||||
$repository->shouldReceive('destroy');
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('tags.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::edit
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('tags.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('tags.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::show
|
||||
*/
|
||||
public function testShow()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('tags.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::store
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
$this->session(['tags.create.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'tag' => 'Hello new tag' . rand(999, 10000),
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('tags.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TagController::update
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
$this->session(['tags.edit.url' => 'http://localhost']);
|
||||
$data = [
|
||||
'tag' => 'Hello updated tag' . rand(999, 10000),
|
||||
'tagMode' => 'nothing',
|
||||
];
|
||||
$repository = $this->mock(TagRepositoryInterface::class);
|
||||
$repository->shouldReceive('update');
|
||||
$repository->shouldReceive('find')->andReturn(new Tag);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('tags.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
@ -16,4 +16,65 @@ use Tests\TestCase;
|
||||
class TransactionControllerTest extends TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::index
|
||||
*/
|
||||
public function testIndex()
|
||||
{
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index', ['transfer']));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::indexAll
|
||||
*/
|
||||
public function testIndexAll()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index.all', ['transfer']));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::indexByDate
|
||||
*/
|
||||
public function testIndexByDate()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.index.date', ['transfer', '2016-01-01']));
|
||||
$response->assertStatus(200);
|
||||
// has bread crumb
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::reorder
|
||||
*/
|
||||
public function testReorder()
|
||||
{
|
||||
$data = [
|
||||
'items' => [],
|
||||
];
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('transactions.reorder'), $data);
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\TransactionController::show
|
||||
*/
|
||||
public function testShow()
|
||||
{
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('transactions.show', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
}
|
@ -2,12 +2,13 @@
|
||||
|
||||
namespace Tests;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use FireflyIII\Models\Preference;
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Class TestCase
|
||||
*
|
||||
@ -17,16 +18,6 @@ abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user = User::find(1);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @param string $range
|
||||
@ -56,21 +47,6 @@ abstract class TestCase extends BaseTestCase
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return \Mockery\MockInterface
|
||||
*/
|
||||
protected function mock($class)
|
||||
{
|
||||
Log::debug(sprintf('Will now mock %s', $class));
|
||||
$object = Mockery::mock($class);
|
||||
$this->app->instance($class, $object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@ -87,4 +63,38 @@ abstract class TestCase extends BaseTestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function emptyUser()
|
||||
{
|
||||
$user = User::find(2);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function user()
|
||||
{
|
||||
$user = User::find(1);
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return \Mockery\MockInterface
|
||||
*/
|
||||
protected function mock($class)
|
||||
{
|
||||
Log::debug(sprintf('Will now mock %s', $class));
|
||||
$object = Mockery::mock($class);
|
||||
$this->app->instance($class, $object);
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user