Updated some tests.

This commit is contained in:
James Cole 2015-05-23 17:11:16 +02:00
parent 99d4adf5e6
commit 9e050fb059
19 changed files with 162 additions and 80 deletions

View File

@ -70,7 +70,7 @@ class ReportHelper implements ReportHelperInterface
if ($account->accountType->type != 'Cash account') {
return $account;
}
}
} // @codeCoverageIgnore
);
// summarize:

View File

@ -6,6 +6,7 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use Input;
use Preferences;
use Redirect;
use Route;
use Session;
use Steam;
@ -87,5 +88,78 @@ class HomeController extends Controller
return view('index', compact('count', 'title', 'savings', 'subTitle', 'mainTitleIcon', 'transactions', 'savingsTotal', 'piggyBankAccounts'));
}
/**
* @codeCoverageIgnore
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function routes()
{
$directory = '/vagrant_data/Sites/firefly-iii-help';
$languages = array_keys(Config::get('firefly.lang'));
$routes = [];
$ignored = [
'debugbar.openhandler', 'debugbar.assets.css', 'debugbar.assets.js', 'register', 'routes', 'daterange',
'flush', 'delete-account-post', 'change-password-post', 'logout', 'login', 'tags.hideTagHelp',
'budgets.postIncome', 'flush'
];
$ignoreMatch = ['.store', '.update', '.destroy', 'json.'];
$routeCollection = Route::getRoutes();
/** @var \Illuminate\Routing\Route $object */
foreach ($routeCollection as $object) {
// get name:
$name = $object->getName();
// has name and not in ignore list?
if (strlen($name) > 0 && !in_array($name, $ignored)) {
// not in ignoreMatch?
$continue = true;
foreach ($ignoreMatch as $ignore) {
$match = strpos($name, $ignore);
if (!($match === false)) {
$continue = false;
}
}
unset($ignore, $match);
if ($continue) {
$routes[] = $name;
// check all languages:
foreach ($languages as $lang) {
$file = $directory . '/' . $lang . '/' . $name . '.md';
if (!file_exists($file)) {
touch($file);
echo $name . '<br />';
}
}
}
}
}
// loop directories with language file.
// tag the ones not in the list of approved routes.
foreach ($languages as $lang) {
$dir = $directory . '/' . $lang;
$set = scandir($dir);
foreach ($set as $entry) {
if ($entry != '.' && $entry != '..') {
$name = str_replace('.md', '', $entry);
if (!in_array($name, $routes)) {
$file = $dir . '/' . $entry;
unlink($file);
}
}
}
}
echo 'Done!';
}
}

View File

@ -193,6 +193,7 @@ Route::controllers(
]
);
Route::get('/routes', ['uses' => 'HomeController@routes', 'as' => 'routes']);
/**
* Home Controller

View File

@ -18,6 +18,7 @@ class Account extends Model
use SoftDeletes, ValidatingTrait;
protected $fillable = ['user_id', 'account_type_id', 'name', 'active', 'virtual_balance'];
protected $hidden = ['virtual_balance_encrypted', 'encrypted'];
protected $rules
= [
'user_id' => 'required|exists:users,id',
@ -116,6 +117,7 @@ class Account extends Model
/**
*
* @param $fieldName
* @codeCoverageIgnore
*
* @return string|null
*/
@ -151,7 +153,7 @@ class Account extends Model
/**
* @param $value
*
* @codeCoverageIgnore
* @return float|int
*/
public function getVirtualBalanceAttribute($value)
@ -220,6 +222,7 @@ class Account extends Model
/**
* @param $value
* @codeCoverageIgnore
*/
public function setVirtualBalanceAttribute($value)
{

View File

@ -4,6 +4,7 @@ use Crypt;
use Illuminate\Database\Eloquent\Model;
/**
* @codeCoverageIgnore
* Class Bill
*
* @package FireflyIII\Models
@ -14,6 +15,8 @@ class Bill extends Model
protected $fillable
= ['name', 'match', 'amount_min', 'match_encrypted', 'name_encrypted', 'user_id', 'amount_max', 'date', 'repeat_freq', 'skip', 'automatch', 'active',];
protected $hidden = ['amount_min_encrypted', 'amount_max_encrypted', 'name_encrypted', 'match_encrypted'];
/**
* @param $value
*
@ -31,6 +34,7 @@ class Bill extends Model
}
/**
*
* @param $value
*
* @return float|int
@ -66,9 +70,7 @@ class Bill extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**
@ -83,9 +85,7 @@ class Bill extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**

View File

@ -15,7 +15,8 @@ class Budget extends Model
use SoftDeletes;
protected $fillable = ['user_id', 'name'];
protected $fillable = ['user_id', 'name', 'active'];
protected $hidden = ['encrypted'];
/**
*
@ -46,9 +47,7 @@ class Budget extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**

View File

@ -12,6 +12,8 @@ use Illuminate\Database\Eloquent\Model;
class BudgetLimit extends Model
{
protected $hidden = ['amount_encrypted'];
/**
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/

View File

@ -16,24 +16,7 @@ class Category extends Model
use SoftDeletes;
protected $fillable = ['user_id', 'name'];
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'deleted_at'];
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');
}
protected $hidden = ['encrypted'];
/**
* @param array $fields
@ -71,22 +54,11 @@ class Category extends Model
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
* @return array
*/
public function user()
public function getDates()
{
return $this->belongsTo('FireflyIII\User');
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
return ['created_at', 'updated_at', 'deleted_at'];
}
/**
@ -106,4 +78,33 @@ class Category extends Model
return $value;
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
public function setNameAttribute($value)
{
$this->attributes['name'] = Crypt::encrypt($value);
$this->attributes['encrypted'] = true;
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
{
return $this->belongsToMany('FireflyIII\Models\TransactionJournal', 'category_transaction_journal', 'category_id');
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo('FireflyIII\User');
}
}

View File

@ -1,20 +1,21 @@
<?php namespace FireflyIII\Models;
use Auth;
use Crypt;
use DB;
use Illuminate\Database\Eloquent\Model;
/**
* Class LimitRepetition
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class LimitRepetition extends Model
{
protected $hidden = ['amount_encrypted'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function budgetLimit()
@ -22,15 +23,6 @@ class LimitRepetition extends Model
return $this->belongsTo('FireflyIII\Models\BudgetLimit');
}
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'startdate', 'enddate'];
}
/**
* @param $value
*
@ -47,6 +39,14 @@ class LimitRepetition extends Model
return $value;
}
/**
* @return array
*/
public function getDates()
{
return ['created_at', 'updated_at', 'startdate', 'enddate'];
}
/**
* @param $value
*/

View File

@ -7,6 +7,8 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class PiggyBank
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class PiggyBank extends Model
@ -15,9 +17,9 @@ class PiggyBank extends Model
protected $fillable
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
protected $hidden = ['targetamount_encrypted', 'encrypted'];
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function account()
@ -45,7 +47,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankRepetitions()
@ -54,7 +55,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
@ -63,7 +63,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@ -76,13 +75,10 @@ class PiggyBank extends Model
return Crypt::decrypt($value);
}
// @codeCoverageIgnoreStart
return $value;
// @codeCoverageIgnoreEnd
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@ -110,7 +106,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
@ -119,7 +114,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reminders()
@ -128,7 +122,6 @@ class PiggyBank extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*/

View File

@ -7,12 +7,14 @@ use Illuminate\Database\Eloquent\Model;
* Class PiggyBankEvent
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class PiggyBankEvent extends Model
{
protected $fillable = ['piggy_bank_id', 'transaction_journal_id', 'date', 'amount'];
protected $hidden = ['amount_encrypted'];
/**
* @param $value

View File

@ -15,6 +15,7 @@ class PiggyBankRepetition extends Model
{
protected $fillable = ['piggy_bank_id', 'startdate', 'targetdate', 'currentamount'];
protected $hidden = ['currentamount_encrypted'];
/**
* @return array

View File

@ -13,6 +13,7 @@ class Preference extends Model
{
protected $fillable = ['user_id', 'data', 'name'];
protected $hidden = ['data_encrypted', 'name_encrypted'];
/**
* @param $value

View File

@ -8,6 +8,8 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class Reminder
*
* @codeCoverageIgnore
*
* @package FireflyIII\Models
*/
class Reminder extends Model
@ -15,9 +17,9 @@ class Reminder extends Model
protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',];
protected $hidden = ['encrypted'];
/**
* @codeCoverageIgnore
*
* @param $value
*
@ -29,7 +31,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
* @return array
*/
public function getDates()
@ -38,7 +39,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@ -54,7 +54,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*
@ -66,7 +65,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function remindersable()
@ -75,7 +73,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
* @param Carbon $start
@ -89,7 +86,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param EloquentBuilder $query
*
@ -104,7 +100,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
*
* @param $value
*/
@ -115,7 +110,6 @@ class Reminder extends Model
}
/**
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()

View File

@ -17,6 +17,7 @@ class Transaction extends Model
{
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount'];
protected $hidden = ['encrypted'];
protected $rules
= [
'account_id' => 'required|exists:accounts,id',

View File

@ -6,7 +6,6 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\JoinClause;
use Watson\Validating\ValidatingTrait;
/**
@ -19,7 +18,7 @@ class TransactionJournal extends Model
use SoftDeletes, ValidatingTrait;
protected $fillable = ['user_id', 'transaction_type_id', 'bill_id', 'transaction_currency_id', 'description', 'completed', 'date', 'encrypted'];
protected $hidden = ['encrypted'];
protected $rules
= [
'user_id' => 'required|exists:users,id',

View File

@ -145,6 +145,7 @@ class CategoryControllerTest extends TestCase
}
public function testStore()
{
// create

View File

@ -231,6 +231,8 @@ class TransactionControllerTest extends TestCase
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Models\Category::firstOrCreateEncrypted
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testStore()
{
@ -254,7 +256,7 @@ class TransactionControllerTest extends TestCase
'budget_id' => '0',
'create_another' => '1',
'category' => '',
'tags' => '',
'tags' => 'fat-test',
'piggy_bank_id' => '0',
'_token' => 'replaceMe',
];
@ -277,6 +279,8 @@ class TransactionControllerTest extends TestCase
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Models\Category::firstOrCreateEncrypted
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testStoreTransfer()
{
@ -314,7 +318,7 @@ class TransactionControllerTest extends TestCase
'budget_id' => '0',
'create_another' => '1',
'category' => '',
'tags' => '',
'tags' => 'fat-test',
'piggy_bank_id' => $piggy->id,
'_token' => 'replaceMe',
];
@ -337,6 +341,8 @@ class TransactionControllerTest extends TestCase
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Models\Category::firstOrCreateEncrypted
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testUpdate()
{
@ -362,7 +368,7 @@ class TransactionControllerTest extends TestCase
'date' => '2015-05-31',
'budget_id' => '0',
'category' => 'Lunch',
'tags' => '',
'tags' => 'fat-test',
'piggy_bank_id' => '0',
];
@ -385,6 +391,8 @@ class TransactionControllerTest extends TestCase
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @covers FireflyIII\Models\Category::firstOrCreateEncrypted
* @covers FireflyIII\Models\Tag::firstOrCreateEncrypted
*/
public function testUpdateWithRedirect()
{
@ -411,7 +419,7 @@ class TransactionControllerTest extends TestCase
'budget_id' => '0',
'category' => 'Lunch',
'return_to_edit' => 1,
'tags' => '',
'tags' => 'fat-test',
'piggy_bank_id' => '0',
];

View File

@ -611,6 +611,7 @@ class AccountRepositoryTest extends TestCase
* @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount
* @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata
* @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance
*
*/
public function testStore()
{
@ -686,6 +687,7 @@ class AccountRepositoryTest extends TestCase
* @covers FireflyIII\Repositories\Account\AccountRepository::storeAccount
* @covers FireflyIII\Repositories\Account\AccountRepository::storeMetadata
* @covers FireflyIII\Repositories\Account\AccountRepository::storeInitialBalance
* @covers FireflyII\Models\Account::firstOrNullEncrypted
* @expectedException Symfony\Component\HttpKernel\Exception\HttpException
*/
public function testStoreWithInvalidAccountData()