Skip to content

Firefly III: a personal finances manager

Some new tests

James Colec06f18c8154e
diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php
index 55026e0620..9efbd64e74 100644
--- a/app/Helpers/Report/ReportHelper.php
+++ b/app/Helpers/Report/ReportHelper.php
@@ -136,7 +136,7 @@ class ReportHelper implements ReportHelperInterface
$end = clone $date;
$sharedAccounts = [];
if ($showSharedReports === false) {
- $sharedCollection = \Auth::user()->accounts()
+ $sharedCollection = Auth::user()->accounts()
->leftJoin('account_meta', 'account_meta.account_id', '=', 'accounts.id')
->where('account_meta.name', '=', 'accountRole')
->where('account_meta.data', '=', json_encode('sharedAsset'))
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index f2d65060c5..6f49c9669a 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -230,7 +230,7 @@ class TransactionJournal extends Model
*/
public function setDescriptionAttribute($value)
{
- $this->attributes['description'] = \Crypt::encrypt($value);
+ $this->attributes['description'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php
index 0c85491199..fd52a224f7 100644
--- a/app/Providers/EventServiceProvider.php
+++ b/app/Providers/EventServiceProvider.php
@@ -117,8 +117,8 @@ class EventServiceProvider extends ServiceProvider
try {
$repetition->save();
} catch (QueryException $e) {
- \Log::error('Trying to save new LimitRepetition failed!');
- \Log::error($e->getMessage());
+ Log::error('Trying to save new LimitRepetition failed!');
+ Log::error($e->getMessage());
}
} else {
if ($set->count() == 1) {
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 41fabfceec..a267f4a0bb 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -4,6 +4,7 @@ namespace FireflyIII\Repositories\Bill;
use Auth;
use Carbon\Carbon;
+use DB;
use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Bill;
@@ -119,7 +120,7 @@ class BillRepository implements BillRepositoryInterface
*/
public function getPossiblyRelatedJournals(Bill $bill)
{
- $set = \DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max)->get(
+ $set = DB::table('transactions')->where('amount', '>', 0)->where('amount', '>=', $bill->amount_min)->where('amount', '<=', $bill->amount_max)->get(
['transaction_journal_id']
);
$ids = [];
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index 82ceed96cf..42133ba6fb 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -10,6 +10,7 @@ use FireflyIII\Models\LimitRepetition;
use Illuminate\Database\Query\Builder as QueryBuilder;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
+use Input;
/**
* Class BudgetRepository
@@ -162,7 +163,7 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function getJournals(Budget $budget, LimitRepetition $repetition = null, $take = 50)
{
- $offset = intval(\Input::get('page')) > 0 ? intval(\Input::get('page')) * $take : 0;
+ $offset = intval(Input::get('page')) > 0 ? intval(Input::get('page')) * $take : 0;
$setQuery = $budget->transactionJournals()->withRelevantData()->take($take)->offset($offset)
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index 54669530d2..b1146b4496 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -39,17 +39,10 @@ class Amount
if (defined('FFCURRENCYSYMBOL')) {
return FFCURRENCYSYMBOL;
}
- if (\Cache::has('FFCURRENCYSYMBOL')) {
- define('FFCURRENCYSYMBOL', \Cache::get('FFCURRENCYSYMBOL'));
-
- return FFCURRENCYSYMBOL;
- }
$currencyPreference = Prefs::get('currencyPreference', 'EUR');
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
- \Cache::forever('FFCURRENCYSYMBOL', $currency->symbol);
-
define('FFCURRENCYSYMBOL', $currency->symbol);
return $currency->symbol;
@@ -160,7 +153,6 @@ class Amount
$currency = TransactionCurrency::whereCode($currencyPreference->data)->first();
if ($currency) {
- Cache::forever('FFCURRENCYCODE', $currency->code);
define('FFCURRENCYCODE', $currency->code);
return $currency->code;
diff --git a/tests/repositories/BillRepositoryTest.php b/tests/repositories/BillRepositoryTest.php
index c900499a20..e1a579dc59 100644
--- a/tests/repositories/BillRepositoryTest.php
+++ b/tests/repositories/BillRepositoryTest.php
@@ -65,38 +65,61 @@ class BillRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::getActiveBills
- * @todo Implement testGetActiveBills().
*/
public function testGetActiveBills()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill');
+ $bill2 = FactoryMuffin::create('FireflyIII\Models\Bill');
+
+ // update bills
+ $bill1->active = 1;
+ $bill2->active = 0;
+ $bill2->user_id = $bill1->user_id;
+ $bill1->save();
+ $bill2->save();
+ $this->be($bill1->user);
+
+ $set = $this->object->getActiveBills();
+
+ $this->assertCount(1, $set);
}
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::getBills
- * @todo Implement testGetBills().
*/
public function testGetBills()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill');
+ $bill2 = FactoryMuffin::create('FireflyIII\Models\Bill');
+
+ // update bills
+ $bill1->active = 1;
+ $bill2->active = 0;
+ $bill2->user_id = $bill1->user_id;
+ $bill1->save();
+ $bill2->save();
+ $this->be($bill1->user);
+
+ $set = $this->object->getBills();
+
+ $this->assertCount(2, $set);
}
/**
* @covers FireflyIII\Repositories\Bill\BillRepository::getJournals
- * @todo Implement testGetJournals().
*/
public function testGetJournals()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill');
+
+ // update bills
+ $bill1->active = 1;
+ $bill1->save();
+ $this->be($bill1->user);
+
+ $set = $this->object->getJournals($bill1);
+
+ $this->assertCount(0, $set);
}
/**
@@ -105,10 +128,16 @@ class BillRepositoryTest extends TestCase
*/
public function testGetJournalsInRange()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $bill1 = FactoryMuffin::create('FireflyIII\Models\Bill');
+
+ // update bills
+ $bill1->active = 1;
+ $bill1->save();
+ $this->be($bill1->user);
+
+ $set = $this->object->getJournalsInRange($bill1, new Carbon, new Carbon);
+
+ $this->assertCount(0, $set);
}
/**