Various bug fixes and extensions to test routine.

This commit is contained in:
James Cole 2016-12-25 11:50:42 +01:00
parent 5b5acba816
commit f2f9f8fbab
5 changed files with 24 additions and 19 deletions

View File

@ -11,8 +11,6 @@ install:
- php artisan clear-compiled
- php artisan optimize
- php artisan env
- ./test.sh -r
- php artisan env
script:
- phpunit

View File

@ -124,16 +124,16 @@ class VerifyDatabase extends Command
{
$set = Budget::leftJoin('budget_limits', 'budget_limits.budget_id', '=', 'budgets.id')
->leftJoin('users', 'budgets.user_id', '=', 'users.id')
->groupBy(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email'])
->groupBy(['budgets.id', 'budgets.name', 'budgets.encrypted', 'budgets.user_id', 'users.email'])
->whereNull('budget_limits.id')
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'users.email']);
->get(['budgets.id', 'budgets.name', 'budgets.user_id', 'budgets.encrypted', 'users.email']);
/** @var stdClass $entry */
/** @var Budget $entry */
foreach ($set as $entry) {
$name = $entry->encrypted ? Crypt::decrypt($entry->name) : $entry->name;
$line = sprintf(
'Notice: User #%d (%s) has budget #%d ("%s") which has no budget limits.',
$entry->user_id, $entry->email, $entry->id, Crypt::decrypt($entry->name)
$entry->user_id, $entry->email, $entry->id, $name
);
$this->line($line);
}

View File

@ -60,6 +60,7 @@ class JournalCollector implements JournalCollectorInterface
'transaction_types.type as transaction_type_type',
'transaction_journals.bill_id',
'bills.name as bill_name',
'bills.name_encrypted as bill_name_encrypted',
'transactions.id as id',
'transactions.amount as transaction_amount',
'transactions.description as transaction_description',
@ -180,10 +181,12 @@ class JournalCollector implements JournalCollectorInterface
$set->each(
function (Transaction $transaction) {
$transaction->date = new Carbon($transaction->date);
$transaction->description = intval($transaction->encrypted) === 1 ? Crypt::decrypt($transaction->description) : $transaction->description;
$transaction->bill_name = !is_null($transaction->bill_name) ? Crypt::decrypt($transaction->bill_name) : '';
$transaction->description = $transaction->encrypted ? Crypt::decrypt($transaction->description) : $transaction->description;
if (!is_null($transaction->bill_name)) {
$transaction->bill_name = $transaction->bill_name_encrypted ? Crypt::decrypt($transaction->bill_name) : $transaction->bill_name;
}
// optionally decrypted:
try {
$transaction->opposing_account_name = Crypt::decrypt($transaction->opposing_account_name);
} catch (DecryptException $e) {

View File

@ -33,11 +33,13 @@ class Transaction extends Model
* @var array
*/
protected $casts
= [
'created_at' => 'date',
'updated_at' => 'date',
'deleted_at' => 'date',
'identifier' => 'int',
= [
'created_at' => 'date',
'updated_at' => 'date',
'deleted_at' => 'date',
'identifier' => 'int',
'encrypted' => 'boolean', // model does not have these fields though
'bill_name_encrypted' => 'boolean',
];
protected $dates = ['created_at', 'updated_at', 'deleted_at'];
protected $fillable = ['account_id', 'transaction_journal_id', 'description', 'amount', 'identifier'];

10
test.sh
View File

@ -7,7 +7,7 @@ BACKUPENV=./.env.current
TESTINGENV=./.env.testing
# do something with flags:
resetestflag=''
resetTestFlag=''
testflag=''
coverageflag=''
acceptancetestclass=''
@ -17,7 +17,7 @@ testsuite=''
while getopts 'vcrta:s:' flag; do
case "${flag}" in
r)
resetestflag='true'
resetTestFlag='true'
;;
t)
testflag='true'
@ -55,7 +55,7 @@ cp $TESTINGENV $ORIGINALENV
php artisan cache:clear
# reset database (optional)
if [[ $resetestflag == "true" ]]
if [[ $resetTestFlag == "true" ]]
then
echo "Must reset database"
@ -69,12 +69,14 @@ then
# run migration
php artisan migrate:refresh --seed
# call test data generation script
$(which php) /sites/FF3/test-data/artisan generate:data testing sqlite
# copy new database over backup (resets backup)
cp $DATABASE $DATABASECOPY
fi
# do not reset database (optional)
if [[ $resetestflag == "" ]]
if [[ $resetTestFlag == "" ]]
then
echo "Will not reset database"
fi