Some experimental model tests.

This commit is contained in:
James Cole
2014-07-09 13:19:30 +02:00
parent 5645f7a893
commit 84f4e80da1
8 changed files with 93 additions and 111 deletions

View File

@@ -6,8 +6,19 @@ class Account extends Elegant
public static $rules
= [
'name' => 'required|between:1,100',
'user_id' => 'required|exists:users,id'
'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'
];
public static $factory
= [
'name' => 'string',
'user_id' => 'factory|User',
'account_type_id' => 'factory|AccountType',
'active' => '1'
];
public function accountType()

View File

@@ -1,10 +1,16 @@
<?php
class AccountType extends Eloquent {
class AccountType extends Eloquent
{
public function accounts() {
public static $factory
= [
'description' => 'string'
];
public function accounts()
{
return $this->hasMany('Account');
}
}

View File

@@ -9,6 +9,12 @@ class Preference extends Elegant
'data' => 'required'
];
public static $factory = [
'user_id' => 'factory|User',
'name' => 'string',
'data' => 'string'
];
public function user()
{
return $this->belongsTo('User');

View File

@@ -18,6 +18,14 @@ class User extends Elegant implements UserInterface, RemindableInterface
'password' => 'required|between:60,60',
'reset' => 'between:32,32',
];
public static $factory
= [
'email' => 'email',
'password' => 'string',
'migrated' => '0'
];
/**
* The database table used by the model.
*