Fixed some tests.

This commit is contained in:
James Cole 2015-06-28 08:24:12 +02:00
parent 4673170531
commit e4e2921f3e
30 changed files with 49 additions and 153 deletions

View File

@ -40,4 +40,4 @@ interface AccountChartGenerator
* @return array
*/
public function single(Account $account, Carbon $start, Carbon $end);
}
}

View File

@ -110,4 +110,4 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
return $data;
}
}
}

View File

@ -119,4 +119,4 @@ class GoogleAccountChartGenerator implements AccountChartGenerator
return $chart->getData();
}
}
}

View File

@ -29,4 +29,4 @@ interface BillChartGenerator
*/
public function frontpage(Collection $paid, Collection $unpaid);
}
}

View File

@ -80,4 +80,4 @@ class ChartJsBillChartGenerator implements BillChartGenerator
public function single(Bill $bill, Collection $entries)
{
}
}
}

View File

@ -84,4 +84,4 @@ class GoogleBillChartGenerator implements BillChartGenerator
return $chart->getData();
}
}
}

View File

@ -40,4 +40,4 @@ interface BudgetChartGenerator
*/
public function year(Collection $budgets, Collection $entries);
}
}

View File

@ -138,4 +138,4 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
return $data;
}
}
}

View File

@ -107,4 +107,4 @@ class GoogleBudgetChartGenerator implements BudgetChartGenerator
return $chart->getData();
}
}
}

View File

@ -41,4 +41,4 @@ interface CategoryChartGenerator
* @return array
*/
public function year(Collection $categories, Collection $entries);
}
}

View File

@ -112,4 +112,4 @@ class ChartJsCategoryChartGenerator implements CategoryChartGenerator
return $data;
}
}
}

View File

@ -101,4 +101,4 @@ class GoogleCategoryChartGenerator implements CategoryChartGenerator
return $chart->getData();
}
}
}

View File

@ -49,4 +49,4 @@ class ChartJsPiggyBankChartGenerator implements PiggyBankChartGenerator
return $data;
}
}
}

View File

@ -38,4 +38,4 @@ class GooglePiggyBankChartGenerator implements PiggyBankChartGenerator
return $chart->getData();
}
}
}

View File

@ -17,4 +17,4 @@ interface PiggyBankChartGenerator
* @return array
*/
public function history(Collection $set);
}
}

View File

@ -84,4 +84,4 @@ class ChartJsReportChartGenerator implements ReportChartGenerator
$data['datasets'][1]['data'][] = round(($expense / $count), 2);
return $data;
}
}
}

View File

@ -55,4 +55,4 @@ class GoogleReportChartGenerator implements ReportChartGenerator
return $chart->getData();
}
}
}

View File

@ -28,4 +28,4 @@ interface ReportChartGenerator
*/
public function yearInOutSummarized($income, $expense, $count);
}
}

View File

@ -95,11 +95,6 @@ $(function () {
$('input[type="number"]').on('input', updateBudgetedAmounts);
//updateRanges();
//$('input[type="range"]').on('input', updateSingleRange);
//$('input[type="number"]').on('input', updateSingleRange);
/*
Draw the charts, if necessary:
*/
@ -112,87 +107,7 @@ $(function () {
});
//function updateSingleRange(e) {
// "use strict";
// // get some values:
// var input = $(e.target);
// var id = input.data('id');
// var value = parseInt(input.val());
// var spent = parseFloat($('#spent-' + id).data('value'));
//
// // update small display:
// if (value > 0) {
// // show the input:
// $('#budget-info-' + id + ' span').show();
// $('#budget-info-' + id + ' input').show();
//
// // update the text:
// $('#budget-description-' + id).text('Budgeted: ');
// } else {
// // hide the input:
// $('#budget-info-' + id + ' span').hide();
// $('#budget-info-' + id + ' input').hide();
//
// // update the text:
// $('#budget-description-' + id).html('<em>No budget</em>');
// }
//
// // update the range display text:
// $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
//
// // send a post to Firefly to update the amount:
// $.post('budgets/amount/' + id, {amount: value, _token: token}).success(function (data) {
// // update the link if relevant:
// $('#budget-link-' + id).attr('href', 'budgets/show/' + id + '/' + data.repetition);
// });
// if (input.attr('type') === 'number') {
// // update the range-input:
// $('#budget-range-' + id).val(value);
// } else {
// // update the number-input:
// $('#budget-info-' + id + ' input').val(value);
// }
//
// // update or hide the bar, whichever is necessary.
// updateTotal();
// return value;
//}
//
//function updateTotal() {
// "use strict";
// var sum = 0;
// $('input[type="range"]').each(function (i, v) {
// // get some values:
// sum += parseInt($(v).val());
// });
//
// /**
// * Update total sum:
// */
// var totalAmount = parseInt($('#totalAmount').data('value'));
// var pct;
// if (sum <= totalAmount) {
// pct = sum / totalAmount * 100;
// $('#progress-bar-default').css('width', pct + '%');
// $('#progress-bar-warning').css('width', '0');
// $('#progress-bar-danger').css('width', '0');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger');
// } else {
// // we gaan er X overheen,
//
// pct = totalAmount / sum * 100;
// var danger = 100 - pct;
// var err = 100 - danger;
// $('#progress-bar-default').css('width', 0);
// $('#progress-bar-warning').css('width', err + '%');
// $('#progress-bar-danger').css('width', danger + '%');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success');
// }
//
//}
//
function updateIncome(e) {
function updateIncome() {
"use strict";
$('#defaultModal').empty().load('budgets/income', function () {
$('#defaultModal').modal('show');
@ -200,51 +115,3 @@ function updateIncome(e) {
return false;
}
//
//function updateRanges() {
// "use strict";
//
//
// var sum = 0;
// $('input[type="range"]').each(function (i, v) {
// // get some values:
// var input = $(v);
// var id = input.data('id');
// var value = parseInt(input.val());
//
// // calculate sum:
// sum += value;
//
// // update small display:
// $('#budget-range-display-' + id).text('\u20AC ' + value.toFixed(2));
//
// // send a post to Firefly to update the amount:
// $.post('budgets/amount/' + id, {amount: value, _token: token});
//
// });
//
// /**
// * Update total sum:
// */
// var totalAmount = parseInt($('#totalAmount').data('value'));
// var pct;
// if (sum <= totalAmount) {
// pct = sum / totalAmount * 100;
// $('#progress-bar-default').css('width', pct + '%');
// $('#progress-bar-warning').css('width', '0');
// $('#progress-bar-danger').css('width', '0');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-success').removeClass('text-danger');
// } else {
// // we gaan er X overheen,
//
// pct = totalAmount / sum * 100;
// var danger = 100 - pct;
// var err = 100 - danger;
// $('#progress-bar-default').css('width', 0);
// $('#progress-bar-warning').css('width', err + '%');
// $('#progress-bar-danger').css('width', danger + '%');
// $('#budgetedAmount').text('\u20AC ' + sum.toFixed(2)).addClass('text-danger').removeClass('text-success');
// }
//
//
//}

View File

@ -254,4 +254,4 @@
<script type="text/javascript" src="js/index.js"></script>
{% endblock %}
{% block styles %}
{% endblock %}
{% endblock %}

View File

@ -81,6 +81,7 @@ class AccountControllerTest extends TestCase
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
@ -152,6 +153,7 @@ class AccountControllerTest extends TestCase
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
// get edit page:
$this->call('GET', '/accounts/edit/' . $this->account->id);
@ -182,6 +184,7 @@ class AccountControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('');
Amount::shouldReceive('getCurrencyCode')->andReturn('A');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
// put stuff in session:
@ -204,6 +207,7 @@ class AccountControllerTest extends TestCase
// mock!
Amount::shouldReceive('getCurrencyCode')->andReturn('A');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface');
$repository->shouldReceive('getJournals')->andReturn(new LengthAwarePaginator([], 0, 10));

View File

@ -52,6 +52,7 @@ class BillControllerTest extends TestCase
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/bills/create');
$this->assertViewHas('subTitle', 'Create new bill');
@ -101,6 +102,7 @@ class BillControllerTest extends TestCase
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/bills/edit/' . $bill->id);
$this->assertViewHas('subTitle', 'Edit bill "' . e($bill->name) . '"');
@ -120,6 +122,7 @@ class BillControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('XX');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface');
$repository->shouldReceive('getBills')->once()->andReturn($collection);
@ -190,6 +193,7 @@ class BillControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('XX');
Amount::shouldReceive('formatJournal')->andReturn('XX');
Amount::shouldReceive('getCurrencyCode')->andReturn('XX');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/bills/show/' . $bill->id);

View File

@ -156,6 +156,7 @@ class BudgetControllerTest extends TestCase
Amount::shouldReceive('getCurrencySymbol')->andReturn('x');
Amount::shouldReceive('format')->andReturn('x');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
$this->call('GET', '/budgets');
@ -221,6 +222,7 @@ class BudgetControllerTest extends TestCase
$paginator = new LengthAwarePaginator(new Collection, 0, 20, 1);
Amount::shouldReceive('getCurrencyCode')->andReturn('x');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('format')->andReturn('x');
$repository->shouldReceive('getJournals')->andReturn($paginator);
$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
@ -247,6 +249,7 @@ class BudgetControllerTest extends TestCase
$this->be($otherBudget->user);
Amount::shouldReceive('getCurrencyCode')->andReturn('x');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('format')->andReturn('x');
$repository->shouldReceive('getJournals')->andReturn(new Collection);
$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
@ -271,6 +274,7 @@ class BudgetControllerTest extends TestCase
$paginator = new LengthAwarePaginator(new Collection, 0, 20, 1);
Amount::shouldReceive('getCurrencyCode')->andReturn('x');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('format')->andReturn('x');
$repository->shouldReceive('getJournals')->andReturn($paginator);
$repository->shouldReceive('getBudgetLimits')->andReturn(new Collection);
@ -412,6 +416,7 @@ class BudgetControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);

View File

@ -107,6 +107,7 @@ class CategoryControllerTest extends TestCase
$collection->push($category);
Amount::shouldReceive('getCurrencyCode')->andReturn('xx');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
$repository->shouldReceive('getCategories')->andReturn($collection);
@ -129,6 +130,7 @@ class CategoryControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('xx');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$repository = $this->mock('FireflyIII\Repositories\Category\CategoryRepositoryInterface');
@ -159,6 +161,7 @@ class CategoryControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('xx');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('formatJournal')->andReturn('xx');
$this->call('GET', '/categories/show/' . $category->id);

View File

@ -119,6 +119,7 @@ class HomeControllerTest extends TestCase
Amount::shouldReceive('getCurrencyCode')->andReturn('EUR');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('format')->andReturn('xxx');
Amount::shouldReceive('formatJournal')->with($journal)->andReturn('xxx');

View File

@ -61,6 +61,7 @@ class JsonControllerTest extends TestCase
$accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Steam::shouldReceive('balance')->andReturn(0);
@ -92,6 +93,7 @@ class JsonControllerTest extends TestCase
$accounts->shouldReceive('getCreditCards')->andReturn($ccs);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Steam::shouldReceive('balance')->andReturn(-1);
$this->call('GET', '/json/box/bills-unpaid');
@ -110,6 +112,7 @@ class JsonControllerTest extends TestCase
$repository->shouldReceive('incomeInPeriodCorrected')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/json/box/in');
$this->assertResponseOk();
@ -127,6 +130,7 @@ class JsonControllerTest extends TestCase
$repository->shouldReceive('expenseInPeriodCorrected')->andReturn(new Collection);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/json/box/out');
$this->assertResponseOk();

View File

@ -47,6 +47,8 @@ class NewUserControllerTest extends TestCase
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/new-user');
$this->assertResponseStatus(200);

View File

@ -58,6 +58,7 @@ class PiggyBankControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('XXxx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/piggy-banks/add/' . $piggyBank->id);
$this->assertResponseOk();
@ -208,6 +209,7 @@ class PiggyBankControllerTest extends TestCase
$accounts->shouldReceive('leftOnAccount')->andReturn(12);
Amount::shouldReceive('format')->andReturn('123');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('GET', '/piggy-banks');
@ -254,6 +256,7 @@ class PiggyBankControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe']);
$this->assertResponseStatus(302);
@ -273,6 +276,7 @@ class PiggyBankControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('something');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
$this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']);
$this->assertResponseStatus(302);

View File

@ -59,6 +59,7 @@ class PreferencesControllerTest extends TestCase
Preferences::shouldReceive('get')->withArgs(['currencyPreference', 'EUR'])->andReturn($pref);
Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection);
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);

View File

@ -339,6 +339,7 @@ class TransactionControllerTest extends TestCase
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X');
Amount::shouldReceive('getCurrencySymbol')->andReturn('X');
Amount::shouldReceive('formatTransaction')->andReturn('X');
Amount::shouldReceive('format')->andReturn('X');