diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 733e08f544..daa31181b4 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -8,6 +8,7 @@ use FireflyIII\Models\Budget; use FireflyIII\Models\BudgetLimit; use FireflyIII\Models\LimitRepetition; use FireflyIII\Repositories\Budget\BudgetRepositoryInterface; +use Illuminate\Support\Collection; use Input; use Preferences; use Redirect; @@ -190,7 +191,9 @@ class BudgetController extends Controller $journals = $repository->getJournals($budget, $repetition); $limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget); $subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); - $journals->setPath('/budgets/show/'.$budget->id); + if (!$journals instanceof Collection) { + $journals->setPath('/budgets/show/' . $budget->id); + } return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); } diff --git a/app/Support/Amount.php b/app/Support/Amount.php index aed7c6bfcb..db7aecb52c 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -160,12 +160,15 @@ class Amount $currencyPreference = Prefs::get('currencyPreference', 'EUR'); $currency = TransactionCurrency::whereCode($currencyPreference->data)->first(); + if ($currency) { - \Cache::forever('FFCURRENCYCODE', $currency->code); + Cache::forever('FFCURRENCYCODE', $currency->code); + define('FFCURRENCYCODE', $currency->code); - define('FFCURRENCYCODE', $currency->code); + return $currency->code; + } - return $currency->code; + return 'EUR'; } public function getDefaultCurrency() diff --git a/phpunit.xml b/phpunit.xml index b1eba9eb5a..076f2928e3 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -7,7 +7,7 @@ convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" - stopOnFailure="false" + stopOnFailure="true" syntaxCheck="false"> diff --git a/resources/twig/categories/edit.twig b/resources/twig/categories/edit.twig new file mode 100644 index 0000000000..b35cfbe9ff --- /dev/null +++ b/resources/twig/categories/edit.twig @@ -0,0 +1,44 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, category) }} +{{ Form.model(category, {'class' : 'form-horizontal','id' : 'update','url' : route('categories.update',category.id)}) }} + +
+
+
+
+ Mandatory fields +
+
+ {{ ExpandedForm.text('name') }} +
+
+ +
+
+ + + +
+
+ Options +
+
+ {{ ExpandedForm.optionsList('update','category') }} +
+
+ +
+
+
+
+

+ +

+
+
+ + +{% endblock %} diff --git a/resources/twig/error.twig b/resources/twig/error.twig new file mode 100644 index 0000000000..edbee43c63 --- /dev/null +++ b/resources/twig/error.twig @@ -0,0 +1,18 @@ +{% extends "./layout/guest.twig" %} + +{% block content %} + +
+
+

Firefly
+ Error +

+
+
+ +
+
+ {{ message |default('General unknown errror') }} +
+
+{% endblock %} diff --git a/tests/TestCase.php b/tests/TestCase.php index cc436f7446..9c2541fa8f 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,5 +1,7 @@ code = 'EUR'; + $currency->save(); + Log::debug('Created new EUR currency.'); } else { if (file_exists($copy)) { copy($copy, $original); @@ -45,7 +57,16 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase } // if the database copy does exists, copy back as original. - FactoryMuffin::loadFactories(__DIR__ . '/factories'); + $this->session( + [ + 'start' => Carbon::now()->startOfMonth(), + 'end' => Carbon::now()->endOfMonth(), + 'first' => Carbon::now()->startOfYear() + ] + ); + + + } diff --git a/tests/controllers/AccountControllerTest.php b/tests/controllers/AccountControllerTest.php index 58b908c640..d89449d252 100644 --- a/tests/controllers/AccountControllerTest.php +++ b/tests/controllers/AccountControllerTest.php @@ -69,6 +69,7 @@ class AccountControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/accounts/create/asset'); $this->assertResponseOk(); @@ -127,6 +128,7 @@ class AccountControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); // get edit page: $this->call('GET', '/accounts/edit/' . $this->account->id); @@ -153,7 +155,7 @@ class AccountControllerTest extends TestCase $repository->shouldReceive('getLastActivity')->andReturn(null); Amount::shouldReceive('format')->andReturn(''); - Amount::shouldReceive('getCurrencyCode')->once()->andReturn('A'); + Amount::shouldReceive('getCurrencyCode')->andReturn('A'); // put stuff in session: @@ -172,7 +174,7 @@ class AccountControllerTest extends TestCase $this->be($this->account->user); // mock! - Amount::shouldReceive('getCurrencyCode')->once()->andReturn('A'); + Amount::shouldReceive('getCurrencyCode')->andReturn('A'); $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository->shouldReceive('getJournals')->andReturn(new LengthAwarePaginator([], 0, 10)); diff --git a/tests/controllers/BillControllerTest.php b/tests/controllers/BillControllerTest.php index eab8b1c0f6..e664a5929a 100644 --- a/tests/controllers/BillControllerTest.php +++ b/tests/controllers/BillControllerTest.php @@ -72,6 +72,7 @@ class BillControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/bills/create'); $this->assertViewHas('subTitle', 'Create new'); @@ -111,6 +112,7 @@ class BillControllerTest extends TestCase $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency'); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/bills/edit/' . $bill->id); $this->assertViewHas('subTitle', 'Edit "' . e($bill->name) . '"'); @@ -126,6 +128,7 @@ class BillControllerTest extends TestCase $collection->push($bill); Amount::shouldReceive('format')->andReturn('XX'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $repository = $this->mock('FireflyIII\Repositories\Bill\BillRepositoryInterface'); $repository->shouldReceive('getBills')->once()->andReturn($collection); @@ -187,6 +190,8 @@ class BillControllerTest extends TestCase Amount::shouldReceive('format')->andReturn('XX'); Amount::shouldReceive('getCurrencyCode')->andReturn('XX'); + + $this->call('GET', '/bills/show/' . $bill->id); } diff --git a/tests/controllers/BudgetControllerTest.php b/tests/controllers/BudgetControllerTest.php index 50ea295ca7..f57fe39918 100644 --- a/tests/controllers/BudgetControllerTest.php +++ b/tests/controllers/BudgetControllerTest.php @@ -115,6 +115,7 @@ class BudgetControllerTest extends TestCase $repository->shouldReceive('getCurrentRepetition')->once(); Amount::shouldReceive('getCurrencySymbol')->andReturn('x'); Amount::shouldReceive('format')->andReturn('x'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/budgets'); $this->assertResponseOk(); @@ -304,6 +305,10 @@ class BudgetControllerTest extends TestCase $pref = FactoryMuffin::create('FireflyIII\Models\Preference'); Preferences::shouldReceive('get')->withArgs(['budgetIncomeTotal' . $date, 1000])->andReturn($pref); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); + Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); + + $this->call('GET', '/budgets/income'); $this->assertResponseOk(); diff --git a/tests/controllers/JsonControllerTest.php b/tests/controllers/JsonControllerTest.php index 0f8390d6cc..32f320161c 100644 --- a/tests/controllers/JsonControllerTest.php +++ b/tests/controllers/JsonControllerTest.php @@ -56,6 +56,7 @@ class JsonControllerTest extends TestCase $accounts->shouldReceive('getCreditCards')->andReturn($ccs); $accounts->shouldReceive('getTransfersInRange')->andReturn(new Collection); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Steam::shouldReceive('balance')->andReturn(0); @@ -83,6 +84,7 @@ class JsonControllerTest extends TestCase $bills->shouldReceive('createFakeBill')->andReturn($bill); $accounts->shouldReceive('getCreditCards')->andReturn($ccs); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Steam::shouldReceive('balance')->andReturn(-1); $this->call('GET', '/json/box/bills-unpaid'); @@ -97,6 +99,7 @@ class JsonControllerTest extends TestCase $repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface'); $repository->shouldReceive('incomeByPeriod')->andReturn(new Collection); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/json/box/in'); $this->assertResponseOk(); @@ -110,6 +113,7 @@ class JsonControllerTest extends TestCase $repository = $this->mock('FireflyIII\Helpers\Report\ReportQueryInterface'); $repository->shouldReceive('journalsByExpenseAccount')->andReturn(new Collection); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/json/box/out'); $this->assertResponseOk(); diff --git a/tests/controllers/PiggyBankControllerTest.php b/tests/controllers/PiggyBankControllerTest.php index fe49823479..38b1b62b0d 100644 --- a/tests/controllers/PiggyBankControllerTest.php +++ b/tests/controllers/PiggyBankControllerTest.php @@ -50,6 +50,8 @@ class PiggyBankControllerTest extends TestCase $repository = $this->mock('FireflyIII\Repositories\Account\AccountRepositoryInterface'); $repository->shouldReceive('leftOnAccount')->withAnyArgs()->andReturn(12); Amount::shouldReceive('format')->andReturn('XXxx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); + Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/piggy-banks/add/' . $piggyBank->id); $this->assertResponseOk(); @@ -179,6 +181,7 @@ class PiggyBankControllerTest extends TestCase Steam::shouldReceive('balance')->andReturn(20); $accounts->shouldReceive('leftOnAccount')->andReturn(12); Amount::shouldReceive('format')->andReturn('123'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('GET', '/piggy-banks'); @@ -218,6 +221,7 @@ class PiggyBankControllerTest extends TestCase $piggyBanks->shouldReceive('createEvent')->once(); Amount::shouldReceive('format')->andReturn('something'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe']); $this->assertResponseStatus(302); @@ -235,6 +239,7 @@ class PiggyBankControllerTest extends TestCase $piggyBanks->shouldReceive('createEvent')->once(); Amount::shouldReceive('format')->andReturn('something'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); $this->call('POST', '/piggy-banks/add/' . $piggyBank->id, ['_token' => 'replaceMe', 'amount' => '10000']); $this->assertResponseStatus(302); @@ -283,6 +288,8 @@ class PiggyBankControllerTest extends TestCase $this->be($piggyBank->account->user); Amount::shouldReceive('format')->andReturn('something'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); + Amount::shouldReceive('getCurrencySymbol')->andReturn('X'); $this->call('GET', '/piggy-banks/remove/' . $piggyBank->id); $this->assertResponseOk(); diff --git a/tests/controllers/PreferencesControllerTest.php b/tests/controllers/PreferencesControllerTest.php index 02f61910d6..af27739081 100644 --- a/tests/controllers/PreferencesControllerTest.php +++ b/tests/controllers/PreferencesControllerTest.php @@ -55,6 +55,7 @@ class PreferencesControllerTest extends TestCase Preferences::shouldReceive('get')->once()->withArgs(['budgetMaximum', 1000])->andReturn($pref); Preferences::shouldReceive('get')->once()->withArgs(['currencyPreference', 'EUR'])->andReturn($pref); Amount::shouldReceive('format')->andReturn('xx'); + Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection); Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);