Skip to content

Firefly III: a personal finances manager

Updated factory muffin. This breaks everything. Let's skip Travis until we've fixed it. [skip ci]

James Cole22bd995b42ff
diff --git a/app/models/Account.php b/app/models/Account.php
index 8b5f787e14..b28c5f095e 100644
--- a/app/models/Account.php
+++ b/app/models/Account.php
@@ -36,23 +36,10 @@ class Account extends Ardent
'name' => 'required|between:1,100',
'user_id' => 'required|exists:users,id',
'account_type_id' => 'required|exists:account_types,id',
- 'active' => 'required|between:0,1|numeric'
+ 'active' => 'required|boolean'
];
- /**
- * Factory instructions
- *
- * @var array
- */
- public static $factory
- = [
- 'name' => 'string',
- 'user_id' => 'factory|User',
- 'account_type_id' => 'factory|AccountType',
- 'active' => '1'
- ];
-
/**
* Account type.
*
diff --git a/app/models/AccountType.php b/app/models/AccountType.php
index b1206e714b..c761dcb956 100644
--- a/app/models/AccountType.php
+++ b/app/models/AccountType.php
@@ -17,11 +17,6 @@
class AccountType extends Eloquent
{
- public static $factory
- = [
- 'description' => 'string'
- ];
-
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
diff --git a/app/models/Budget.php b/app/models/Budget.php
index 488b3547f9..2eb23fca1f 100644
--- a/app/models/Budget.php
+++ b/app/models/Budget.php
@@ -22,12 +22,6 @@
*/
class Budget extends Component
{
- public static $factory
- = [
- 'name' => 'string',
- 'user_id' => 'factory|User',
- 'class' => 'Budget'
- ];
protected $isSubclass = true;
/**
diff --git a/app/models/Category.php b/app/models/Category.php
index e08108bd18..da35743774 100644
--- a/app/models/Category.php
+++ b/app/models/Category.php
@@ -22,12 +22,6 @@
*/
class Category extends Component
{
- public static $factory
- = [
- 'name' => 'string',
- 'user_id' => 'factory|User',
- 'class' => 'Category'
- ];
protected $isSubclass = true;
/**
diff --git a/app/models/Piggybank.php b/app/models/Piggybank.php
index d686e32dae..fbfe7a936e 100644
--- a/app/models/Piggybank.php
+++ b/app/models/Piggybank.php
@@ -37,6 +37,8 @@ use LaravelBook\Ardent\Ardent as Ardent;
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminder($value)
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereReminderSkip($value)
* @method static \Illuminate\Database\Query\Builder|\Piggybank whereOrder($value)
+ * @property-read \Illuminate\Database\Eloquent\Collection|\PiggybankEvent[] $piggybankevents
+ * @property-read \Illuminate\Database\Eloquent\Collection|\Transaction[] $transactions
*/
class Piggybank extends Ardent
{
diff --git a/app/models/PiggybankEvent.php b/app/models/PiggybankEvent.php
index 88ef4168e6..11c9779cec 100644
--- a/app/models/PiggybankEvent.php
+++ b/app/models/PiggybankEvent.php
@@ -3,6 +3,23 @@
use Carbon\Carbon;
use LaravelBook\Ardent\Ardent as Ardent;
+/**
+ * PiggybankEvent
+ *
+ * @property integer $id
+ * @property \Carbon\Carbon $created_at
+ * @property \Carbon\Carbon $updated_at
+ * @property integer $piggybank_id
+ * @property \Carbon\Carbon $date
+ * @property float $amount
+ * @property-read \Piggybank $piggybank
+ * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereId($value)
+ * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereCreatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereUpdatedAt($value)
+ * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent wherePiggybankId($value)
+ * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereDate($value)
+ * @method static \Illuminate\Database\Query\Builder|\PiggybankEvent whereAmount($value)
+ */
class PiggybankEvent extends Ardent
{
diff --git a/app/models/TransactionJournal.php b/app/models/TransactionJournal.php
index 3b5cafdadf..a862a69664 100644
--- a/app/models/TransactionJournal.php
+++ b/app/models/TransactionJournal.php
@@ -35,6 +35,10 @@ use LaravelBook\Ardent\Ardent;
* @method static \Illuminate\Database\Query\Builder|\TransactionJournal whereDate($value)
* @method static \TransactionJournal after($date)
* @method static \TransactionJournal before($date)
+ * @property-read \Illuminate\Database\Eloquent\Collection|\
+ * 'Budget[] $budgets
+ * @property-read \Illuminate\Database\Eloquent\Collection|\
+ * 'Category[] $categories
*/
class TransactionJournal extends Ardent
{
diff --git a/app/models/User.php b/app/models/User.php
index 77164b0996..729ec33d12 100644
--- a/app/models/User.php
+++ b/app/models/User.php
@@ -44,7 +44,7 @@ class User extends Ardent implements UserInterface, RemindableInterface
public static $rules
= [
'email' => 'required|email|unique:users,email',
- 'migrated' => 'required|numeric|between:0,1',
+ 'migrated' => 'required|boolean',
'password' => 'required|between:60,60',
'reset' => 'between:32,32',
];
@@ -61,19 +61,6 @@ class User extends Ardent implements UserInterface, RemindableInterface
*/
protected $hidden = ['remember_token'];
- /**
- * @return array
- */
- public static function factory()
- {
- return [
- 'email' => 'email',
- 'password' => 'sander',
- 'migrated' => '0'
-
- ];
- }
-
/**
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
diff --git a/app/tests/TestCase.php b/app/tests/TestCase.php
index c291be445a..f6230dd2ef 100644
--- a/app/tests/TestCase.php
+++ b/app/tests/TestCase.php
@@ -1,4 +1,5 @@
<?php
+use League\FactoryMuffin\Facade as f;
/**
* Class TestCase
@@ -23,6 +24,12 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
return require __DIR__ . '/../../bootstrap/start.php';
}
+ public function setUp()
+ {
+ parent::setUp();
+ f::loadFactories(__DIR__ . '/factories');
+ }
+
/**
* @param $class
*
diff --git a/app/tests/controllers/AccountControllerTest.php b/app/tests/controllers/AccountControllerTest.php
index 0aa9e62d2c..3bc06d7da5 100644
--- a/app/tests/controllers/AccountControllerTest.php
+++ b/app/tests/controllers/AccountControllerTest.php
@@ -3,7 +3,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class AccountControllerTest
@@ -21,6 +21,9 @@ class AccountControllerTest extends TestCase
public function setUp()
{
parent::setUp();
+
+
+
Artisan::call('migrate');
Artisan::call('db:seed');
$this->_repository = $this->mock('Firefly\Storage\Account\AccountRepositoryInterface');
@@ -114,9 +117,15 @@ class AccountControllerTest extends TestCase
Auth::shouldReceive('user')->andReturn($this->_user);
Auth::shouldReceive('check')->andReturn(true);
$this->_user->shouldReceive('getAttribute')->with('id')->once()->andReturn($account->user_id);
- $this->_user->shouldReceive('getAttribute')->with('email')->once()->andReturn('some@email');
+ $this->_user->shouldReceive('getAttribute')->with('email')->andReturn('some@email');
$this->_accounts->shouldReceive('openingBalanceTransaction')->once()->andReturn(null);
+ // test if the view works:
+ View::shouldReceive('make')->with('accounts.edit')->once()->andReturn(m::self())->shouldReceive('with')->with(
+ 'account', m::any()
+ )
+ ->andReturn(m::self())->shouldReceive('with')->with('openingBalance', null)->andReturn(m::self());
+
$this->action('GET', 'AccountController@edit', $account->id);
$this->assertResponseOk();
}
@@ -127,14 +136,20 @@ class AccountControllerTest extends TestCase
$collection = new Collection();
$collection->add($account);
+ // create some fake accounts:
+ $personal = f::create('Account');
+ $bene = f::create('Account');
+ $init = f::create('Account');
+ $cash = f::create('Account');
+
$list = [
- 'personal' => [],
- 'beneficiaries' => [],
- 'initial' => [],
- 'cash' => []
+ 'personal' => [$personal],
+ 'beneficiaries' => [$bene],
+ 'initial' => [$init],
+ 'cash' => [$cash]
];
- $this->_repository->shouldReceive('get')->with()->once()->andReturn($collection);
+ $this->_repository->shouldReceive('get')->once()->andReturn($collection);
$this->_accounts->shouldReceive('index')->with($collection)->once()->andReturn($list);
$this->action('GET', 'AccountController@index');
$this->assertResponseOk();
diff --git a/app/tests/controllers/BudgetControllerTest.php b/app/tests/controllers/BudgetControllerTest.php
index d3432943e3..6fc751bdb5 100644
--- a/app/tests/controllers/BudgetControllerTest.php
+++ b/app/tests/controllers/BudgetControllerTest.php
@@ -3,7 +3,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class BudgetControllerTest
diff --git a/app/tests/controllers/CategoryControllerTest.php b/app/tests/controllers/CategoryControllerTest.php
index 7d87683cf3..5d04d3b433 100644
--- a/app/tests/controllers/CategoryControllerTest.php
+++ b/app/tests/controllers/CategoryControllerTest.php
@@ -3,7 +3,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class CategoryControllerTest
diff --git a/app/tests/controllers/ChartControllerTest.php b/app/tests/controllers/ChartControllerTest.php
index 0b86bf7f57..261b7ea248 100644
--- a/app/tests/controllers/ChartControllerTest.php
+++ b/app/tests/controllers/ChartControllerTest.php
@@ -3,7 +3,7 @@
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Collection;
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
diff --git a/app/tests/controllers/HomeControllerTest.php b/app/tests/controllers/HomeControllerTest.php
index 16c9798f88..07f812459c 100644
--- a/app/tests/controllers/HomeControllerTest.php
+++ b/app/tests/controllers/HomeControllerTest.php
@@ -1,7 +1,7 @@
<?php
use Carbon\Carbon as Carbon;
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class HomeControllerTest
diff --git a/app/tests/controllers/JsonControllerTest.php b/app/tests/controllers/JsonControllerTest.php
index 66b437848d..37f576341e 100644
--- a/app/tests/controllers/JsonControllerTest.php
+++ b/app/tests/controllers/JsonControllerTest.php
@@ -1,5 +1,5 @@
<?php
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class JsonControllerTest
diff --git a/app/tests/controllers/LimitControllerTest.php b/app/tests/controllers/LimitControllerTest.php
index 8853a7ae06..9e81a2b17c 100644
--- a/app/tests/controllers/LimitControllerTest.php
+++ b/app/tests/controllers/LimitControllerTest.php
@@ -1,6 +1,6 @@
<?php
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class LimitControllerTest
diff --git a/app/tests/controllers/PiggybankControllerTest.php b/app/tests/controllers/PiggybankControllerTest.php
index d220c48144..0bbddb75f4 100644
--- a/app/tests/controllers/PiggybankControllerTest.php
+++ b/app/tests/controllers/PiggybankControllerTest.php
@@ -1,7 +1,7 @@
<?php
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
diff --git a/app/tests/controllers/ProfileControllerTest.php b/app/tests/controllers/ProfileControllerTest.php
index b0e9e9f379..fb82c75faf 100644
--- a/app/tests/controllers/ProfileControllerTest.php
+++ b/app/tests/controllers/ProfileControllerTest.php
@@ -1,6 +1,6 @@
<?php
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class ProfileControllerTest
diff --git a/app/tests/controllers/RecurringControllerTest.php b/app/tests/controllers/RecurringControllerTest.php
index a520bf61e3..f35d918c7b 100644
--- a/app/tests/controllers/RecurringControllerTest.php
+++ b/app/tests/controllers/RecurringControllerTest.php
@@ -1,6 +1,6 @@
<?php
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class RecurringControllerTest
diff --git a/app/tests/controllers/TransactionControllerTest.php b/app/tests/controllers/TransactionControllerTest.php
index 6ac6777c8b..11556e4350 100644
--- a/app/tests/controllers/TransactionControllerTest.php
+++ b/app/tests/controllers/TransactionControllerTest.php
@@ -1,7 +1,7 @@
<?php
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class TransactionControllerTest
diff --git a/app/tests/controllers/UserControllerTest.php b/app/tests/controllers/UserControllerTest.php
index 963ba018c1..78d4a20211 100644
--- a/app/tests/controllers/UserControllerTest.php
+++ b/app/tests/controllers/UserControllerTest.php
@@ -1,7 +1,7 @@
<?php
use Mockery as m;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
diff --git a/app/tests/factories/Account.php b/app/tests/factories/Account.php
new file mode 100644
index 0000000000..289478ddd1
--- /dev/null
+++ b/app/tests/factories/Account.php
@@ -0,0 +1,12 @@
+<?php
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'Account',
+ [
+ 'user_id' => 'factory|User',
+ 'account_type_id' => 'factory|AccountType',
+ 'name' => 'word',
+ 'active' => 'boolean'
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/AccountType.php b/app/tests/factories/AccountType.php
new file mode 100644
index 0000000000..df48a184b5
--- /dev/null
+++ b/app/tests/factories/AccountType.php
@@ -0,0 +1,17 @@
+<?php
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'AccountType',
+ [
+ 'description' => function() {
+ $types = [
+ 'Default account',
+ 'Cash account',
+ 'Initial balance account',
+ 'Beneficiary account'
+ ];
+ return $types[rand(0,3)];
+ }
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/Budget.php b/app/tests/factories/Budget.php
new file mode 100644
index 0000000000..a7b68c6ed3
--- /dev/null
+++ b/app/tests/factories/Budget.php
@@ -0,0 +1,11 @@
+<?php
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'Budget',
+ [
+ 'name' => 'word',
+ 'user_id' => 'factory|User',
+ 'class' => 'Budget'
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/Category.php b/app/tests/factories/Category.php
new file mode 100644
index 0000000000..71f1df47e8
--- /dev/null
+++ b/app/tests/factories/Category.php
@@ -0,0 +1,11 @@
+<?php
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'Budget',
+ [
+ 'name' => 'word',
+ 'user_id' => 'factory|User',
+ 'class' => 'Category'
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/factories/User.php b/app/tests/factories/User.php
new file mode 100644
index 0000000000..1649da1e1f
--- /dev/null
+++ b/app/tests/factories/User.php
@@ -0,0 +1,17 @@
+<?php
+use League\FactoryMuffin\Facade;
+
+Facade::define(
+ 'User',
+ [
+ 'email' => 'safeEmail',
+ 'password' => function () {
+ return \Str::random(60);
+ },
+ 'reset' => function () {
+ return \Str::random(32);
+ },
+ 'remember_token' => null,
+ 'migrated' => 'boolean'
+ ]
+);
\ No newline at end of file
diff --git a/app/tests/models/ModelTest.php b/app/tests/models/ModelTest.php
index 1393580d2a..b8b3e77741 100644
--- a/app/tests/models/ModelTest.php
+++ b/app/tests/models/ModelTest.php
@@ -1,6 +1,6 @@
<?php
use Carbon\Carbon;
-use Zizaco\FactoryMuff\Facade\FactoryMuff as f;
+use League\FactoryMuffin\Facade as f;
/**
* Class ModelTest
diff --git a/app/views/partials/menu.blade.php b/app/views/partials/menu.blade.php
index 6fe57d4461..7cf4fcc89e 100644
--- a/app/views/partials/menu.blade.php
+++ b/app/views/partials/menu.blade.php
@@ -53,8 +53,10 @@ $r = Route::current()->getName();
<li><a href="{{route('transactions.create','withdrawal')}}" title="For when you spend money"><span class="glyphicon glyphicon-arrow-left"></span> Withdrawal</a></li>
</ul>
</li>
-
</ul>
+ <!--
+ <p style="cursor:pointer;" class="navbar-text"><span class="label label-danger">1 reminder</span> </p>
+ -->
@if(\Auth::user() && \Auth::check())
<ul class="nav navbar-nav navbar-right">
diff --git a/composer.json b/composer.json
index 9be2d6503c..5bb6edc01c 100644
--- a/composer.json
+++ b/composer.json
@@ -30,7 +30,7 @@
"barryvdh/laravel-ide-helper": "~1.9",
"mockery/mockery": "~0.9",
"satooshi/php-coveralls": "~0.6",
- "league/factory-muffin": "~1.5",
+ "league/factory-muffin": "~2.0",
"doctrine/dbal": "2.4.*"
},
"autoload": {