Some new tests

This commit is contained in:
James Cole 2015-05-08 14:00:49 +02:00
parent 6802f04036
commit c06f18c815
7 changed files with 56 additions and 33 deletions

View File

@ -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'))

View File

@ -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;
}

View File

@ -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) {

View File

@ -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 = [];

View File

@ -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)

View File

@ -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;

View File

@ -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);
}
/**