mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-20 11:48:27 -06:00
Update tests, fixes some bugs.
This commit is contained in:
parent
ec3b356f86
commit
b4eac84097
@ -58,7 +58,7 @@ class MassController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function massDelete(Collection $journals)
|
||||
public function delete(Collection $journals)
|
||||
{
|
||||
$subTitle = trans('firefly.mass_delete_journals');
|
||||
|
||||
@ -77,7 +77,7 @@ class MassController extends Controller
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function massDestroy(MassDeleteJournalRequest $request, JournalRepositoryInterface $repository)
|
||||
public function destroy(MassDeleteJournalRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
$ids = $request->get('confirm_mass_delete');
|
||||
$set = new Collection;
|
||||
@ -114,7 +114,7 @@ class MassController extends Controller
|
||||
*
|
||||
* @return View
|
||||
*/
|
||||
public function massEdit(Collection $journals)
|
||||
public function edit(Collection $journals)
|
||||
{
|
||||
$subTitle = trans('firefly.mass_edit_journals');
|
||||
|
||||
@ -187,7 +187,7 @@ class MassController extends Controller
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function massUpdate(MassEditJournalRequest $request, JournalRepositoryInterface $repository)
|
||||
public function update(MassEditJournalRequest $request, JournalRepositoryInterface $repository)
|
||||
{
|
||||
$journalIds = $request->get('journals');
|
||||
$count = 0;
|
||||
|
@ -27,6 +27,7 @@ use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
|
||||
/**
|
||||
* HOME
|
||||
@ -652,6 +653,29 @@ Breadcrumbs::register(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* MASS TRANSACTION EDIT / DELETE
|
||||
*/
|
||||
Breadcrumbs::register(
|
||||
'transactions.mass.edit', function (BreadCrumbGenerator $breadcrumbs, Collection $journals) {
|
||||
|
||||
$journalIds = $journals->pluck('id')->toArray();
|
||||
$what = strtolower($journals->first()->transactionType->type);
|
||||
$breadcrumbs->parent('transactions.index', $what);
|
||||
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.edit', $journalIds));
|
||||
}
|
||||
);
|
||||
|
||||
Breadcrumbs::register(
|
||||
'transactions.mass.delete', function (BreadCrumbGenerator $breadcrumbs, Collection $journals) {
|
||||
|
||||
$journalIds = $journals->pluck('id')->toArray();
|
||||
$what = strtolower($journals->first()->transactionType->type);
|
||||
$breadcrumbs->parent('transactions.index', $what);
|
||||
$breadcrumbs->push(trans('firefly.mass_edit_journals'), route('transactions.mass.delete', $journalIds));
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* SPLIT
|
||||
|
@ -113,8 +113,8 @@ class JournalTasker implements JournalTaskerInterface
|
||||
|
||||
/** @var Transaction $entry */
|
||||
foreach ($set as $entry) {
|
||||
$sourceBalance = $this->getBalance($entry->id);
|
||||
$destinationBalance = $this->getBalance($entry->destination_id);
|
||||
$sourceBalance = $this->getBalance(intval($entry->id));
|
||||
$destinationBalance = $this->getBalance(intval($entry->destination_id));
|
||||
$budget = $entry->budgets->first();
|
||||
$category = $entry->categories->first();
|
||||
$transaction = [
|
||||
|
@ -1,11 +1,11 @@
|
||||
{% extends "./layout/default" %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journals) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form method="POST" action="{{ route('transactions.mass-destroy') }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">
|
||||
<form method="POST" action="{{ route('transactions.mass.destroy') }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">
|
||||
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||
|
||||
<div class="row">
|
||||
|
@ -1,11 +1,11 @@
|
||||
{% extends "./layout/default" %}
|
||||
|
||||
{% block breadcrumbs %}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName) }}
|
||||
{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, journals) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<form method="POST" action="{{ route('transactions.mass-update') }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">
|
||||
<form method="POST" action="{{ route('transactions.mass.update') }}" accept-charset="UTF-8" class="form-horizontal" id="destroy">
|
||||
<input name="_token" type="hidden" value="{{ csrf_token() }}">
|
||||
|
||||
<div class="row">
|
||||
|
@ -228,9 +228,11 @@ Route::group(
|
||||
Route::get('expense', ['uses' => 'AccountController@expenseAccounts', 'as' => 'expense']);
|
||||
Route::get('revenue', ['uses' => 'AccountController@revenueAccounts', 'as' => 'revenue']);
|
||||
Route::get('report/{accountList}/{start_date}/{end_date}', ['uses' => 'AccountController@report', 'as' => 'report']);
|
||||
Route::get('all/{account}', ['uses' => 'AccountController@period', 'as' => 'all']); // TODO
|
||||
Route::get('single/{account}', ['uses' => 'AccountController@single', 'as' => 'single']);
|
||||
Route::get('period/{account}/{date}', ['uses' => 'AccountController@period', 'as' => 'period']);
|
||||
|
||||
|
||||
Route::get('income-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@incomeCategory', 'as' => 'income-category']);
|
||||
Route::get('expense-category/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseCategory', 'as' => 'expense-category']);
|
||||
Route::get('expense-budget/{account}/{start_date}/{end_date}', ['uses' => 'AccountController@expenseBudget', 'as' => 'expense-budget']);
|
||||
@ -307,8 +309,8 @@ Route::group(
|
||||
* Chart\PiggyBank Controller
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'Chart', 'prefix' => 'chart/piggy-bank','as'=> 'chart.piggy-bank.'], function () {
|
||||
Route::get('{piggyBank}', ['uses' => 'PiggyBankController@history','as' => 'history']);
|
||||
['middleware' => 'user-full-auth', 'namespace' => 'Chart', 'prefix' => 'chart/piggy-bank', 'as' => 'chart.piggy-bank.'], function () {
|
||||
Route::get('{piggyBank}', ['uses' => 'PiggyBankController@history', 'as' => 'history']);
|
||||
}
|
||||
);
|
||||
|
||||
@ -593,9 +595,11 @@ Route::group(
|
||||
*/
|
||||
Route::group(
|
||||
['middleware' => 'user-full-auth', 'prefix' => 'transactions', 'as' => 'transactions.'], function () {
|
||||
Route::get('{what}', ['uses' => 'TransactionController@index', 'as' => 'index'])->where(['what' => 'withdrawal|deposit|transfers']);
|
||||
Route::get('{what}/all', ['uses' => 'TransactionController@indexAll', 'as' => 'index.all'])->where(['what' => 'withdrawal|deposit|transfers']);
|
||||
Route::get('{what}/{date}', ['uses' => 'TransactionController@indexByDate', 'as' => 'index.date'])->where(['what' => 'withdrawal|deposit|transfers']);
|
||||
Route::get('{what}', ['uses' => 'TransactionController@index', 'as' => 'index'])->where(['what' => 'withdrawal|deposit|transfers|transfer']);
|
||||
Route::get('{what}/all', ['uses' => 'TransactionController@indexAll', 'as' => 'index.all'])->where(['what' => 'withdrawal|deposit|transfers|transfer']);
|
||||
Route::get('{what}/{date}', ['uses' => 'TransactionController@indexByDate', 'as' => 'index.date'])->where(
|
||||
['what' => 'withdrawal|deposit|transfers|transfer']
|
||||
);
|
||||
Route::get('show/{tj}', ['uses' => 'TransactionController@show', 'as' => 'show']);
|
||||
Route::post('reorder', ['uses' => 'TransactionController@reorder', 'as' => 'reorder']);
|
||||
}
|
||||
|
@ -30,58 +30,81 @@ class MassControllerTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::massDelete
|
||||
* Implement testMassDelete().
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::delete
|
||||
*/
|
||||
public function testMassDelete()
|
||||
public function testDelete()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->call('get', route('transactions.mass.delete', [561, 562]));
|
||||
$this->assertResponseStatus(200);
|
||||
$this->see('Delete a number of transactions');
|
||||
// has bread crumb
|
||||
$this->see('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::massDestroy
|
||||
* Implement testMassDestroy().
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::destroy
|
||||
*/
|
||||
public function testMassDestroy()
|
||||
public function testDestroy()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->session(['transactions.mass-delete.url' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'confirm_mass_delete' => [56, 37],
|
||||
];
|
||||
$this->be($this->user());
|
||||
$this->call('post', route('transactions.mass.destroy'), $data);
|
||||
$this->assertSessionHas('success');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
// visit them should give 404.
|
||||
$this->call('get', route('transactions.show', [56]));
|
||||
$this->assertResponseStatus(404);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::massEdit
|
||||
* Implement testMassEdit().
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::edit
|
||||
*/
|
||||
public function testMassEdit()
|
||||
public function testEdit()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->call('get', route('transactions.mass.delete', [132, 113]));
|
||||
$this->assertResponseStatus(200);
|
||||
$this->see('Edit a number of transactions');
|
||||
// has bread crumb
|
||||
$this->see('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::massUpdate
|
||||
* Implement testMassUpdate().
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\MassController::update
|
||||
*/
|
||||
public function testMassUpdate()
|
||||
public function testUpdate()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
|
||||
$this->session(['transactions.mass-edit.url' => 'http://localhost']);
|
||||
|
||||
$data = [
|
||||
'journals' => [132],
|
||||
'description' => [132 => 'Updated salary thing'],
|
||||
'amount' => [132 => 1600],
|
||||
'amount_currency_id_amount_132' => 1,
|
||||
'date' => [132 => '2014-07-24'],
|
||||
'source_account_name' => [132 => 'Job'],
|
||||
'destination_account_id' => [132 => 1],
|
||||
'category' => [132 => 'Salary'],
|
||||
];
|
||||
|
||||
$this->be($this->user());
|
||||
$this->call('post', route('transactions.mass.update', [132]), $data);
|
||||
$this->assertSessionHas('success');
|
||||
$this->assertResponseStatus(302);
|
||||
|
||||
// visit them should show updated content
|
||||
$this->call('get', route('transactions.show', [132]));
|
||||
$this->assertResponseStatus(200);
|
||||
$this->see('Updated salary thing');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Transaction;
|
||||
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use TestCase;
|
||||
|
||||
/**
|
||||
@ -31,81 +33,110 @@ class SingleControllerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::create
|
||||
* Implement testCreate().
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->call('get', route('transactions.create', ['withdrawal']));
|
||||
$this->assertResponseStatus(200);
|
||||
// has bread crumb
|
||||
$this->see('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::delete
|
||||
* Implement testDelete().
|
||||
*/
|
||||
public function testDelete()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->call('get', route('transactions.delete', [12]));
|
||||
$this->assertResponseStatus(200);
|
||||
// has bread crumb
|
||||
$this->see('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::destroy
|
||||
* Implement testDestroy().
|
||||
*/
|
||||
public function testDestroy()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->session(['transactions.delete.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository->shouldReceive('first')->once()->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('delete')->once();
|
||||
|
||||
$this->call('post', route('transactions.destroy', [13]));
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::edit
|
||||
* Implement testEdit().
|
||||
*/
|
||||
public function testEdit()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->be($this->user());
|
||||
$this->call('get', route('transactions.edit', [13]));
|
||||
$this->assertResponseStatus(200);
|
||||
// has bread crumb
|
||||
$this->see('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::store
|
||||
* Implement testStore().
|
||||
*/
|
||||
public function testStore()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->session(['transactions.create.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
|
||||
$data = [
|
||||
'what' => 'withdrawal',
|
||||
'amount' => 10,
|
||||
'amount_currency_id_amount' => 1,
|
||||
'source_account_id' => 1,
|
||||
'destination_account_name' => 'Some destination',
|
||||
'date' => '2016-01-01',
|
||||
'description' => 'Some description',
|
||||
];
|
||||
$this->call('post', route('transactions.store', ['withdrawal']), $data);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Transaction\SingleController::update
|
||||
* Implement testUpdate().
|
||||
*/
|
||||
public function testUpdate()
|
||||
{
|
||||
// Remove the following lines when you implement this test.
|
||||
$this->markTestIncomplete(
|
||||
'This test has not been implemented yet.'
|
||||
);
|
||||
$this->session(['transactions.edit.url' => 'http://localhost']);
|
||||
$this->be($this->user());
|
||||
$data = [
|
||||
'id' => 123,
|
||||
'what' => 'withdrawal',
|
||||
'description' => 'Updated groceries',
|
||||
'source_account_id' => 1,
|
||||
'destination_account_name' => 'PLUS',
|
||||
'amount' => 123,
|
||||
'amount_currency_id_amount' => 1,
|
||||
'budget_id' => 1,
|
||||
'category' => 'Daily groceries',
|
||||
'tags' => '',
|
||||
'date' => '2016-01-01',
|
||||
];
|
||||
|
||||
$this->call('post', route('transactions.update', [123]), $data);
|
||||
$this->assertResponseStatus(302);
|
||||
$this->assertSessionHas('success');
|
||||
|
||||
$this->call('get', route('transactions.show', [123]));
|
||||
$this->assertResponseStatus(200);
|
||||
$this->see('Updated groceries');
|
||||
// has bread crumb
|
||||
$this->see('<ol class="breadcrumb">');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tears down the fixture, for example, closes a network connection.
|
||||
* This method is called after a test is executed.
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user