diff --git a/.env.example b/.env.example
index ce0218faf1..9259db3b04 100644
--- a/.env.example
+++ b/.env.example
@@ -15,4 +15,5 @@ EMAIL_SMTP=
EMAIL_DRIVER=smtp
EMAIL_USERNAME=
EMAIL_PASSWORD=
-ANALYTICS_ID=
\ No newline at end of file
+ANALYTICS_ID=
+EMAIL_PRETEND=false
\ No newline at end of file
diff --git a/.env.testing b/.env.testing
index 789c5a2b02..5443422bda 100644
--- a/.env.testing
+++ b/.env.testing
@@ -14,4 +14,5 @@ SESSION_DRIVER=array
EMAIL_SMTP=
EMAIL_USERNAME=
EMAIL_PASSWORD=
-ANALYTICS_ID=ABC
\ No newline at end of file
+ANALYTICS_ID=ABC
+EMAIL_PRETEND=true
\ No newline at end of file
diff --git a/README.md b/README.md
index 7ff58eb737..630cd679d7 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
# Firefly III
-#### v3.4.0.4
+#### v3.4.0.5
[](https://travis-ci.org/JC5/firefly-iii)
[](http://stillmaintained.com/JC5/firefly-iii)
diff --git a/app/Commands/Command.php b/app/Commands/Command.php
index 095393f3fa..1212b4e554 100644
--- a/app/Commands/Command.php
+++ b/app/Commands/Command.php
@@ -2,6 +2,7 @@
/**
* Class Command
*
+ * @codeCoverageIgnore
* @package FireflyIII\Commands
*/
abstract class Command
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index b8ebcaae70..07e2bb7ece 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -6,6 +6,7 @@ use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
/**
* Class Kernel
*
+ * @codeCoverageIgnore
* @package FireflyIII\Console
*/
class Kernel extends ConsoleKernel
diff --git a/app/Events/Event.php b/app/Events/Event.php
index 3d82e4d1dd..6d2ccc442c 100644
--- a/app/Events/Event.php
+++ b/app/Events/Event.php
@@ -3,6 +3,7 @@
/**
* Class Event
*
+ * @codeCoverageIgnore
* @package FireflyIII\Events
*/
abstract class Event
diff --git a/app/Events/JournalCreated.php b/app/Events/JournalCreated.php
index 65c8929d4b..4b9ef60b9c 100644
--- a/app/Events/JournalCreated.php
+++ b/app/Events/JournalCreated.php
@@ -6,6 +6,7 @@ use Illuminate\Queue\SerializesModels;
/**
* Class JournalCreated
*
+ * @codeCoverageIgnore
* @package FireflyIII\Events
*/
class JournalCreated extends Event
diff --git a/app/Events/JournalDeleted.php b/app/Events/JournalDeleted.php
index eadf06bb81..575697e6f9 100644
--- a/app/Events/JournalDeleted.php
+++ b/app/Events/JournalDeleted.php
@@ -5,6 +5,7 @@ use Illuminate\Queue\SerializesModels;
/**
* Class JournalDeleted
*
+ * @codeCoverageIgnore
* @package FireflyIII\Events
*/
class JournalDeleted extends Event
diff --git a/app/Events/JournalSaved.php b/app/Events/JournalSaved.php
index e3a8a37da0..f4d640cbf7 100644
--- a/app/Events/JournalSaved.php
+++ b/app/Events/JournalSaved.php
@@ -6,6 +6,7 @@ use Illuminate\Queue\SerializesModels;
/**
* Class JournalSaved
*
+ * @codeCoverageIgnore
* @package FireflyIII\Events
*/
class JournalSaved extends Event
diff --git a/app/Exceptions/FireflyException.php b/app/Exceptions/FireflyException.php
index a0079fa618..c81f61eb7f 100644
--- a/app/Exceptions/FireflyException.php
+++ b/app/Exceptions/FireflyException.php
@@ -6,6 +6,7 @@ namespace FireflyIII\Exceptions;
/**
* Class FireflyException
*
+ * @codeCoverageIgnore
* @package FireflyIII\Exceptions
*/
class FireflyException extends \Exception
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index 23521f7c0f..5bf9d44d91 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -6,6 +6,7 @@ use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
/**
* Class Handler
*
+ * @codeCoverageIgnore
* @package FireflyIII\Exceptions
*/
class Handler extends ExceptionHandler
diff --git a/app/Exceptions/NotImplementedException.php b/app/Exceptions/NotImplementedException.php
index 614a9b7f97..c1f3ed4500 100644
--- a/app/Exceptions/NotImplementedException.php
+++ b/app/Exceptions/NotImplementedException.php
@@ -5,6 +5,7 @@ namespace FireflyIII\Exceptions;
/**
* Class NotImplementedException
*
+ * @codeCoverageIgnore
* @package FireflyIII\Exceptions
*/
class NotImplementedException extends \Exception
diff --git a/app/Exceptions/ValidationException.php b/app/Exceptions/ValidationException.php
index 71922fe9c1..aba658ac9b 100644
--- a/app/Exceptions/ValidationException.php
+++ b/app/Exceptions/ValidationException.php
@@ -4,6 +4,7 @@ namespace FireflyIII\Exceptions;
/**
* Class ValidationExceptions
*
+ * @codeCoverageIgnore
* @package FireflyIII\Exception
*/
class ValidationException extends \Exception
diff --git a/app/Handlers/Events/JournalDeletedHandler.php b/app/Handlers/Events/JournalDeletedHandler.php
index bcc3782511..757738ba62 100644
--- a/app/Handlers/Events/JournalDeletedHandler.php
+++ b/app/Handlers/Events/JournalDeletedHandler.php
@@ -5,6 +5,7 @@ use FireflyIII\Events\JournalDeleted;
/**
* Class JournalDeletedHandler
*
+ * @codeCoverageIgnore
* @package FireflyIII\Handlers\Events
*/
class JournalDeletedHandler
diff --git a/app/Http/Controllers/Auth/AuthController.php b/app/Http/Controllers/Auth/AuthController.php
index 079ec4dcf3..27c50adb65 100644
--- a/app/Http/Controllers/Auth/AuthController.php
+++ b/app/Http/Controllers/Auth/AuthController.php
@@ -38,6 +38,7 @@ class AuthController extends Controller
*
* @param \Illuminate\Contracts\Auth\Guard $auth
* @param \Illuminate\Contracts\Auth\Registrar $registrar
+ * @codeCoverageIgnore
*
*/
public function __construct(Guard $auth, Registrar $registrar)
@@ -51,7 +52,9 @@ class AuthController extends Controller
/**
* Show the application login form.
*
+ * @codeCoverageIgnore
* @return \Illuminate\Http\Response
+ *
*/
public function getLogin()
{
@@ -73,7 +76,9 @@ class AuthController extends Controller
$this->throwValidationException(
$request, $validator
);
+ // @codeCoverageIgnoreStart
}
+ // @codeCoverageIgnoreEnd
$data = $request->all();
$data['password'] = bcrypt($data['password']);
diff --git a/app/Http/Controllers/Auth/PasswordController.php b/app/Http/Controllers/Auth/PasswordController.php
index 2d9ebced35..907b514894 100644
--- a/app/Http/Controllers/Auth/PasswordController.php
+++ b/app/Http/Controllers/Auth/PasswordController.php
@@ -7,7 +7,7 @@ use Illuminate\Foundation\Auth\ResetsPasswords;
/**
* Class PasswordController
- *
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Controllers\Auth
*/
class PasswordController extends Controller
diff --git a/app/Http/Controllers/GoogleChartController.php b/app/Http/Controllers/GoogleChartController.php
index 0c7b0f218e..96fd291304 100644
--- a/app/Http/Controllers/GoogleChartController.php
+++ b/app/Http/Controllers/GoogleChartController.php
@@ -187,17 +187,6 @@ class GoogleChartController extends Controller
if ($entry[1] != 0 || $entry[2] != 0 || $entry[3] != 0) {
$chart->addRow($entry[0], $entry[1], $entry[2], $entry[3]);
}
- // if ($entry[2] > 0) {
- // $left = $entry[1] - $entry[2];
- // if ($left > 0) {
- // $chart->addRow($entry[0], $left, null);
- // } else {
- // if ($left < 0) {
- // $chart->addRow($entry[0], null, $left);
- // }
- // }
- //
- // }
}
$chart->generate();
diff --git a/app/Http/Middleware/Authenticate.php b/app/Http/Middleware/Authenticate.php
index 23b18019a4..f5cfcdd144 100644
--- a/app/Http/Middleware/Authenticate.php
+++ b/app/Http/Middleware/Authenticate.php
@@ -7,6 +7,7 @@ use Illuminate\Http\Request;
/**
* Class Authenticate
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class Authenticate
diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php
index 237bbe02ce..b5419be62c 100644
--- a/app/Http/Middleware/RedirectIfAuthenticated.php
+++ b/app/Http/Middleware/RedirectIfAuthenticated.php
@@ -8,6 +8,7 @@ use Illuminate\Http\Request;
/**
* Class RedirectIfAuthenticated
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class RedirectIfAuthenticated
diff --git a/app/Http/Middleware/ReplaceTestVars.php b/app/Http/Middleware/ReplaceTestVars.php
index bc75e07f7c..5e90f0253c 100644
--- a/app/Http/Middleware/ReplaceTestVars.php
+++ b/app/Http/Middleware/ReplaceTestVars.php
@@ -10,6 +10,7 @@ use Log;
/**
* Class ReplaceTestVars
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class ReplaceTestVars
diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php
index 0cb1548af8..f6bd70ec03 100644
--- a/app/Http/Middleware/VerifyCsrfToken.php
+++ b/app/Http/Middleware/VerifyCsrfToken.php
@@ -6,6 +6,7 @@ use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
/**
* Class VerifyCsrfToken
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Middleware
*/
class VerifyCsrfToken extends BaseVerifier
diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php
index 370415f26f..83275c966d 100644
--- a/app/Http/Requests/AccountFormRequest.php
+++ b/app/Http/Requests/AccountFormRequest.php
@@ -10,6 +10,7 @@ use Input;
/**
* Class AccountFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class AccountFormRequest extends Request
diff --git a/app/Http/Requests/BillFormRequest.php b/app/Http/Requests/BillFormRequest.php
index 49dc166af6..452e5a1e7a 100644
--- a/app/Http/Requests/BillFormRequest.php
+++ b/app/Http/Requests/BillFormRequest.php
@@ -9,6 +9,7 @@ use Input;
/**
* Class BillFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class BillFormRequest extends Request
diff --git a/app/Http/Requests/BudgetFormRequest.php b/app/Http/Requests/BudgetFormRequest.php
index 452acc42e2..ad871cd07b 100644
--- a/app/Http/Requests/BudgetFormRequest.php
+++ b/app/Http/Requests/BudgetFormRequest.php
@@ -9,6 +9,7 @@ use Input;
/**
* Class BudgetFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class BudgetFormRequest extends Request
diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.php
index 7c02b57152..7c32b3329c 100644
--- a/app/Http/Requests/CategoryFormRequest.php
+++ b/app/Http/Requests/CategoryFormRequest.php
@@ -9,6 +9,7 @@ use Input;
/**
* Class CategoryFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class CategoryFormRequest extends Request
diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.php
index 96b471790e..d2de6cfad1 100644
--- a/app/Http/Requests/CurrencyFormRequest.php
+++ b/app/Http/Requests/CurrencyFormRequest.php
@@ -8,6 +8,7 @@ use Input;
/**
* Class BillFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class CurrencyFormRequest extends Request
diff --git a/app/Http/Requests/DeleteAccountFormRequest.php b/app/Http/Requests/DeleteAccountFormRequest.php
index 68dbe811a3..895c3d4183 100644
--- a/app/Http/Requests/DeleteAccountFormRequest.php
+++ b/app/Http/Requests/DeleteAccountFormRequest.php
@@ -7,6 +7,7 @@ use Auth;
/**
* Class DeleteAccountFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class DeleteAccountFormRequest extends Request
diff --git a/app/Http/Requests/JournalFormRequest.php b/app/Http/Requests/JournalFormRequest.php
index 47db30f2b9..2ae445e1e9 100644
--- a/app/Http/Requests/JournalFormRequest.php
+++ b/app/Http/Requests/JournalFormRequest.php
@@ -10,6 +10,7 @@ use Input;
/**
* Class JournalFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class JournalFormRequest extends Request
diff --git a/app/Http/Requests/PiggyBankFormRequest.php b/app/Http/Requests/PiggyBankFormRequest.php
index 86b9d3ec23..f4878aeea6 100644
--- a/app/Http/Requests/PiggyBankFormRequest.php
+++ b/app/Http/Requests/PiggyBankFormRequest.php
@@ -8,6 +8,7 @@ use Input;
/**
* Class PiggyBankFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class PiggyBankFormRequest extends Request
diff --git a/app/Http/Requests/ProfileFormRequest.php b/app/Http/Requests/ProfileFormRequest.php
index 8bac377a5b..932873318b 100644
--- a/app/Http/Requests/ProfileFormRequest.php
+++ b/app/Http/Requests/ProfileFormRequest.php
@@ -7,6 +7,7 @@ use Auth;
/**
* Class ProfileFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class ProfileFormRequest extends Request
diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php
index a5c9945e32..73c38578b3 100644
--- a/app/Http/Requests/Request.php
+++ b/app/Http/Requests/Request.php
@@ -5,6 +5,7 @@ use Illuminate\Foundation\Http\FormRequest;
/**
* Class Request
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
abstract class Request extends FormRequest
diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php
index 3909b177b2..777288d5a8 100644
--- a/app/Http/Requests/TagFormRequest.php
+++ b/app/Http/Requests/TagFormRequest.php
@@ -15,6 +15,7 @@ use Input;
/**
* Class TagFormRequest
*
+ * @codeCoverageIgnore
* @package FireflyIII\Http\Requests
*/
class TagFormRequest extends Request
diff --git a/app/Http/breadcrumbs.php b/app/Http/breadcrumbs.php
index 7705a04648..a038774e44 100644
--- a/app/Http/breadcrumbs.php
+++ b/app/Http/breadcrumbs.php
@@ -319,7 +319,7 @@ Breadcrumbs::register(
Breadcrumbs::register(
'reports.month', function (Generator $breadcrumbs, Carbon $date) {
- $breadcrumbs->parent('reports.index');
+ $breadcrumbs->parent('reports.year', $date);
$breadcrumbs->push('Monthly report for ' . $date->format('F Y'), route('reports.month', [$date->year, $date->month]));
}
);
diff --git a/app/Models/Account.php b/app/Models/Account.php
index dcea8ec26e..e9e39346f5 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -29,6 +29,7 @@ class Account extends Model
/**
* @param array $fields
*
+ *
* @return Account|null
*/
public static function firstOrCreateEncrypted(array $fields)
@@ -86,6 +87,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function accountMeta()
@@ -94,6 +96,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function accountType()
@@ -102,6 +105,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -110,6 +114,7 @@ class Account extends Model
}
/**
+ *
* @param $fieldName
*
* @return string|null
@@ -127,6 +132,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return string
@@ -144,6 +150,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBanks()
@@ -152,6 +159,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param array $types
*/
@@ -165,6 +173,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param string $name
* @param string $value
@@ -181,6 +190,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setNameAttribute($value)
@@ -190,6 +200,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactions()
@@ -198,6 +209,7 @@ class Account extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php
index 16e6f7a91b..960d3d7759 100644
--- a/app/Models/AccountMeta.php
+++ b/app/Models/AccountMeta.php
@@ -6,6 +6,7 @@ use Watson\Validating\ValidatingTrait;
/**
* Class AccountMeta
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class AccountMeta extends Model
@@ -22,6 +23,7 @@ class AccountMeta extends Model
protected $table = 'account_meta';
/**
+ *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function account()
diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php
index aee84c7c1e..4d17499645 100644
--- a/app/Models/AccountType.php
+++ b/app/Models/AccountType.php
@@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class AccountType
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class AccountType extends Model
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 63a7e3979b..7272639eac 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Budget
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class Budget extends Model
@@ -17,6 +18,7 @@ class Budget extends Model
protected $fillable = ['user_id', 'name'];
/**
+ *
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function budgetlimits()
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 5189d91664..25bf48a4b4 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class BudgetLimit
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class BudgetLimit extends Model
diff --git a/app/Models/Category.php b/app/Models/Category.php
index 12efc295b6..363f773d2a 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Category
*
+ *
* @package FireflyIII\Models
*/
class Category extends Model
@@ -17,6 +18,7 @@ class Category extends Model
protected $fillable = ['user_id', 'name'];
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -25,6 +27,7 @@ class Category extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
@@ -66,6 +69,7 @@ class Category extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
@@ -74,6 +78,7 @@ class Category extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setNameAttribute($value)
@@ -83,6 +88,7 @@ class Category extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return string
@@ -94,9 +100,7 @@ class Category extends Model
return Crypt::decrypt($value);
}
- // @codeCoverageIgnoreStart
return $value;
- // @codeCoverageIgnoreEnd
}
}
diff --git a/app/Models/Component.php b/app/Models/Component.php
index a17450943d..cac107270a 100644
--- a/app/Models/Component.php
+++ b/app/Models/Component.php
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class Component
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class Component extends Model
diff --git a/app/Models/LimitRepetition.php b/app/Models/LimitRepetition.php
index 129e0a4901..3faef2b46d 100644
--- a/app/Models/LimitRepetition.php
+++ b/app/Models/LimitRepetition.php
@@ -13,6 +13,7 @@ class LimitRepetition extends Model
{
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function budgetLimit()
@@ -21,6 +22,7 @@ class LimitRepetition extends Model
}
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php
index 7d00585d6c..9879b3f1a8 100644
--- a/app/Models/PiggyBank.php
+++ b/app/Models/PiggyBank.php
@@ -17,6 +17,7 @@ class PiggyBank extends Model
= ['name', 'account_id', 'order', 'reminder_skip', 'targetamount', 'startdate', 'targetdate', 'reminder', 'remind_me'];
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function account()
@@ -44,6 +45,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankRepetitions()
@@ -52,6 +54,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -60,6 +63,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return int
@@ -70,6 +74,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
@@ -78,6 +83,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphMany
*/
public function reminders()
@@ -86,6 +92,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setNameAttribute($value)
@@ -95,6 +102,7 @@ class PiggyBank extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return string
diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php
index 775a4e310d..4a54c0b3f2 100644
--- a/app/Models/PiggyBankEvent.php
+++ b/app/Models/PiggyBankEvent.php
@@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class PiggyBankEvent
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class PiggyBankEvent extends Model
diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php
index 07202b672e..12019da640 100644
--- a/app/Models/PiggyBankRepetition.php
+++ b/app/Models/PiggyBankRepetition.php
@@ -7,6 +7,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class PiggyBankRepetition
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class PiggyBankRepetition extends Model
diff --git a/app/Models/Preference.php b/app/Models/Preference.php
index b0c1cb7d03..86c5dd9f40 100644
--- a/app/Models/Preference.php
+++ b/app/Models/Preference.php
@@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class Preference
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class Preference extends Model
diff --git a/app/Models/Reminder.php b/app/Models/Reminder.php
index f6116b2754..0160f1a9f1 100644
--- a/app/Models/Reminder.php
+++ b/app/Models/Reminder.php
@@ -17,6 +17,7 @@ class Reminder extends Model
protected $fillable = ['user_id', 'startdate', 'metadata', 'enddate', 'active', 'notnow', 'remindersable_id', 'remindersable_type',];
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return int
@@ -27,6 +28,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -35,6 +37,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return mixed
@@ -49,6 +52,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return bool
@@ -59,6 +63,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\MorphTo
*/
public function remindersable()
@@ -67,6 +72,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param Carbon $start
* @param Carbon $end
@@ -79,6 +85,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
*
* @return $this
@@ -92,6 +99,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setMetadataAttribute($value)
@@ -101,6 +109,7 @@ class Reminder extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index 11ce119559..286a481fc0 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -67,6 +67,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -75,6 +76,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return string
@@ -85,6 +87,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return string
@@ -95,6 +98,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setDescriptionAttribute($value)
@@ -103,6 +107,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setTagAttribute($value)
@@ -111,6 +116,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactionjournals()
@@ -119,6 +125,7 @@ class Tag extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index 85f8e74e17..447c3085e0 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -9,6 +9,7 @@ use Watson\Validating\ValidatingTrait;
/**
* Class Transaction
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class Transaction extends Model
diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php
index 9283709f9e..a91c2df889 100644
--- a/app/Models/TransactionCurrency.php
+++ b/app/Models/TransactionCurrency.php
@@ -4,8 +4,10 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
+ *
* Class TransactionCurrency
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class TransactionCurrency extends Model
diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php
index 3afbdba0f4..31e93d90fe 100644
--- a/app/Models/TransactionGroup.php
+++ b/app/Models/TransactionGroup.php
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class TransactionGroup
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class TransactionGroup extends Model
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index 6f49c9669a..7fd1e4db4c 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -32,6 +32,7 @@ class TransactionJournal extends Model
];
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function bill()
@@ -40,6 +41,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function budgets()
@@ -48,6 +50,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function categories()
@@ -94,6 +97,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function transactions()
@@ -102,6 +106,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return array
*/
public function getDates()
@@ -110,6 +115,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*
* @return string
@@ -120,12 +126,11 @@ class TransactionJournal extends Model
return Crypt::decrypt($value);
}
- // @codeCoverageIgnoreStart
return $value;
- // @codeCoverageIgnoreEnd
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
@@ -134,6 +139,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param Account $account
*/
@@ -147,6 +153,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param Carbon $date
*
@@ -158,6 +165,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param Carbon $date
*
@@ -169,6 +177,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param $amount
*/
@@ -185,6 +194,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param Carbon $date
*
@@ -196,6 +206,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param EloquentBuilder $query
* @param array $types
*/
@@ -211,6 +222,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* Automatically includes the 'with' parameters to get relevant related
* objects.
*
@@ -226,6 +238,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @param $value
*/
public function setDescriptionAttribute($value)
@@ -235,6 +248,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function tags()
@@ -243,6 +257,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function transactionCurrency()
@@ -251,6 +266,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function transactionType()
@@ -259,6 +275,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
*/
public function transactiongroups()
@@ -267,6 +284,7 @@ class TransactionJournal extends Model
}
/**
+ * @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
diff --git a/app/Models/TransactionRelation.php b/app/Models/TransactionRelation.php
index 058f395537..aa4d3810af 100644
--- a/app/Models/TransactionRelation.php
+++ b/app/Models/TransactionRelation.php
@@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model;
/**
* Class TransactionRelation
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class TransactionRelation extends Model
diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php
index dbabd104f8..cee923cfc2 100644
--- a/app/Models/TransactionType.php
+++ b/app/Models/TransactionType.php
@@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
/**
* Class TransactionType
*
+ * @codeCoverageIgnore
* @package FireflyIII\Models
*/
class TransactionType extends Model
diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php
index c4d042b13e..066ee64665 100644
--- a/app/Providers/FireflyServiceProvider.php
+++ b/app/Providers/FireflyServiceProvider.php
@@ -10,6 +10,7 @@ use FireflyIII\Support\Preferences;
use FireflyIII\Support\Steam;
use FireflyIII\Support\Twig\Budget;
use FireflyIII\Support\Twig\General;
+use FireflyIII\Support\Twig\Translation;
use FireflyIII\Support\Twig\Journal;
use FireflyIII\Support\Twig\PiggyBank;
use FireflyIII\Validation\FireflyValidator;
@@ -42,6 +43,7 @@ class FireflyServiceProvider extends ServiceProvider
Twig::addExtension(new General);
Twig::addExtension(new Journal);
Twig::addExtension(new Budget);
+ Twig::addExtension(new Translation);
}
public function register()
diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php
index 180f6d870a..012a144bdb 100644
--- a/app/Repositories/Journal/JournalRepository.php
+++ b/app/Repositories/Journal/JournalRepository.php
@@ -137,7 +137,7 @@ class JournalRepository implements JournalRepositoryInterface
*/
public function getWithDate($id, Carbon $date)
{
- return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d'))->first();
+ return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d 00:00:00'))->first();
}
/**
@@ -379,14 +379,19 @@ class JournalRepository implements JournalRepositoryInterface
$to = Account::find($data['account_to_id']);
break;
}
- if (is_null($to->id)) {
+ if (is_null($to) || (!is_null($to) && is_null($to->id))) {
Log::error('"to"-account is null, so we cannot continue!');
App::abort(500, '"to"-account is null, so we cannot continue!');
+ // @codeCoverageIgnoreStart
}
- if (is_null($from->id)) {
+ // @codeCoverageIgnoreEnd
+
+ if (is_null($from) || (!is_null($from) && is_null($from->id))) {
Log::error('"from"-account is null, so we cannot continue!');
App::abort(500, '"from"-account is null, so we cannot continue!');
+ // @codeCoverageIgnoreStart
}
+ // @codeCoverageIgnoreEnd
return [$from, $to];
}
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index bbd7248915..6fe50edd23 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -145,14 +145,20 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
/**
* Set all piggy banks to order 0.
*
- * @return void
+ * @return boolean
*/
public function reset()
{
- DB::table('piggy_banks')
- ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.id')
- ->where('accounts.user_id', Auth::user()->id)
- ->update(['order' => 0, 'piggy_banks.updated_at' => DB::Raw('NOW()')]);
+ // split query to make it work in sqlite:
+ $set = PiggyBank::
+ leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.id')
+ ->where('accounts.user_id', Auth::user()->id)->get(['piggy_banks.*']);
+ foreach ($set as $e) {
+ $e->order = 0;
+ $e->save();
+ }
+
+ return true;
}
/**
diff --git a/app/Repositories/PiggyBank/PiggybankPart.php b/app/Repositories/PiggyBank/PiggybankPart.php
index bbde8435f3..1cc6b9051f 100644
--- a/app/Repositories/PiggyBank/PiggybankPart.php
+++ b/app/Repositories/PiggyBank/PiggybankPart.php
@@ -9,6 +9,7 @@ use FireflyIII\Models\Reminder;
/**
* Class PiggyBankPart
*
+ * @codeCoverageIgnore
* @package FireflyIII\Collection
*/
class PiggyBankPart
diff --git a/app/Repositories/Reminder/ReminderRepository.php b/app/Repositories/Reminder/ReminderRepository.php
index d35e8bda2f..8db6d0ada0 100644
--- a/app/Repositories/Reminder/ReminderRepository.php
+++ b/app/Repositories/Reminder/ReminderRepository.php
@@ -20,7 +20,7 @@ class ReminderRepository implements ReminderRepositoryInterface
protected $helper;
/**
- *
+ * @codeCoverageIgnore
*/
public function __construct()
{
diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php
index 0fc8c4b42b..4f27c7f9d9 100644
--- a/app/Repositories/Tag/TagRepository.php
+++ b/app/Repositories/Tag/TagRepository.php
@@ -52,6 +52,7 @@ class TagRepository implements TagRepositoryInterface
$withdrawals = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->count();
$transfers = $tag->transactionjournals()->where('transaction_type_id', $transfer->id)->count();
+ $deposits = $tag->transactionjournals()->where('transaction_type_id', $deposit->id)->count();
if ($tag->tagMode == 'balancingAct') {
@@ -73,39 +74,47 @@ class TagRepository implements TagRepositoryInterface
}
if ($tag->tagMode == 'advancePayment') {
+ // advance payments cannot accept transfers:
+ if ($journal->transaction_type_id == $transfer->id) {
+ return false;
+ }
- // only if this is the only withdrawal
- if ($journal->transaction_type_id == $withdrawal->id && $withdrawals < 1) {
+ // the first transaction to be attached to this
+ // tag is attached just like that:
+ if ($withdrawals < 1 && $deposits < 1) {
$journal->tags()->save($tag);
return true;
}
- // only if this is a deposit.
- if ($journal->transaction_type_id == $deposit->id) {
+ // if withdrawal and already has a withdrawal, return false:
+ if ($journal->transaction_type_id == $withdrawal->id && $withdrawals == 1) {
+ return false;
+ }
- // if this is a deposit, account must match the current only journal
- // (if already present):
- $currentWithdrawal = $tag->transactionjournals()->where('transaction_type_id', $withdrawal->id)->first();
-
- if ($currentWithdrawal && $currentWithdrawal->assetAccount->id == $journal->assetAccount->id) {
+ // if already has transaction journals, must match ALL asset account id's:
+ if ($deposits > 0 || $withdrawals == 1) {
+ $match = true;
+ /** @var TransactionJournal $check */
+ foreach ($tag->transactionjournals as $check) {
+ if ($check->assetAccount->id != $journal->assetAccount->id) {
+ $match = false;
+ }
+ }
+ if ($match) {
$journal->tags()->save($tag);
return true;
- } else {
- if (is_null($currentWithdrawal)) {
- $journal->tags()->save($tag);
-
- return true;
- }
}
+
}
return false;
}
-
+ // @codeCoverageIgnoreStart
return false;
}
+ // @codeCoverageIgnoreEnd
/**
* @param Tag $tag
diff --git a/app/Services/Registrar.php b/app/Services/Registrar.php
index 123d11e8f8..5f69c7ba24 100644
--- a/app/Services/Registrar.php
+++ b/app/Services/Registrar.php
@@ -7,6 +7,7 @@ use Validator;
/**
* Class Registrar
*
+ * @codeCoverageIgnore
* @package FireflyIII\Services
*/
class Registrar implements RegistrarContract
diff --git a/app/Support/Amount.php b/app/Support/Amount.php
index b1146b4496..583b7e73a9 100644
--- a/app/Support/Amount.php
+++ b/app/Support/Amount.php
@@ -2,7 +2,6 @@
namespace FireflyIII\Support;
-use Cache;
use FireflyIII\Models\Transaction;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Models\TransactionJournal;
diff --git a/app/Support/Facades/Amount.php b/app/Support/Facades/Amount.php
index 3a8d059ea4..4ef94d5c93 100644
--- a/app/Support/Facades/Amount.php
+++ b/app/Support/Facades/Amount.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Facade;
/**
* Class Amount
*
+ * @codeCoverageIgnore
* @package FireflyIII\Support\Facades
*/
class Amount extends Facade
diff --git a/app/Support/Facades/ExpandedForm.php b/app/Support/Facades/ExpandedForm.php
index 4757d8e779..5cd1973d77 100644
--- a/app/Support/Facades/ExpandedForm.php
+++ b/app/Support/Facades/ExpandedForm.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Facade;
/**
* Class Amount
*
+ * @codeCoverageIgnore
* @package FireflyIII\Support\Facades
*/
class ExpandedForm extends Facade
diff --git a/app/Support/Facades/Navigation.php b/app/Support/Facades/Navigation.php
index 86adb38a13..9adefb8cc9 100644
--- a/app/Support/Facades/Navigation.php
+++ b/app/Support/Facades/Navigation.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Facade;
/**
* Class Navigation
*
+ * @codeCoverageIgnore
* @package FireflyIII\Support\Facades
*/
class Navigation extends Facade
diff --git a/app/Support/Facades/Preferences.php b/app/Support/Facades/Preferences.php
index d7c093c38e..14cd12b528 100644
--- a/app/Support/Facades/Preferences.php
+++ b/app/Support/Facades/Preferences.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Facade;
/**
* Class Preferences
*
+ * @codeCoverageIgnore
* @package FireflyIII\Support\Facades
*/
class Preferences extends Facade
diff --git a/app/Support/Facades/Steam.php b/app/Support/Facades/Steam.php
index 496975c3be..986aa30ccf 100644
--- a/app/Support/Facades/Steam.php
+++ b/app/Support/Facades/Steam.php
@@ -7,6 +7,7 @@ use Illuminate\Support\Facades\Facade;
/**
* Class Steam
*
+ * @codeCoverageIgnore
* @package FireflyIII\Support\Facades
*/
class Steam extends Facade
diff --git a/app/Support/Twig/Translation.php b/app/Support/Twig/Translation.php
new file mode 100644
index 0000000000..3bfd795420
--- /dev/null
+++ b/app/Support/Twig/Translation.php
@@ -0,0 +1,42 @@
+ ['html']]
+ );
+
+ return $filters;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public function getName()
+ {
+ return 'FireflyIII\Support\Twig\Translation';
+ }
+}
diff --git a/config/mail.php b/config/mail.php
index 3841db29c9..31c5eaa8a2 100644
--- a/config/mail.php
+++ b/config/mail.php
@@ -119,6 +119,6 @@ return [
|
*/
- 'pretend' => false,
+ 'pretend' => env('EMAIL_PRETEND', false),
];
diff --git a/resources/lang/en/firefly.php b/resources/lang/en/firefly.php
index fba918f94d..7053e27f94 100644
--- a/resources/lang/en/firefly.php
+++ b/resources/lang/en/firefly.php
@@ -6,5 +6,7 @@ return [
'pleaseHold' => 'Please hold...',
'mandatoryFields' => 'Mandatory fields',
'optionalFields' => 'Optional fields',
- 'options' => 'Options'
-];
\ No newline at end of file
+ 'options' => 'Options',
+ 'something' => 'Something!'
+
+];
diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig
index 4e50f1dfbb..1a11d72452 100644
--- a/resources/twig/accounts/create.twig
+++ b/resources/twig/accounts/create.twig
@@ -9,7 +9,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -22,7 +22,7 @@
{% if what == 'asset' %}
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
@@ -37,7 +37,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','account') }}
diff --git a/resources/twig/accounts/edit.twig b/resources/twig/accounts/edit.twig
index 0bfe9e258b..f32d375941 100644
--- a/resources/twig/accounts/edit.twig
+++ b/resources/twig/accounts/edit.twig
@@ -9,7 +9,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -20,7 +20,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{% if account.accounttype.type == 'Default account' or account.accounttype.type == 'Asset account' %}
@@ -50,7 +50,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','account') }}
diff --git a/resources/twig/bills/create.twig b/resources/twig/bills/create.twig
index cd6938771b..50e87921ca 100644
--- a/resources/twig/bills/create.twig
+++ b/resources/twig/bills/create.twig
@@ -7,7 +7,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -23,7 +23,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{{ ExpandedForm.integer('skip',0) }}
@@ -35,7 +35,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','bill') }}
diff --git a/resources/twig/bills/edit.twig b/resources/twig/bills/edit.twig
index 9eb5f05892..0e96f79885 100644
--- a/resources/twig/bills/edit.twig
+++ b/resources/twig/bills/edit.twig
@@ -9,7 +9,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -26,7 +26,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{{ ExpandedForm.integer('skip') }}
@@ -37,7 +37,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','bill') }}
diff --git a/resources/twig/budgets/create.twig b/resources/twig/budgets/create.twig
index ee5c2b338e..526bc9d00e 100644
--- a/resources/twig/budgets/create.twig
+++ b/resources/twig/budgets/create.twig
@@ -6,7 +6,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -17,7 +17,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','budget') }}
diff --git a/resources/twig/budgets/edit.twig b/resources/twig/budgets/edit.twig
index cdb62233b9..9818ea25a0 100644
--- a/resources/twig/budgets/edit.twig
+++ b/resources/twig/budgets/edit.twig
@@ -13,7 +13,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.checkbox('active') }}
@@ -26,7 +26,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','budget') }}
diff --git a/resources/twig/categories/create.twig b/resources/twig/categories/create.twig
index 3ae6089566..58b44c976c 100644
--- a/resources/twig/categories/create.twig
+++ b/resources/twig/categories/create.twig
@@ -7,7 +7,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -20,7 +20,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','category') }}
diff --git a/resources/twig/categories/edit.twig b/resources/twig/categories/edit.twig
index 5c1f623685..446e51faf5 100644
--- a/resources/twig/categories/edit.twig
+++ b/resources/twig/categories/edit.twig
@@ -7,7 +7,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name') }}
@@ -21,7 +21,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','category') }}
diff --git a/resources/twig/currency/create.twig b/resources/twig/currency/create.twig
index 01cc6c131e..2b667d69a2 100644
--- a/resources/twig/currency/create.twig
+++ b/resources/twig/currency/create.twig
@@ -6,7 +6,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
@@ -22,7 +22,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','currency') }}
diff --git a/resources/twig/currency/edit.twig b/resources/twig/currency/edit.twig
index dc4720d1f6..172c3ce408 100644
--- a/resources/twig/currency/edit.twig
+++ b/resources/twig/currency/edit.twig
@@ -8,7 +8,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('name',null,{'maxlength' : 48}) }}
@@ -23,7 +23,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','currency') }}
diff --git a/resources/twig/index.twig b/resources/twig/index.twig
index 24097c2b09..36836b753b 100644
--- a/resources/twig/index.twig
+++ b/resources/twig/index.twig
@@ -5,7 +5,7 @@
{% if count == 0 %}
-
{{ trans('firefly.welcome') }}
+
{{ 'welcome'|_ }}
Create a new asset account to get started.
diff --git a/resources/twig/layout/default.twig b/resources/twig/layout/default.twig
index 2bf12e7cc0..149ecced8c 100644
--- a/resources/twig/layout/default.twig
+++ b/resources/twig/layout/default.twig
@@ -89,15 +89,15 @@
diff --git a/resources/twig/piggy-banks/create.twig b/resources/twig/piggy-banks/create.twig
index 46214c5f2c..cf62c481e7 100644
--- a/resources/twig/piggy-banks/create.twig
+++ b/resources/twig/piggy-banks/create.twig
@@ -8,7 +8,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
@@ -22,7 +22,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{{ ExpandedForm.date('targetdate') }}
@@ -34,7 +34,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','piggy bank') }}
diff --git a/resources/twig/piggy-banks/edit.twig b/resources/twig/piggy-banks/edit.twig
index db6fa3eafb..6200bd7def 100644
--- a/resources/twig/piggy-banks/edit.twig
+++ b/resources/twig/piggy-banks/edit.twig
@@ -10,7 +10,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
@@ -25,7 +25,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{{ ExpandedForm.date('targetdate') }}
@@ -37,7 +37,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','piggy bank') }}
diff --git a/resources/twig/tags/create.twig b/resources/twig/tags/create.twig
index 36cc5e03d0..72cd43e642 100644
--- a/resources/twig/tags/create.twig
+++ b/resources/twig/tags/create.twig
@@ -7,7 +7,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('tag') }}
@@ -20,7 +20,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{{ ExpandedForm.date('date') }}
@@ -32,7 +32,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','tag') }}
diff --git a/resources/twig/tags/edit.twig b/resources/twig/tags/edit.twig
index 2d92e75ba9..01fedc6eb7 100644
--- a/resources/twig/tags/edit.twig
+++ b/resources/twig/tags/edit.twig
@@ -9,7 +9,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
{{ ExpandedForm.text('tag') }}
@@ -22,7 +22,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
{{ ExpandedForm.date('date') }}
@@ -34,7 +34,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','tag') }}
diff --git a/resources/twig/transactions/create.twig b/resources/twig/transactions/create.twig
index f356aaf7c4..445c09c72d 100644
--- a/resources/twig/transactions/create.twig
+++ b/resources/twig/transactions/create.twig
@@ -8,7 +8,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
@@ -47,7 +47,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
@@ -71,7 +71,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('create','transaction') }}
diff --git a/resources/twig/transactions/edit.twig b/resources/twig/transactions/edit.twig
index 8f8587f42c..5ab00230f0 100644
--- a/resources/twig/transactions/edit.twig
+++ b/resources/twig/transactions/edit.twig
@@ -10,7 +10,7 @@
- {{ trans('firefly.mandatoryFields') }}
+ {{ 'mandatoryFields'|_ }}
@@ -49,7 +49,7 @@
- {{ trans('firefly.optionalFields') }}
+ {{ 'optionalFields'|_ }}
@@ -74,7 +74,7 @@
- {{ trans('firefly.options') }}
+ {{ 'options'|_ }}
{{ ExpandedForm.optionsList('update','transaction') }}
diff --git a/tests/TestCase.php b/tests/TestCase.php
index 4fa6707c85..0fa64e999a 100644
--- a/tests/TestCase.php
+++ b/tests/TestCase.php
@@ -42,7 +42,7 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
Log::debug('Created new database.');
touch($original);
Artisan::call('migrate');
- copy($original, $copy);
+
// create EUR currency
/** @var TransactionCurrency $currency */
@@ -50,8 +50,11 @@ class TestCase extends Illuminate\Foundation\Testing\TestCase
$currency->code = 'EUR';
$currency->save();
Log::debug('Created new EUR currency.');
+ copy($original, $copy);
} else {
+
if (file_exists($copy)) {
+ Log::debug('Copied copy back over original.');
copy($copy, $original);
}
}
diff --git a/tests/controllers/AuthControllerTest.php b/tests/controllers/AuthControllerTest.php
new file mode 100644
index 0000000000..abe9fa9e44
--- /dev/null
+++ b/tests/controllers/AuthControllerTest.php
@@ -0,0 +1,68 @@
+ 'test@example.com',
+ 'password' => 'onetwothree',
+ 'password_confirmation' => 'onetwothree',
+ '_token' => 'replaceMe'
+ ];
+ $this->call('POST', '/auth/register', $data);
+ $this->assertResponseStatus(302);
+ $this->assertSessionHas('success');
+ }
+
+ public function testPostRegisterFails()
+ {
+
+ $data = [
+ 'email' => 'test@example.com',
+ 'password' => 'onetwothree',
+ 'password_confirmation' => 'onetwofour',
+ '_token' => 'replaceMe'
+ ];
+ $this->call('POST', '/auth/register', $data);
+ $this->assertResponseStatus(302);
+
+
+ }
+
+}
diff --git a/tests/controllers/TagControllerTest.php b/tests/controllers/TagControllerTest.php
index 6b50ca1d91..1e6c65fad9 100644
--- a/tests/controllers/TagControllerTest.php
+++ b/tests/controllers/TagControllerTest.php
@@ -115,6 +115,28 @@ class TagControllerTest extends TestCase
$this->assertResponseOk();
}
+ public function testMultipleDeposits()
+ {
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ for ($i = 0; $i < 3; $i++) {
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $journal->transaction_type_id = $type->id;
+ $journal->save();
+ $tag->transactionJournals()->save($journal);
+ }
+
+
+ $tag->tagMode = 'nothing';
+ $tag->save();
+ $this->be($tag->user);
+
+ $this->call('GET', '/tags/edit/' . $tag->id);
+ $this->assertResponseOk();
+ }
+
public function testHideTagHelp()
{
diff --git a/tests/factories/all.php b/tests/factories/all.php
index a060efcc07..572cf25ee1 100644
--- a/tests/factories/all.php
+++ b/tests/factories/all.php
@@ -173,9 +173,9 @@ FactoryMuffin::define(
'FireflyIII\Models\AccountType',
[
'type' => function () {
- $types = ['Expense account', 'Revenue account', 'Asset account'];
+ $types = ['Expense account', 'Revenue account', 'Asset account','Cash account'];
$count = DB::table('account_types')->count();
- if ($count < 3) {
+ if ($count < 4) {
return $types[$count];
} else {
return RandomString::generateRandomString(10);
diff --git a/tests/repositories/CurrencyRepositoryTest.php b/tests/repositories/CurrencyRepositoryTest.php
index 221ea6ec15..1e56b2db96 100644
--- a/tests/repositories/CurrencyRepositoryTest.php
+++ b/tests/repositories/CurrencyRepositoryTest.php
@@ -50,7 +50,7 @@ class CurrencyRepositoryTest extends TestCase
FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
$set = $this->object->get();
- $this->assertCount(2, $set);
+ $this->assertCount(3, $set); // EUR is already present.
}
/**
@@ -76,7 +76,7 @@ class CurrencyRepositoryTest extends TestCase
$preference->data = 'ABC';
$preference->save();
$found = $this->object->getCurrencyByPreference($preference);
- $this->assertEquals($first->id, $found->id);
+ $this->assertEquals(1, $found->id); // EUR is first and will be set.
}
/**
diff --git a/tests/repositories/JournalRepositoryTest.php b/tests/repositories/JournalRepositoryTest.php
index 69840beaef..e4d0e2a68a 100644
--- a/tests/repositories/JournalRepositoryTest.php
+++ b/tests/repositories/JournalRepositoryTest.php
@@ -1,5 +1,10 @@
markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 1;
+ $reminder->save();
+ $this->be($reminder->user);
+
+ $this->object->deactivateReminder($reminder->id);
+
+ $this->assertEquals(1, Reminder::where('id', $reminder->id)->where('active', 0)->count());
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::delete
- * @todo Implement testDelete().
*/
public function testDelete()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+ $transaction = Transaction::create(
+ [
+ 'account_id' => $account->id,
+ 'transaction_journal_id' => $journal->id,
+ 'amount' => 100,
+ ]
);
+
+ $this->object->delete($journal);
+
+ $this->assertEquals(0, TransactionJournal::where('id', $journal->id)->whereNull('deleted_at')->count());
+ $this->assertEquals(0, Transaction::where('id', $transaction->id)->whereNull('deleted_at')->count());
+
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::first
- * @todo Implement testFirst().
*/
public function testFirst()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $this->be($journal->user);
+
+ $first = $this->object->first();
+
+ $this->assertEquals($journal->id, $first->id);
+
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::getAmountBefore
- * @todo Implement testGetAmountBefore().
*/
public function testGetAmountBefore()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $transaction = FactoryMuffin::create('FireflyIII\Models\Transaction');
+ $before = $this->object->getAmountBefore($transaction->transactionjournal, $transaction);
+
+ $this->assertEquals(0, $before);
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfType
- * @todo Implement testGetJournalsOfType().
*/
public function testGetJournalsOfType()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $this->be($user);
+ $result = $this->object->getJournalsOfType($type);
+ $this->assertCount(0, $result);
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::getJournalsOfTypes
- * @todo Implement testGetJournalsOfTypes().
*/
public function testGetJournalsOfTypes()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $this->be($user);
+ $types = ['Withdrawal', 'Expense'];
+ $set = $this->object->getJournalsOfTypes($types, 0, 1);
+
+ $this->assertTrue($set instanceof LengthAwarePaginator);
+ $this->assertEquals(1, $set->currentPage());
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::getTransactionType
- * @todo Implement testGetTransactionType().
*/
public function testGetTransactionType()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $type = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $otherType = $this->object->getTransactionType($type->type);
+ $this->assertEquals($type->id, $otherType->id);
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::getWithDate
- * @todo Implement testGetWithDate().
*/
public function testGetWithDate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $this->be($journal->user);
+
+ $found = $this->object->getWithDate($journal->id, $journal->date);
+
+ $this->assertEquals($journal->id, $found->id);
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::saveTags
- * @todo Implement testSaveTags().
*/
public function testSaveTags()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tags = ['one', 'two', 'three'];
+ $this->be($journal->user);
+
+ $this->object->saveTags($journal, $tags);
+
+ $this->assertCount(3, $journal->tags()->get());
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::store
- * @todo Implement testStore().
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
*/
public function testStore()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'withdrawal',
+ 'amount_currency_id' => $currency->id,
+ 'account_id' => $account1->id,
+ 'expense_account' => 'Some expense account',
+ 'date' => '2014-01-01',
+ 'category' => 'Some category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::store
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
+ */
+ public function testStoreDeposit()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'deposit',
+ 'amount_currency_id' => $currency->id,
+ 'account_id' => $account1->id,
+ 'revenue_account' => 'Some revenue account',
+ 'date' => '2014-01-01',
+ 'category' => 'Some category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::store
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
+ */
+ public function testStoreExpenseWithCash()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'withdrawal',
+ 'amount_currency_id' => $currency->id,
+ 'account_id' => $account1->id,
+ 'expense_account' => '',
+ 'date' => '2014-01-01',
+ 'category' => 'Some other category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::store
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
+ * @expectedException Symfony\Component\HttpKernel\Exception\HttpException
+ */
+ public function testStoreInvalidFromAccount()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'transfer',
+ 'amount_currency_id' => $currency->id,
+ 'account_from_id' => $account1->id,
+ 'account_to_id' => 17,
+ 'date' => '2014-01-01',
+ 'category' => 'Some other category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::store
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
+ * @expectedException Symfony\Component\HttpKernel\Exception\HttpException
+ */
+ public function testStoreInvalidToAccount()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'transfer',
+ 'amount_currency_id' => $currency->id,
+ 'account_from_id' => 17,
+ 'account_to_id' => $account1->id,
+ 'date' => '2014-01-01',
+ 'category' => 'Some other category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::store
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
+ */
+ public function testStoreRevenueWithCash()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'deposit',
+ 'amount_currency_id' => $currency->id,
+ 'account_id' => $account1->id,
+ 'revenue_account' => '',
+ 'date' => '2014-01-01',
+ 'category' => 'Some other category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::store
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::storeAccounts
+ */
+ public function testStoreTransfer()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $account2 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $data = [
+ 'description' => 'Some journal ' . rand(1, 100),
+ 'user' => $user->id,
+ 'what' => 'transfer',
+ 'amount_currency_id' => $currency->id,
+ 'account_from_id' => $account1->id,
+ 'account_to_id' => $account2->id,
+ 'date' => '2014-01-01',
+ 'category' => 'Some other category',
+ 'budget_id' => $budget->id,
+ 'amount' => 100,
+ 'tags' => ['one', 'two', 'three']
+
+
+ ];
+
+ $journal = $this->object->store($data);
+
+ $this->assertEquals($data['description'], $journal->description);
}
/**
* @covers FireflyIII\Repositories\Journal\JournalRepository::update
- * @todo Implement testUpdate().
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags
*/
public function testUpdate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $account2 = FactoryMuffin::create('FireflyIII\Models\Account');
+
+ // two transactions
+ Transaction::create(
+ [
+ 'account_id' => $account1->id,
+ 'transaction_journal_id' => $journal->id,
+ 'amount' => 100,
+ ]
);
+ Transaction::create(
+ [
+ 'account_id' => $account1->id,
+ 'transaction_journal_id' => $journal->id,
+ 'amount' => -100,
+ ]
+ );
+
+
+ $data = [
+ 'amount_currency_id' => $currency->id,
+ 'description' => 'New description ' . rand(1, 100),
+ 'date' => '2015-01-01',
+ 'category' => 'SomenewCat',
+ 'amount' => 50,
+ 'user' => $journal->user_id,
+ 'budget_id' => $budget->id,
+ 'account_from_id' => $account1->id,
+ 'account_to_id' => $account2->id,
+ 'revenue_account' => 'Some revenue account',
+ 'expense_account' => 'Some expense account',
+ 'tags' => ['a', 'b', 'c']
+
+ ];
+
+ $result = $this->object->update($journal, $data);
+
+ $this->assertEquals($result->description, $data['description']);
+ $this->assertEquals($result->amount, 50);
+ }
+ /**
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::update
+ * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags
+ */
+ public function testUpdateNoTags()
+ {
+ for ($i = 0; $i < 4; $i++) {
+ FactoryMuffin::create('FireflyIII\Models\AccountType');
+ }
+
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $currency = FactoryMuffin::create('FireflyIII\Models\TransactionCurrency');
+ $budget = FactoryMuffin::create('FireflyIII\Models\Budget');
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $account2 = FactoryMuffin::create('FireflyIII\Models\Account');
+
+ // two transactions
+ Transaction::create(
+ [
+ 'account_id' => $account1->id,
+ 'transaction_journal_id' => $journal->id,
+ 'amount' => 100,
+ ]
+ );
+ Transaction::create(
+ [
+ 'account_id' => $account1->id,
+ 'transaction_journal_id' => $journal->id,
+ 'amount' => -100,
+ ]
+ );
+
+
+ $data = [
+ 'amount_currency_id' => $currency->id,
+ 'description' => 'New description ' . rand(1, 100),
+ 'date' => '2015-01-01',
+ 'category' => 'SomenewCat',
+ 'amount' => 50,
+ 'user' => $journal->user_id,
+ 'budget_id' => $budget->id,
+ 'account_from_id' => $account1->id,
+ 'account_to_id' => $account2->id,
+ 'revenue_account' => 'Some revenue account',
+ 'expense_account' => 'Some expense account',
+ 'tags' => []
+
+ ];
+
+ $result = $this->object->update($journal, $data);
+
+ $this->assertEquals($result->description, $data['description']);
+ $this->assertEquals($result->amount, 50);
}
- /**
- * @covers FireflyIII\Repositories\Journal\JournalRepository::updateTags
- * @todo Implement testUpdateTags().
- */
- public function testUpdateTags()
- {
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
- }
}
diff --git a/tests/repositories/PiggyBankRepositoryTest.php b/tests/repositories/PiggyBankRepositoryTest.php
index acbb997467..ef7ff93d20 100644
--- a/tests/repositories/PiggyBankRepositoryTest.php
+++ b/tests/repositories/PiggyBankRepositoryTest.php
@@ -1,5 +1,9 @@
markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ /** @var PiggyBankRepetition $repetition */
+ $repetition = FactoryMuffin::create('FireflyIII\Models\PiggyBankRepetition');
+ $repetition->startdate = new Carbon('2014-01-01');
+ $repetition->targetdate = new Carbon('2014-12-31');
+ $repetition->save();
+
+ $parts = $this->object->calculateParts($repetition);
+
+ $this->assertCount(1, $parts);
+
+
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::calculateParts
+ */
+ public function testCalculatePartsWithReminder()
+ {
+ /** @var PiggyBankRepetition $repetition */
+ $repetition = FactoryMuffin::create('FireflyIII\Models\PiggyBankRepetition');
+ /** @var PiggyBank $piggyBank */
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $piggyBank->startdate = new Carbon('2014-01-01');
+ $piggyBank->targetdate = new Carbon('2014-12-31');
+ $piggyBank->remind_me = 1;
+ $piggyBank->reminder = 'monthly';
+ $repetition->startdate = new Carbon('2014-01-01');
+ $repetition->targetdate = new Carbon('2014-12-31');
+ $repetition->piggy_bank_id = $piggyBank->id;
+ $repetition->save();
+ $piggyBank->save();
+
+ $parts = $this->object->calculateParts($repetition);
+ $this->assertCount(12, $parts);
+
+
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createEvent
- * @todo Implement testCreateEvent().
*/
public function testCreateEvent()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $this->object->createEvent($piggyBank, 100);
+
+ $this->assertCount(1, $piggyBank->piggybankevents()->get());
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::createPiggyBankPart
- * @todo Implement testCreatePiggyBankPart().
*/
public function testCreatePiggyBankPart()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $repetition = FactoryMuffin::create('FireflyIII\Models\PiggyBankRepetition');
+ $data = [
+ 'repetition' => $repetition,
+ 'amountPerBar' => 100,
+ 'currentAmount' => 100,
+ 'cumulativeAmount' => 100,
+ 'startDate' => new Carbon,
+ 'targetDate' => new Carbon,
+ ];
+ $part = $this->object->createPiggyBankPart($data);
+ $this->assertEquals($data['amountPerBar'], $part->getAmountPerBar());
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::destroy
- * @todo Implement testDestroy().
*/
public function testDestroy()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+
+ $this->object->destroy($piggyBank);
+
+ $this->assertCount(0, PiggyBank::where('id', $piggyBank->id)->whereNull('deleted_at')->get());
+
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getEventSummarySet
- * @todo Implement testGetEventSummarySet().
*/
public function testGetEventSummarySet()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $set = $this->object->getEventSummarySet($piggyBank);
+
+ $this->assertCount(0, $set);
}
/**
@@ -96,46 +136,51 @@ class PiggyBankRepositoryTest extends TestCase
*/
public function testGetEvents()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $set = $this->object->getEvents($piggyBank);
+
+ $this->assertCount(0, $set);
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::getPiggyBanks
- * @todo Implement testGetPiggyBanks().
*/
public function testGetPiggyBanks()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $this->be($piggyBank->account->user);
+ $set = $this->object->getPiggyBanks();
+
+ $this->assertCount(1, $set);
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::reset
- * @todo Implement testReset().
*/
public function testReset()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $piggyBank->order = 4;
+ $piggyBank->save();
+ $this->be($piggyBank->account->user);
+ $this->object->reset();
+
+ $this->assertCount(1, PiggyBank::where('order', 0)->get());
}
/**
* @covers FireflyIII\Repositories\PiggyBank\PiggyBankRepository::setOrder
- * @todo Implement testSetOrder().
*/
public function testSetOrder()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+ $piggyBank->order = 4;
+ $this->be($piggyBank->account->user);
+ $piggyBank->save();
+
+ $this->object->setOrder($piggyBank->id, 3);
+ $newPiggy = PiggyBank::find($piggyBank->id);
+ $this->assertEquals(3, $newPiggy->order);
}
/**
@@ -144,10 +189,21 @@ class PiggyBankRepositoryTest extends TestCase
*/
public function testStore()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+
+ $data = [
+ 'remind_me' => 1,
+ 'account_id' => $account->id,
+ 'name' => 'Some piggy',
+ 'targetamount' => 100,
+ 'reminder_skip' => 0,
+ 'order' => 1,
+
+ ];
+
+ $piggyBank = $this->object->store($data);
+
+ $this->assertEquals(1, $piggyBank->id);
}
/**
@@ -156,9 +212,21 @@ class PiggyBankRepositoryTest extends TestCase
*/
public function testUpdate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $piggyBank = FactoryMuffin::create('FireflyIII\Models\PiggyBank');
+
+ $data = [
+ 'name' => 'Update piggy ' . rand(1, 100),
+ 'account_id' => $piggyBank->account_id,
+ 'targetamount' => 101,
+ 'targetdate' => new Carbon,
+ 'reminder' => null,
+ 'startdate' => new Carbon,
+ 'remind_me' => '1'
+ ];
+
+ $new = $this->object->update($piggyBank, $data);
+
+ $this->assertEquals($data['name'], $new->name);
+ $this->assertEquals($piggyBank->id, $new->id);
}
}
diff --git a/tests/repositories/ReminderRepositoryTest.php b/tests/repositories/ReminderRepositoryTest.php
index 55e5277577..c4285ea132 100644
--- a/tests/repositories/ReminderRepositoryTest.php
+++ b/tests/repositories/ReminderRepositoryTest.php
@@ -1,5 +1,7 @@
mock('FireflyIII\Helpers\Reminders\ReminderHelperInterface');
+ $helper->shouldReceive('getReminderText')->andReturn('Hello!');
$this->object = new ReminderRepository;
}
@@ -33,49 +37,116 @@ class ReminderRepositoryTest extends TestCase
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getActiveReminders
- * @todo Implement testGetActiveReminders().
*/
public function testGetActiveReminders()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $yesterday = Carbon::now()->subDay();
+ $tomorrow = Carbon::now()->addDay();
+
+ $user = FactoryMuffin::create('FireflyIII\User');
+ for ($i = 0; $i < 3; $i++) {
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 1;
+ $reminder->notnow = 0;
+ $reminder->startdate = $yesterday;
+ $reminder->enddate = $tomorrow;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+
+ }
+
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 0;
+ $reminder->notnow = 0;
+ $reminder->startdate = $yesterday;
+ $reminder->enddate = $tomorrow;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+ $this->be($user);
+
+ $set = $this->object->getActiveReminders();
+ $this->assertCount(3, $set);
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getDismissedReminders
- * @todo Implement testGetDismissedReminders().
*/
public function testGetDismissedReminders()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+
+ $user = FactoryMuffin::create('FireflyIII\User');
+ for ($i = 0; $i < 3; $i++) {
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->notnow = 1;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+
+ }
+
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->notnow = 0;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+ $this->be($user);
+
+ $set = $this->object->getDismissedReminders();
+ $this->assertCount(3, $set);
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getExpiredReminders
- * @todo Implement testGetExpiredReminders().
*/
public function testGetExpiredReminders()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $yesterday = Carbon::now()->subDay();
+ $tomorrow = Carbon::now()->addDay();
+
+ $user = FactoryMuffin::create('FireflyIII\User');
+ for ($i = 0; $i < 3; $i++) {
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 1;
+ $reminder->notnow = 0;
+ $reminder->startdate = $tomorrow;
+ $reminder->enddate = $yesterday;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+
+ }
+
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 0;
+ $reminder->notnow = 0;
+ $reminder->startdate = $tomorrow;
+ $reminder->enddate = $yesterday;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+ $this->be($user);
+
+ $set = $this->object->getExpiredReminders();
+ $this->assertCount(3, $set);
}
/**
* @covers FireflyIII\Repositories\Reminder\ReminderRepository::getInactiveReminders
- * @todo Implement testGetInactiveReminders().
*/
public function testGetInactiveReminders()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ for ($i = 0; $i < 3; $i++) {
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 0;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+
+ }
+
+ $reminder = FactoryMuffin::create('FireflyIII\Models\Reminder');
+ $reminder->active = 1;
+ $reminder->user_id = $user->id;
+ $reminder->save();
+ $this->be($user);
+
+ $set = $this->object->getInactiveReminders();
+ $this->assertCount(3, $set);
}
}
diff --git a/tests/repositories/TagRepositoryTest.php b/tests/repositories/TagRepositoryTest.php
index fb1b57cd0c..855ec366d5 100644
--- a/tests/repositories/TagRepositoryTest.php
+++ b/tests/repositories/TagRepositoryTest.php
@@ -1,5 +1,8 @@
markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+ $journal->tags()->save($tag);
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertFalse($result);
+
+ }
+
+ /**
+ * A deposit cannot be connected to a balancing act.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectBalancingOneDeposit()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal->transaction_type_id = $deposit->id;
+ $tag->tagMode = 'balancingAct';
+
+ $tag->save();
+ $journal->save();
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertFalse($result);
+
+ }
+
+ /**
+ * Connecting a single transfer to a balancing act is possible if there are no
+ * other transfers already connected.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectBalancingOneTransfer()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal->transaction_type_id = $transfer->id;
+ $tag->tagMode = 'balancingAct';
+
+ $tag->save();
+ $journal->save();
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertTrue($result);
+
+ }
+
+ /**
+ * Connecting a single withdrawal to a balancing act is possible if there are
+ * not other withdrawals already connected.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectBalancingOneWithdrawal()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal->transaction_type_id = $withdrawal->id;
+ $tag->tagMode = 'balancingAct';
+
+ $tag->save();
+ $journal->save();
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertTrue($result);
+
+ }
+
+ /**
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectDefault()
+ {
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+ $tag->tagMode = 'nothing';
+ $tag->save();
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertTrue($result);
+
+ }
+
+ /**
+ * Once one or more journals have been accepted by the tag, others must match the asset account
+ * id. For this to work, we must also create an asset account, and a transaction.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectPaymentMultipleMatch()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
+ $revenue = FactoryMuffin::create('FireflyIII\Models\AccountType');
+ $asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
+
+ $account = FactoryMuffin::create('FireflyIII\Models\Account');
+
+
+ $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+
+ // transactions for both:
+ Transaction::create(['account_id' => $account->id, 'transaction_journal_id' => $journal1->id, 'amount' => 100]);
+ Transaction::create(['account_id' => $account->id, 'transaction_journal_id' => $journal2->id, 'amount' => 100]);
+
+
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal1->transaction_type_id = $withdrawal->id;
+ $journal2->transaction_type_id = $deposit->id;
+ $tag->tagMode = 'advancePayment';
+ $account->account_type_id = $asset->id;
+
+ $tag->save();
+ $journal1->save();
+ $journal2->save();
+ $account->save();
+ // connect journal1:
+ $journal1->tags()->save($tag);
+
+ $result = $this->object->connect($journal2, $tag);
+ $this->assertTrue($result);
+
+ }
+
+ /**
+ * Once one or more journals have been accepted by the tag, others must match the asset account
+ * id. For this to work, we must also create an asset account, and a transaction.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectPaymentNoMatch()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $expense = FactoryMuffin::create('FireflyIII\Models\AccountType');
+ $revenue = FactoryMuffin::create('FireflyIII\Models\AccountType');
+ $asset = FactoryMuffin::create('FireflyIII\Models\AccountType');
+
+ $account1 = FactoryMuffin::create('FireflyIII\Models\Account');
+ $account2 = FactoryMuffin::create('FireflyIII\Models\Account');
+
+
+ $journal1 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $journal2 = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+
+ // transactions for both:
+ Transaction::create(['account_id' => $account1->id, 'transaction_journal_id' => $journal1->id, 'amount' => 100]);
+ Transaction::create(['account_id' => $account2->id, 'transaction_journal_id' => $journal2->id, 'amount' => 100]);
+
+
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal1->transaction_type_id = $withdrawal->id;
+ $journal2->transaction_type_id = $deposit->id;
+ $tag->tagMode = 'advancePayment';
+ $account1->account_type_id = $asset->id;
+ $account2->account_type_id = $asset->id;
+
+ $tag->save();
+ $journal1->save();
+ $journal2->save();
+ $account1->save();
+ $account2->save();
+ // connect journal1:
+ $journal1->tags()->save($tag);
+
+ $result = $this->object->connect($journal2, $tag);
+ // account1 and account2 are different, so false:
+ $this->assertFalse($result);
+
+ }
+
+ /**
+ * An advance payment accepts no transfers
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectPaymentOneTransfer()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal->transaction_type_id = $transfer->id;
+ $tag->tagMode = 'advancePayment';
+
+ $tag->save();
+ $journal->save();
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertFalse($result);
+
+ }
+
+ /**
+ * An advance payment accepts only one withdrawal, not two.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectPaymentOneWithdrawal()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal->transaction_type_id = $withdrawal->id;
+ $tag->tagMode = 'advancePayment';
+
+ $tag->save();
+ $journal->save();
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertTrue($result);
+
+ }
+
+ /**
+ * An advance payment accepts only one withdrawal, not two.
+ *
+ * @covers FireflyIII\Repositories\Tag\TagRepository::connect
+ */
+ public function testConnectPaymentTwoWithdrawals()
+ {
+ $withdrawal = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $deposit = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+ $transfer = FactoryMuffin::create('FireflyIII\Models\TransactionType');
+
+ $journal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $otherJournal = FactoryMuffin::create('FireflyIII\Models\TransactionJournal');
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+ $journal->transaction_type_id = $withdrawal->id;
+ $otherJournal->transaction_type_id = $withdrawal->id;
+ $tag->tagMode = 'advancePayment';
+
+ $tag->save();
+ $journal->save();
+ $otherJournal->save();
+ $otherJournal->tags()->save($tag);
+
+ $result = $this->object->connect($journal, $tag);
+ $this->assertFalse($result);
+
}
/**
* @covers FireflyIII\Repositories\Tag\TagRepository::destroy
- * @todo Implement testDestroy().
*/
public function testDestroy()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+ $this->object->destroy($tag);
+
+ $this->assertCount(0, Tag::where('id', $tag->id)->whereNull('deleted_at')->get());
+
}
/**
@@ -60,33 +334,68 @@ class TagRepositoryTest extends TestCase
*/
public function testGet()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+ $tag1 = FactoryMuffin::create('FireflyIII\Models\Tag');
+ $tag2 = FactoryMuffin::create('FireflyIII\Models\Tag');
+ $tag1->tag = 'BBB';
+ $tag2->tag = 'AAA';
+ $tag1->user_id = $user->id;
+ $tag2->user_id = $user->id;
+
+ $tag1->save();
+ $tag2->save();
+
+ $this->be($user);
+
+ $set = $this->object->get();
+
+ $this->assertCount(2, $set);
+ $this->assertEquals('AAA', $set->first()->tag);
}
/**
* @covers FireflyIII\Repositories\Tag\TagRepository::store
- * @todo Implement testStore().
*/
public function testStore()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $user = FactoryMuffin::create('FireflyIII\User');
+
+ $data = [
+ 'tag' => 'Hello' . rand(1, 100),
+ 'date' => '2012-01-01',
+ 'description' => 'Some',
+ 'latitude' => 12,
+ 'longitude' => 13,
+ 'zoomLevel' => 4,
+ 'tagMode' => 'nothing'
+ ];
+ $this->be($user);
+
+ $tag = $this->object->store($data);
+ $this->assertEquals($data['tag'], $tag->tag);
}
/**
* @covers FireflyIII\Repositories\Tag\TagRepository::update
- * @todo Implement testUpdate().
*/
public function testUpdate()
{
- // Remove the following lines when you implement this test.
- $this->markTestIncomplete(
- 'This test has not been implemented yet.'
- );
+ $tag = FactoryMuffin::create('FireflyIII\Models\Tag');
+
+
+ $data = [
+ 'tag' => 'Hello' . rand(1, 100),
+ 'date' => '2012-01-01',
+ 'description' => 'Some',
+ 'latitude' => 12,
+ 'longitude' => 13,
+ 'zoomLevel' => 4,
+ 'tagMode' => 'nothing'
+ ];
+ $this->be($tag->user);
+
+ $newTag = $this->object->update($tag, $data);
+ $this->assertEquals($data['tag'], $newTag->tag);
+ $this->assertEquals($tag->id, $newTag->id);
}
}