Should fix tests.

This commit is contained in:
James Cole 2015-06-03 21:15:52 +02:00
parent a7f6848e53
commit 409ec2e086
21 changed files with 151 additions and 132 deletions

View File

@ -48,14 +48,10 @@ class AccountController extends Controller
$chartProperties->addProperty($end); $chartProperties->addProperty($end);
$chartProperties->addProperty('all'); $chartProperties->addProperty('all');
$chartProperties->addProperty('accounts'); $chartProperties->addProperty('accounts');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
$chart->addColumn(trans('firefly.dayOfMonth'), 'date'); $chart->addColumn(trans('firefly.dayOfMonth'), 'date');
@ -123,14 +119,10 @@ class AccountController extends Controller
$chartProperties->addProperty($end); $chartProperties->addProperty($end);
$chartProperties->addProperty('frontpage'); $chartProperties->addProperty('frontpage');
$chartProperties->addProperty('accounts'); $chartProperties->addProperty('accounts');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
$index = 1; $index = 1;
@ -188,14 +180,10 @@ class AccountController extends Controller
$chartProperties->addProperty('frontpage'); $chartProperties->addProperty('frontpage');
$chartProperties->addProperty('single'); $chartProperties->addProperty('single');
$chartProperties->addProperty($account->id); $chartProperties->addProperty($account->id);
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();

View File

@ -44,13 +44,10 @@ class BillController extends Controller
$chartProperties->addProperty('single'); $chartProperties->addProperty('single');
$chartProperties->addProperty('bill'); $chartProperties->addProperty('bill');
$chartProperties->addProperty($bill->id); $chartProperties->addProperty($bill->id);
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
// get first transaction or today for start: // get first transaction or today for start:
$results = $repository->getJournals($bill); $results = $repository->getJournals($bill);
@ -92,13 +89,10 @@ class BillController extends Controller
$chartProperties->addProperty($end); $chartProperties->addProperty($end);
$chartProperties->addProperty('bills'); $chartProperties->addProperty('bills');
$chartProperties->addProperty('frontpage'); $chartProperties->addProperty('frontpage');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
$bills = $repository->getActiveBills(); $bills = $repository->getActiveBills();
$paid = new Collection; // journals. $paid = new Collection; // journals.

View File

@ -50,13 +50,10 @@ class BudgetController extends Controller
$chartProperties->addProperty($last); $chartProperties->addProperty($last);
$chartProperties->addProperty('budget'); $chartProperties->addProperty('budget');
$chartProperties->addProperty('budget'); $chartProperties->addProperty('budget');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
while ($first < $last) { while ($first < $last) {
@ -100,13 +97,10 @@ class BudgetController extends Controller
$chartProperties->addProperty('limit'); $chartProperties->addProperty('limit');
$chartProperties->addProperty($budget->id); $chartProperties->addProperty($budget->id);
$chartProperties->addProperty($repetition->id); $chartProperties->addProperty($repetition->id);
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
$chart->addColumn(trans('firefly.day'), 'date'); $chart->addColumn(trans('firefly.day'), 'date');
$chart->addColumn(trans('firefly.left'), 'number'); $chart->addColumn(trans('firefly.left'), 'number');
@ -158,13 +152,10 @@ class BudgetController extends Controller
$chartProperties->addProperty($end); $chartProperties->addProperty($end);
$chartProperties->addProperty('budget'); $chartProperties->addProperty('budget');
$chartProperties->addProperty('all'); $chartProperties->addProperty('all');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
/** @var Budget $budget */ /** @var Budget $budget */
@ -232,14 +223,10 @@ class BudgetController extends Controller
$chartProperties->addProperty($end); $chartProperties->addProperty($end);
$chartProperties->addProperty('budget'); $chartProperties->addProperty('budget');
$chartProperties->addProperty('year'); $chartProperties->addProperty('year');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
// add columns: // add columns:
$chart->addColumn(trans('firefly.month'), 'date'); $chart->addColumn(trans('firefly.month'), 'date');

View File

@ -85,14 +85,10 @@ class CategoryController extends Controller
$chartProperties->addProperty($end); $chartProperties->addProperty($end);
$chartProperties->addProperty('category'); $chartProperties->addProperty('category');
$chartProperties->addProperty('frontpage'); $chartProperties->addProperty('frontpage');
$md5 = $chartProperties->md5(); if ($chartProperties->has()) {
return Response::json($chartProperties->get());
if (Cache::has($md5)) {
Log::debug('Successfully returned cached chart [' . $md5 . '].');
return Response::json(Cache::get($md5));
} }
$md5 = $chartProperties->getMd5();
$set = $repository->getCategoriesAndExpensesCorrected($start, $end); $set = $repository->getCategoriesAndExpensesCorrected($start, $end);

View File

@ -41,16 +41,6 @@ class HomeController extends Controller
{ {
Session::clear(); Session::clear();
// encrypt transaction journal description
$set = TransactionJournal::where('encrypted', 0)->take(100)->get();
/** @var TransactionJournal $entry */
foreach ($set as $entry) {
$description = $entry->description;
$entry->description = $description;
$entry->save();
}
unset($set, $entry, $description);
return Redirect::route('index'); return Redirect::route('index');
} }

View File

@ -13,7 +13,6 @@ use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\Tag\TagRepositoryInterface; use FireflyIII\Repositories\Tag\TagRepositoryInterface;
use FireflyIII\Support\CacheProperties; use FireflyIII\Support\CacheProperties;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use Log;
use Response; use Response;
use Session; use Session;
use Steam; use Steam;
@ -44,12 +43,10 @@ class JsonController extends Controller
$prop->addProperty($start); $prop->addProperty($start);
$prop->addProperty($end); $prop->addProperty($end);
$prop->addProperty('box-bills-paid'); $prop->addProperty('box-bills-paid');
$md5 = $prop->md5(); if ($prop->has()) {
if (Cache::has($md5)) { return Response::json($prop->get());
Log::debug('Successfully returned cached box bills-paid [' . $md5 . ']');
return Response::json(Cache::get($md5));
} }
$md5 = $prop->getMd5();
$amount = 0; $amount = 0;
@ -100,12 +97,10 @@ class JsonController extends Controller
$prop->addProperty($start); $prop->addProperty($start);
$prop->addProperty($end); $prop->addProperty($end);
$prop->addProperty('box-bills-unpaid'); $prop->addProperty('box-bills-unpaid');
$md5 = $prop->md5(); if ($prop->has()) {
if (Cache::has($md5)) { return Response::json($prop->get());
Log::debug('Successfully returned cached box bills-unpaid [' . $md5 . ']');
return Response::json(Cache::get($md5));
} }
$md5 = $prop->getMd5();
$bills = $repository->getActiveBills(); $bills = $repository->getActiveBills();
$unpaid = new Collection; // bills $unpaid = new Collection; // bills
@ -162,13 +157,10 @@ class JsonController extends Controller
$prop->addProperty($start); $prop->addProperty($start);
$prop->addProperty($end); $prop->addProperty($end);
$prop->addProperty('box-in'); $prop->addProperty('box-in');
$md5 = $prop->md5(); if ($prop->has()) {
if (Cache::has($md5)) { return Response::json($prop->get());
Log::debug('Successfully returned cached box in [' . $md5 . ']');
return Response::json(Cache::get($md5));
} }
$md5 = $prop->getMd5();
$amount = $reportQuery->incomeInPeriodCorrected($start, $end, true)->sum('amount'); $amount = $reportQuery->incomeInPeriodCorrected($start, $end, true)->sum('amount');
@ -194,12 +186,10 @@ class JsonController extends Controller
$prop->addProperty($start); $prop->addProperty($start);
$prop->addProperty($end); $prop->addProperty($end);
$prop->addProperty('box-out'); $prop->addProperty('box-out');
$md5 = $prop->md5(); if ($prop->has()) {
if (Cache::has($md5)) { return Response::json($prop->get());
Log::debug('Successfully returned cached box out [' . $md5 . ']');
return Response::json(Cache::get($md5));
} }
$md5 = $prop->getMd5();
$amount = $reportQuery->expenseInPeriodCorrected($start, $end, true)->sum('amount'); $amount = $reportQuery->expenseInPeriodCorrected($start, $end, true)->sum('amount');

View File

@ -57,14 +57,13 @@ class Reminders
$properties = new CacheProperties; $properties = new CacheProperties;
$properties->addProperty('reminders'); $properties->addProperty('reminders');
$md5 = $properties->md5(); if ($properties->has()) {
$reminders = $properties->get();
if (Cache::has($md5)) {
$reminders = Cache::get($md5);
View::share('reminders', $reminders); View::share('reminders', $reminders);
return $next($request); return $next($request);
} }
$md5 = $properties->getMd5();
$piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get(); $piggyBanks = $this->auth->user()->piggyBanks()->where('remind_me', 1)->get();

View File

@ -139,10 +139,10 @@ class TransactionJournal extends Model
$prop = new CacheProperties(); $prop = new CacheProperties();
$prop->addProperty($this->id); $prop->addProperty($this->id);
$prop->addProperty('amount'); $prop->addProperty('amount');
$md5 = $prop->md5(); if ($prop->has()) {
if (Cache::has($md5)) { return $prop->get();
return Cache::get($md5);
} }
$md5 = $prop->getMd5();
$amount = '0'; $amount = '0';

View File

@ -114,10 +114,10 @@ class AccountRepository implements AccountRepositoryInterface
$cache = new CacheProperties(); $cache = new CacheProperties();
$cache->addProperty($preference->data); $cache->addProperty($preference->data);
$cache->addProperty('frontPageaccounts'); $cache->addProperty('frontPageaccounts');
$md5 = $cache->md5(); if ($cache->has()) {
if (Cache::has($md5)) { return $cache->get();
return Cache::get($md5);
} }
$md5 = $cache->getMd5();
if ($preference->data == []) { if ($preference->data == []) {
@ -148,10 +148,10 @@ class AccountRepository implements AccountRepositoryInterface
$prop->addProperty($account->id); $prop->addProperty($account->id);
$prop->addProperty($start); $prop->addProperty($start);
$prop->addProperty($end); $prop->addProperty($end);
$md5 = $prop->md5(); if ($prop->has()) {
if(Cache::has($md5)) { return $prop->get();
return Cache::get($md5);
} }
$md5 = $prop->getMd5();
$set = Auth::user() $set = Auth::user()
->transactionjournals() ->transactionjournals()
@ -167,6 +167,7 @@ class AccountRepository implements AccountRepositoryInterface
->take(10) ->take(10)
->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']); ->get(['transaction_journals.*', 'transaction_currencies.symbol', 'transaction_types.type']);
Cache::forever($md5, $set); Cache::forever($md5, $set);
return $set; return $set;
} }
@ -234,10 +235,10 @@ class AccountRepository implements AccountRepositoryInterface
$cache = new CacheProperties; $cache = new CacheProperties;
$cache->addProperty($ids); $cache->addProperty($ids);
$cache->addProperty('piggyAccounts'); $cache->addProperty('piggyAccounts');
$md5 = $cache->md5(); if ($cache->has()) {
if (Cache::has($md5)) { return $cache->get();
return Cache::get($md5);
} }
$md5 = $cache->getMd5();
$ids = array_unique($ids); $ids = array_unique($ids);
if (count($ids) > 0) { if (count($ids) > 0) {

View File

@ -4,6 +4,7 @@ namespace FireflyIII\Support;
use Auth; use Auth;
use Cache;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection as EloquentCollection; use Illuminate\Database\Eloquent\Collection as EloquentCollection;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
@ -17,6 +18,8 @@ use Preferences as Prefs;
class CacheProperties class CacheProperties
{ {
/** @var string */
protected $md5 = '';
/** @var Collection */ /** @var Collection */
protected $properties; protected $properties;
@ -38,39 +41,62 @@ class CacheProperties
$this->properties->push($property); $this->properties->push($property);
} }
/**
* @return mixed
*/
public function get()
{
return Cache::get($this->md5);
}
/** /**
* @return string * @return string
*/ */
public function md5() public function getMd5()
{
return $this->md5;
}
/**
* @return bool
*/
public function has()
{
$this->md5();
return Cache::has($this->md5);
}
/**
* @return void
*/
private function md5()
{ {
$string = '';
//Log::debug('--- building string ---');
foreach ($this->properties as $property) { foreach ($this->properties as $property) {
if ($property instanceof Collection || $property instanceof EloquentCollection) { if ($property instanceof Collection || $property instanceof EloquentCollection) {
$string .= print_r($property->toArray(), true); $this->md5 .= print_r($property->toArray(), true);
continue; continue;
} }
if ($property instanceof Carbon) { if ($property instanceof Carbon) {
$string .= $property->toRfc3339String(); $this->md5 .= $property->toRfc3339String();
continue; continue;
} }
if (is_array($property)) { if (is_array($property)) {
$string .= print_r($property, true); $this->md5 .= print_r($property, true);
continue; continue;
} }
if (is_object($property)) { if (is_object($property)) {
$string .= $property->__toString(); $this->md5 .= $property->__toString();
} }
if (is_array($property)) { if (is_array($property)) {
$string .= print_r($property, true); $this->md5 .= print_r($property, true);
} }
$string .= (string)$property; $this->md5 .= (string)$property;
} }
return md5($string); $this->md5 = md5($this->md5);
} }
} }

View File

@ -30,10 +30,10 @@ class Steam
$properties->addProperty('balance'); $properties->addProperty('balance');
$properties->addProperty($date); $properties->addProperty($date);
$properties->addProperty($ignoreVirtualBalance); $properties->addProperty($ignoreVirtualBalance);
$md5 = $properties->md5(); if ($properties->has()) {
if (Cache::has($md5)) { return $properties->get();
return Cache::get($md5);
} }
$md5 = $properties->getMd5();
// find the first known transaction on this account: // find the first known transaction on this account:

View File

@ -33,10 +33,10 @@ class Journal extends Twig_Extension
$prop = new CacheProperties(); $prop = new CacheProperties();
$prop->addProperty($journal->id); $prop->addProperty($journal->id);
$prop->addProperty('typeIcon'); $prop->addProperty('typeIcon');
$md5 = $prop->md5(); if ($prop->has()) {
if (Cache::has($md5)) { return $prop->get();
return Cache::get($md5);
} }
$md5 = $prop->getMd5();
$type = $journal->transactionType->type; $type = $journal->transactionType->type;

View File

@ -1,9 +1,6 @@
<?php <?php
use Carbon\Carbon; use Carbon\Carbon;
use FireflyIII\Models\Account; use FireflyIII\Models\Account;
use FireflyIII\Models\AccountType;
use FireflyIII\Models\Preference;
use FireflyIII\Models\TransactionCurrency;
use Illuminate\Pagination\LengthAwarePaginator; use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;
use League\FactoryMuffin\Facade as FactoryMuffin; use League\FactoryMuffin\Facade as FactoryMuffin;
@ -79,6 +76,9 @@ class AccountControllerTest extends TestCase
Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency); Amount::shouldReceive('getDefaultCurrency')->once()->andReturn($currency);
Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]); Amount::shouldReceive('getAllCurrencies')->once()->andReturn([$currency]);
Amount::shouldReceive('getCurrencyCode')->andReturn('X'); Amount::shouldReceive('getCurrencyCode')->andReturn('X');
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
$this->call('GET', '/accounts/create/asset'); $this->call('GET', '/accounts/create/asset');
$this->assertResponseOk(); $this->assertResponseOk();

View File

@ -194,6 +194,9 @@ class BudgetControllerTest extends TestCase
$date = Carbon::now()->startOfMonth()->format('FY'); $date = Carbon::now()->startOfMonth()->format('FY');
Preferences::shouldReceive('set')->once()->withArgs(['budgetIncomeTotal' . $date, 1001]); Preferences::shouldReceive('set')->once()->withArgs(['budgetIncomeTotal' . $date, 1001]);
Preferences::shouldReceive('mark')->once()->andReturn(true); Preferences::shouldReceive('mark')->once()->andReturn(true);
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
// language preference: // language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference'); $language = FactoryMuffin::create('FireflyIII\Models\Preference');
@ -386,6 +389,9 @@ class BudgetControllerTest extends TestCase
Amount::shouldReceive('format')->andReturn('xx'); Amount::shouldReceive('format')->andReturn('xx');
Amount::shouldReceive('getCurrencyCode')->andReturn('X'); 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);
// language preference: // language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference'); $language = FactoryMuffin::create('FireflyIII\Models\Preference');

View File

@ -108,6 +108,10 @@ class HomeControllerTest extends TestCase
$language->save(); $language->save();
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
Amount::shouldReceive('getCurrencyCode')->andReturn('EUR'); Amount::shouldReceive('getCurrencyCode')->andReturn('EUR');
Amount::shouldReceive('format')->andReturn('xxx'); Amount::shouldReceive('format')->andReturn('xxx');

View File

@ -62,6 +62,10 @@ class PreferencesControllerTest extends TestCase
Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection); Amount::shouldReceive('getAllCurrencies')->andReturn(new Collection);
Amount::shouldReceive('getDefaultCurrency')->andReturn($currency); Amount::shouldReceive('getDefaultCurrency')->andReturn($currency);
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
// language preference: // language preference:
$language = FactoryMuffin::create('FireflyIII\Models\Preference'); $language = FactoryMuffin::create('FireflyIII\Models\Preference');
$language->data = 'en'; $language->data = 'en';
@ -105,6 +109,10 @@ class PreferencesControllerTest extends TestCase
$language->save(); $language->save();
Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language); Preferences::shouldReceive('get')->withAnyArgs()->andReturn($language);
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
$this->call('POST', '/preferences', $data); $this->call('POST', '/preferences', $data);
$this->assertResponseStatus(302); $this->assertResponseStatus(302);

View File

@ -60,6 +60,14 @@ class ChartBillControllerTest extends TestCase
$repository->shouldReceive('createFakeBill')->andReturn($bills->first()); $repository->shouldReceive('createFakeBill')->andReturn($bills->first());
Steam::shouldReceive('balance')->andReturn(-10, 0); Steam::shouldReceive('balance')->andReturn(-10, 0);
$lastActivity = FactoryMuffin::create('FireflyIII\Models\Preference');
$lastActivity->data = microtime();
Preferences::shouldReceive('lastActivity')->andReturn($lastActivity);
$language = FactoryMuffin::create('FireflyIII\Models\Preference');
$language->data = 'en';
Preferences::shouldReceive('get')->withArgs(['language', 'en'])->andReturn($language);
$this->call('GET', '/chart/bill/frontpage'); $this->call('GET', '/chart/bill/frontpage');
$this->assertResponseOk(); $this->assertResponseOk();

View File

@ -111,6 +111,9 @@ class ReportHelperTest extends TestCase
*/ */
public function testGetBillReport() public function testGetBillReport()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// factory! // factory!
$set = new Collection; $set = new Collection;
$journals = new Collection; $journals = new Collection;

View File

@ -62,6 +62,8 @@ class TransactionJournalModelTest extends TestCase
*/ */
public function testGetAmountAttributeAdvancePayment() public function testGetAmountAttributeAdvancePayment()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// make types: // make types:
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
$depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); $depositType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
@ -120,6 +122,9 @@ class TransactionJournalModelTest extends TestCase
*/ */
public function testGetAmountAttributeBalancingAct() public function testGetAmountAttributeBalancingAct()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// make types: // make types:
$withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType'); $withdrawalType = FactoryMuffin::create('FireflyIII\Models\TransactionType');
FactoryMuffin::create('FireflyIII\Models\TransactionType'); FactoryMuffin::create('FireflyIII\Models\TransactionType');
@ -177,6 +182,8 @@ class TransactionJournalModelTest extends TestCase
*/ */
public function testGetAmountAttributeNoTags() public function testGetAmountAttributeNoTags()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal'); $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
$journal->transactions[0]->amount = 123.45; $journal->transactions[0]->amount = 123.45;
@ -194,6 +201,9 @@ class TransactionJournalModelTest extends TestCase
*/ */
public function testGetAmountAttributeTag() public function testGetAmountAttributeTag()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
// has a normal tag, but nothing special. // has a normal tag, but nothing special.
// make tag // make tag
$tag = FactoryMuffin::create('FireflyIII\Models\Tag'); $tag = FactoryMuffin::create('FireflyIII\Models\Tag');

View File

@ -38,6 +38,9 @@ class BillRepositoryTest extends TestCase
public function testBillPaymentsInRange() public function testBillPaymentsInRange()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
$bill = FactoryMuffin::create('FireflyIII\Models\Bill'); $bill = FactoryMuffin::create('FireflyIII\Models\Bill');
$start = Carbon::now()->startOfMonth(); $start = Carbon::now()->startOfMonth();
$end = Carbon::now()->endOfMonth(); $end = Carbon::now()->endOfMonth();

View File

@ -446,6 +446,9 @@ class JournalRepositoryTest extends TestCase
*/ */
public function testUpdate() public function testUpdate()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
FactoryMuffin::create('FireflyIII\Models\AccountType'); FactoryMuffin::create('FireflyIII\Models\AccountType');
} }
@ -504,6 +507,9 @@ class JournalRepositoryTest extends TestCase
*/ */
public function testUpdateNoTags() public function testUpdateNoTags()
{ {
$user = FactoryMuffin::create('FireflyIII\User');
$this->be($user);
for ($i = 0; $i < 4; $i++) { for ($i = 0; $i < 4; $i++) {
FactoryMuffin::create('FireflyIII\Models\AccountType'); FactoryMuffin::create('FireflyIII\Models\AccountType');
} }