mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Merge branch 'release/4.7.6.1'
This commit is contained in:
commit
a4cb2c1cb1
@ -15,7 +15,7 @@ APP_KEY=${FF_APP_KEY}
|
||||
|
||||
# Change this value to your preferred time zone.
|
||||
# Example: Europe/Amsterdam
|
||||
TZ=UTC
|
||||
TZ=${TZ}
|
||||
|
||||
# This variable must match your installation's external address but keep in mind that
|
||||
# it's only used on the command line as a fallback value.
|
||||
|
@ -15,7 +15,7 @@ APP_KEY=SomeRandomStringOf32CharsExactly
|
||||
|
||||
# Change this value to your preferred time zone.
|
||||
# Example: Europe/Amsterdam
|
||||
TZ=${TZ}
|
||||
TZ=Europe/Amsterdam
|
||||
|
||||
# This variable must match your installation's external address but keep in mind that
|
||||
# it's only used on the command line as a fallback value.
|
||||
|
@ -1,3 +1,8 @@
|
||||
# 4.7.6.1
|
||||
- An issue where I switched variables from the Docker `.env` file to the normal `.env` file and vice versa -- breaking both.
|
||||
- [Issue 1649](https://github.com/firefly-iii/firefly-iii/issues/1649) 2FA QR code would not show up due to very strict security policy headers
|
||||
- Docker build gave a cURL error whenever it runs PHP commands.
|
||||
|
||||
# 4.7.6
|
||||
- [Issue 145](https://github.com/firefly-iii/firefly-iii/issues/145) You can now download transactions from YNAB.
|
||||
- [Issue 306](https://github.com/firefly-iii/firefly-iii/issues/306) You can now add liabilities to Firefly III.
|
||||
@ -26,13 +31,13 @@
|
||||
- [Issue 1598](https://github.com/firefly-iii/firefly-iii/issues/1598) Fix budget calculations.
|
||||
- [Issue 1597](https://github.com/firefly-iii/firefly-iii/issues/1597) Piggy banks are always inactive.
|
||||
- [Issue 1605](https://github.com/firefly-iii/firefly-iii/issues/1605) System will ignore foreign currency setting if user doesn't indicate the amount.
|
||||
- [Issue 1607](https://github.com/firefly-iii/firefly-iii/issues/1607) Firefly III trusts the Heroku load balancer, fixing deployment on Heroku.
|
||||
- [Issue 1608](https://github.com/firefly-iii/firefly-iii/issues/1608) Spelling error in command line import.
|
||||
- [Issue 1609](https://github.com/firefly-iii/firefly-iii/issues/1609) Link to budgets page was absolute.
|
||||
- [Issue 1615](https://github.com/firefly-iii/firefly-iii/issues/1615) Fix currency bug in transactions.
|
||||
- [Issue 1616](https://github.com/firefly-iii/firefly-iii/issues/1616) Fix null pointer exception in pie charts.
|
||||
- [Issue 1617](https://github.com/firefly-iii/firefly-iii/issues/1617) Fix for complex tag names in URL's.
|
||||
- [Issue 1620](https://github.com/firefly-iii/firefly-iii/issues/1620) Fixed index reference in API.
|
||||
- [Issue 1639](https://github.com/firefly-iii/firefly-iii/issues/1639) Firefly III trusts the Heroku load balancer, fixing deployment on Heroku.
|
||||
- [Issue 1642](https://github.com/firefly-iii/firefly-iii/issues/1642) Fix issue with split journals.
|
||||
- [Issue 1643](https://github.com/firefly-iii/firefly-iii/issues/1643) Fix reconciliation issue.
|
||||
- Users can no longer give expenses a budget.
|
||||
|
@ -16,7 +16,7 @@ const pkgdef :Spk.PackageDefinition = (
|
||||
manifest = (
|
||||
appTitle = (defaultText = "Firefly III"),
|
||||
appVersion = 16,
|
||||
appMarketingVersion = (defaultText = "4.7.6"),
|
||||
appMarketingVersion = (defaultText = "4.7.6.1"),
|
||||
|
||||
actions = [
|
||||
# Define your "new document" handlers here.
|
||||
|
@ -60,6 +60,10 @@ RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/00-curl.conf && ldconfig
|
||||
COPY .deploy/docker/supervisord.conf /etc/supervisor/supervisord.conf
|
||||
RUN mkdir -p /etc/supervisor/conf.d /var/log/supervisor
|
||||
|
||||
# Fix the link to curl:
|
||||
RUN rm -rf /usr/local/lib/libcurl.so.4 && ln -s /usr/lib/x86_64-linux-gnu/libcurl.so.4.4.0 /usr/local/lib/libcurl.so.4
|
||||
|
||||
|
||||
# copy Firefly III supervisor conf file.
|
||||
COPY ./.deploy/docker/firefly-iii.conf /etc/supervisor/conf.d/firefly-iii.conf
|
||||
|
||||
|
@ -105,10 +105,10 @@ class EditController extends Controller
|
||||
'times' => (string)trans('firefly.repeat_times'),
|
||||
];
|
||||
if (null !== $recurrence->repeat_until) {
|
||||
$repetitionEnd = 'until_date';
|
||||
$repetitionEnd = 'until_date'; // @codeCoverageIgnore
|
||||
}
|
||||
if ($recurrence->repetitions > 0) {
|
||||
$repetitionEnd = 'times';
|
||||
$repetitionEnd = 'times'; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$weekendResponses = [
|
||||
|
@ -63,10 +63,12 @@ class AccountController extends Controller
|
||||
$accountReport = $accountTasker->getAccountReport($accounts, $start, $end);
|
||||
try {
|
||||
$result = view('reports.partials.accounts', compact('accountReport'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.accounts: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -61,10 +61,12 @@ class BalanceController extends Controller
|
||||
$balance = $helper->getBalanceReport($accounts, $start, $end);
|
||||
try {
|
||||
$result = view('reports.partials.balance', compact('balance'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.balance: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -63,10 +63,12 @@ class BudgetController extends Controller
|
||||
$budgets = $helper->getBudgetReport($start, $end, $accounts);
|
||||
try {
|
||||
$result = view('reports.partials.budgets', compact('budgets'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budgets: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -103,10 +105,12 @@ class BudgetController extends Controller
|
||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||
try {
|
||||
$result = view('reports.partials.budget-period', compact('report', 'periods'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.budget-period: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -67,10 +67,12 @@ class CategoryController extends Controller
|
||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||
try {
|
||||
$result = view('reports.partials.category-period', compact('report', 'periods'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$cache->store($result);
|
||||
|
||||
@ -107,10 +109,12 @@ class CategoryController extends Controller
|
||||
$periods = app('navigation')->listOfPeriods($start, $end);
|
||||
try {
|
||||
$result = view('reports.partials.category-period', compact('report', 'periods'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -160,10 +164,12 @@ class CategoryController extends Controller
|
||||
try {
|
||||
$result = view('reports.partials.categories', compact('report'))->render();
|
||||
$cache->store($result);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
@ -107,10 +107,12 @@ class ExpenseController extends Controller
|
||||
}
|
||||
try {
|
||||
$result = view('reports.partials.exp-budgets', compact('together'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::budget: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -170,10 +172,12 @@ class ExpenseController extends Controller
|
||||
}
|
||||
try {
|
||||
$result = view('reports.partials.exp-categories', compact('together'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -220,10 +224,12 @@ class ExpenseController extends Controller
|
||||
}
|
||||
try {
|
||||
$result = view('reports.partials.exp-not-grouped', compact('result'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::expenses: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -271,10 +277,12 @@ class ExpenseController extends Controller
|
||||
);
|
||||
try {
|
||||
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::topExpense: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -320,10 +328,12 @@ class ExpenseController extends Controller
|
||||
);
|
||||
try {
|
||||
$result = view('reports.partials.top-transactions', compact('sorted'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::error(sprintf('Could not render category::topIncome: %s', $e->getMessage()));
|
||||
$result = 'An error prevented Firefly III from rendering. Apologies.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -81,10 +81,12 @@ class OperationsController extends Controller
|
||||
$type = 'expense-entry';
|
||||
try {
|
||||
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.income-expense: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
@ -114,10 +116,12 @@ class OperationsController extends Controller
|
||||
$type = 'income-entry';
|
||||
try {
|
||||
$result = view('reports.partials.income-expenses', compact('entries', 'type'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.income-expenses: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$cache->store($result);
|
||||
|
||||
@ -166,10 +170,12 @@ class OperationsController extends Controller
|
||||
);
|
||||
try {
|
||||
$result = view('reports.partials.operations', compact('incomeSum', 'expensesSum'))->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
Log::debug(sprintf('Could not render reports.partials.operations: %s', $e->getMessage()));
|
||||
$result = 'Could not render view.';
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
$cache->store($result);
|
||||
|
||||
return $result;
|
||||
|
@ -258,10 +258,13 @@ class CreateController extends Controller
|
||||
'count' => $index + 1,
|
||||
]
|
||||
)->render();
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $e) {
|
||||
|
||||
Log::debug(sprintf('Throwable was thrown in getTriggersForBill(): %s', $e->getMessage()));
|
||||
Log::debug($e->getTraceAsString());
|
||||
$string = '';
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
if ('' !== $string) {
|
||||
$result[] = $string;
|
||||
|
@ -49,7 +49,8 @@ class CronController
|
||||
*/
|
||||
private function runRecurring(): string
|
||||
{
|
||||
$recurring = new RecurringCronjob;
|
||||
/** @var RecurringCronjob $recurring */
|
||||
$recurring = app(RecurringCronjob::class);
|
||||
try {
|
||||
$result = $recurring->fire();
|
||||
} catch (FireflyException $e) {
|
||||
|
@ -57,7 +57,7 @@ class SecureHeaders
|
||||
"form-action 'self'",
|
||||
"font-src 'self'",
|
||||
"connect-src 'self'",
|
||||
"img-src 'self'",
|
||||
"img-src 'self' data:",
|
||||
];
|
||||
|
||||
$featurePolicies = [
|
||||
@ -85,4 +85,4 @@ class SecureHeaders
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ class RecurrenceFormRequest extends Request
|
||||
// fill in source and destination account data
|
||||
switch ($this->string('transaction_type')) {
|
||||
default:
|
||||
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type')));
|
||||
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); // @codeCoverageIgnore
|
||||
case 'withdrawal':
|
||||
$return['transactions'][0]['source_id'] = $this->integer('source_id');
|
||||
$return['transactions'][0]['destination_name'] = $this->string('destination_name');
|
||||
@ -227,8 +227,6 @@ class RecurrenceFormRequest extends Request
|
||||
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,' . $recurrence->id;
|
||||
$rules['first_date'] = 'required|date';
|
||||
}
|
||||
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,16 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $types
|
||||
*
|
||||
|
@ -38,6 +38,16 @@ class AccountTasker implements AccountTaskerInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
|
@ -45,6 +45,16 @@ class AttachmentRepository implements AttachmentRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
*
|
||||
|
@ -48,6 +48,16 @@ class BillRepository implements BillRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
|
@ -54,6 +54,16 @@ class BudgetRepository implements BudgetRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A method that returns the amount of money budgeted per day for this budget,
|
||||
* on average.
|
||||
|
@ -47,6 +47,16 @@ class CategoryRepository implements CategoryRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Category $category
|
||||
*
|
||||
|
@ -43,10 +43,13 @@ class CurrencyRepository implements CurrencyRepositoryInterface
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* CurrencyRepository constructor.
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,6 +39,16 @@ class ExportJobRepository implements ExportJobRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ExportJob $job
|
||||
* @param string $status
|
||||
|
@ -53,6 +53,10 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
{
|
||||
$this->maxUploadSize = (int)config('firefly.maxUploadSize');
|
||||
$this->uploadDisk = Storage::disk('upload');
|
||||
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -380,7 +384,6 @@ class ImportJobRepository implements ImportJobRepositoryInterface
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
|
@ -54,6 +54,16 @@ class JournalRepository implements JournalRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/** @noinspection MoreThanThreeArgumentsInspection */
|
||||
/**
|
||||
* @param TransactionJournal $journal
|
||||
|
@ -40,6 +40,16 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param LinkType $linkType
|
||||
*
|
||||
|
@ -44,6 +44,16 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
* @param string $amount
|
||||
|
@ -56,6 +56,16 @@ class RecurringRepository implements RecurringRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy a recurring transaction.
|
||||
*
|
||||
|
@ -29,6 +29,7 @@ use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\Models\RuleTrigger;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class RuleRepository.
|
||||
@ -40,6 +41,16 @@ class RuleRepository implements RuleRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -27,6 +27,7 @@ use FireflyIII\Models\RuleGroup;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class RuleGroupRepository.
|
||||
@ -36,6 +37,16 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -43,6 +43,16 @@ class TagRepository implements TagRepositoryInterface
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
@ -36,6 +36,16 @@ use Log;
|
||||
*/
|
||||
class UserRepository implements UserRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
@ -55,6 +65,7 @@ class UserRepository implements UserRepositoryInterface
|
||||
$roleObject = Role::where('name', $role)->first();
|
||||
if (null === $roleObject) {
|
||||
Log::error(sprintf('Could not find role "%s" in attachRole()', $role));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,16 @@ class FixerIOv2 implements ExchangeRateInterface
|
||||
/** @var User */
|
||||
protected $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ('testing' === env('APP_ENV')) {
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param TransactionCurrency $fromCurrency
|
||||
* @param TransactionCurrency $toCurrency
|
||||
|
10
changelog.md
10
changelog.md
@ -2,6 +2,13 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [4.7.6.1] - 2018-09-02
|
||||
### Fixed
|
||||
- An issue where I switched variables from the Docker `.env` file to the normal `.env` file and vice versa -- breaking both.
|
||||
- [Issue 1649](https://github.com/firefly-iii/firefly-iii/issues/1649) 2FA QR code would not show up due to very strict security policy headers
|
||||
- Docker build gave a cURL error whenever it runs PHP commands.
|
||||
|
||||
## [4.7.6] - 2018-09-02
|
||||
### Added
|
||||
- [Issue 145](https://github.com/firefly-iii/firefly-iii/issues/145) You can now download transactions from YNAB.
|
||||
@ -35,15 +42,16 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- [Issue 1598](https://github.com/firefly-iii/firefly-iii/issues/1598) Fix budget calculations.
|
||||
- [Issue 1597](https://github.com/firefly-iii/firefly-iii/issues/1597) Piggy banks are always inactive.
|
||||
- [Issue 1605](https://github.com/firefly-iii/firefly-iii/issues/1605) System will ignore foreign currency setting if user doesn't indicate the amount.
|
||||
- [Issue 1607](https://github.com/firefly-iii/firefly-iii/issues/1607) Firefly III trusts the Heroku load balancer, fixing deployment on Heroku.
|
||||
- [Issue 1608](https://github.com/firefly-iii/firefly-iii/issues/1608) Spelling error in command line import.
|
||||
- [Issue 1609](https://github.com/firefly-iii/firefly-iii/issues/1609) Link to budgets page was absolute.
|
||||
- [Issue 1615](https://github.com/firefly-iii/firefly-iii/issues/1615) Fix currency bug in transactions.
|
||||
- [Issue 1616](https://github.com/firefly-iii/firefly-iii/issues/1616) Fix null pointer exception in pie charts.
|
||||
- [Issue 1617](https://github.com/firefly-iii/firefly-iii/issues/1617) Fix for complex tag names in URL's.
|
||||
- [Issue 1620](https://github.com/firefly-iii/firefly-iii/issues/1620) Fixed index reference in API.
|
||||
- [Issue 1639](https://github.com/firefly-iii/firefly-iii/issues/1639) Firefly III trusts the Heroku load balancer, fixing deployment on Heroku.
|
||||
- [Issue 1642](https://github.com/firefly-iii/firefly-iii/issues/1642) Fix issue with split journals.
|
||||
- [Issue 1643](https://github.com/firefly-iii/firefly-iii/issues/1643) Fix reconciliation issue.
|
||||
|
||||
- Users can no longer give expenses a budget.
|
||||
- Fix bug in Spectre import.
|
||||
- Heroku would not make you owner.
|
||||
|
10
composer.lock
generated
10
composer.lock
generated
@ -1022,16 +1022,16 @@
|
||||
},
|
||||
{
|
||||
"name": "laravel/framework",
|
||||
"version": "v5.6.35",
|
||||
"version": "v5.6.37",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/laravel/framework.git",
|
||||
"reference": "02abbe2091404ebe032a6d5a83075031b7072ebe"
|
||||
"reference": "975e182d42403b0efdf847c05f6bfb99144f95f5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/02abbe2091404ebe032a6d5a83075031b7072ebe",
|
||||
"reference": "02abbe2091404ebe032a6d5a83075031b7072ebe",
|
||||
"url": "https://api.github.com/repos/laravel/framework/zipball/975e182d42403b0efdf847c05f6bfb99144f95f5",
|
||||
"reference": "975e182d42403b0efdf847c05f6bfb99144f95f5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -1157,7 +1157,7 @@
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"time": "2018-08-27T13:18:24+00:00"
|
||||
"time": "2018-09-02T13:51:42+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laravel/passport",
|
||||
|
@ -88,7 +88,7 @@ return [
|
||||
'is_demo_site' => false,
|
||||
],
|
||||
'encryption' => null === env('USE_ENCRYPTION') || env('USE_ENCRYPTION') === true,
|
||||
'version' => '4.7.6',
|
||||
'version' => '4.7.6.1',
|
||||
'api_version' => '0.7',
|
||||
'db_version' => 4,
|
||||
'maxUploadSize' => 15242880,
|
||||
|
@ -392,7 +392,7 @@ return [
|
||||
'rule_action_set_budget' => 'Kostenrahmen zu „:action_value” festlegen',
|
||||
'rule_action_clear_budget' => 'Kostenrahmen leeren',
|
||||
'rule_action_add_tag' => 'Schlagwort „:action_value” hinzufügen',
|
||||
'rule_action_remove_tag' => 'Tag ":action_value" entfernen',
|
||||
'rule_action_remove_tag' => 'Schlagwort „:action_value” entfernen',
|
||||
'rule_action_remove_all_tags' => 'Alle Schlüsselwörter entfernen',
|
||||
'rule_action_set_description' => 'Beschreibung setzen für ":action_value"',
|
||||
'rule_action_append_description' => 'Beschreibungen mit ":action_value" anfügen',
|
||||
@ -490,7 +490,7 @@ Sollen zusätzlich Ihre Girokonten angezeigt werden?',
|
||||
'between_dates' => '(:start und :end)',
|
||||
'pref_optional_fields_transaction' => 'Optionale Felder für Buchungen',
|
||||
'pref_optional_fields_transaction_help' => 'Standardmäßig sind nicht alle Felder aktiviert, wenn eine neue Überweisung erstellt wird (wegen der Übersicht). Unten können Sie diese Felder aktivieren, wenn Sie glauben, dass Sie nützlich für Sie sind. Alle Felder die deaktiviert sind, aber bereits ausgefüllt sind, werden unabhängig von ihren Einstellung sichtbar sein.',
|
||||
'optional_tj_date_fields' => 'Datumsfeld',
|
||||
'optional_tj_date_fields' => 'Datumsfelder',
|
||||
'optional_tj_business_fields' => 'Geschäftsfelder',
|
||||
'optional_tj_attachment_fields' => 'Anlage-Felder',
|
||||
'pref_optional_tj_interest_date' => 'Zinstermin',
|
||||
|
@ -1216,7 +1216,7 @@ return [
|
||||
'no_accounts_create_revenue' => 'Crea conto entrate',
|
||||
'no_accounts_title_liabilities' => 'Creiamo una passività!',
|
||||
'no_accounts_intro_liabilities' => 'Non hai ancora delle passività. Le passività sono conti che registrano le tue carte di credito, i prestiti (studenteschi) e altri debiti.',
|
||||
'no_accounts_imperative_liabilities' => 'Non è necessario che usi questa funzionalità ma può essere utile se vuoi tenere traccia queste cose.',
|
||||
'no_accounts_imperative_liabilities' => 'Non è necessario che usi questa funzionalità ma può essere utile se vuoi tenere traccia di queste cose.',
|
||||
'no_accounts_create_liabilities' => 'Crea una passività',
|
||||
'no_budgets_title_default' => 'Creiamo un budget',
|
||||
'no_budgets_intro_default' => 'Non hai ancora budget. I budget sono usati per organizzare le tue spese in gruppi logici, ai quali puoi dare un tetto indicativo per limitare le tue spese.',
|
||||
|
@ -35,7 +35,7 @@ class AboutControllerTest extends TestCase
|
||||
/**
|
||||
* Set up test
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
|
@ -148,6 +148,40 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new available budget without a valid currency.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest
|
||||
*/
|
||||
public function testStoreNoCurrencyAtAll(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
|
||||
$currencyRepository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'currency_id' => '1',
|
||||
'currency_code' => 'EUR',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Could not find the indicated currency.'); // the amount
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store new available budget without a valid currency.
|
||||
*
|
||||
@ -186,40 +220,6 @@ class AvailableBudgetControllerTest extends TestCase
|
||||
$response->assertSee($availableBudget->amount); // the amount
|
||||
$response->assertHeader('Content-Type', 'application/vnd.api+json');
|
||||
}
|
||||
/**
|
||||
* Store new available budget without a valid currency.
|
||||
*
|
||||
* @covers \FireflyIII\Api\V1\Controllers\AvailableBudgetController
|
||||
* @covers \FireflyIII\Api\V1\Requests\AvailableBudgetRequest
|
||||
*/
|
||||
public function testStoreNoCurrencyAtAll(): void
|
||||
{
|
||||
// mock stuff:
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$currencyRepository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock calls:
|
||||
$repository->shouldReceive('setUser')->once();
|
||||
$currencyRepository->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
|
||||
$currencyRepository->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(null)->once();
|
||||
|
||||
// data to submit
|
||||
$data = [
|
||||
'currency_id' => '1',
|
||||
'currency_code' => 'EUR',
|
||||
'amount' => '100',
|
||||
'start_date' => '2018-01-01',
|
||||
'end_date' => '2018-01-31',
|
||||
];
|
||||
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/available_budgets', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(500);
|
||||
$response->assertSee('Could not find the indicated currency.'); // the amount
|
||||
$response->assertHeader('Content-Type', 'application/json');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update available budget.
|
||||
|
@ -40,7 +40,7 @@ class BillControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
|
@ -239,7 +239,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first());
|
||||
|
||||
$data = [
|
||||
'name' => 'new pigy bank ' . random_int(1, 10000),
|
||||
'name' => 'new pigy bank ' . random_int(1, 10000),
|
||||
'account_id' => 1,
|
||||
'target_amount' => '100',
|
||||
];
|
||||
|
@ -142,6 +142,72 @@ class RuleControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoActions(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
[
|
||||
'name' => 'description_is',
|
||||
'value' => 'Hello',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
'rule_actions' => [
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoTriggers(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
],
|
||||
'rule_actions' => [
|
||||
[
|
||||
'name' => 'add_tag',
|
||||
'value' => 'A',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
@ -183,71 +249,4 @@ class RuleControllerTest extends TestCase
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoTriggers(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
],
|
||||
'rule_actions' => [
|
||||
[
|
||||
'name' => 'add_tag',
|
||||
'value' => 'A',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
$response->assertSee('');
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Api\V1\Controllers\RuleController
|
||||
* @covers \FireflyIII\Api\V1\Requests\RuleRequest
|
||||
*/
|
||||
public function testStoreNoActions(): void
|
||||
{
|
||||
$ruleRepos = $this->mock(RuleRepositoryInterface::class);
|
||||
$ruleRepos->shouldReceive('setUser')->once();
|
||||
$rule = $this->user()->rules()->first();
|
||||
$data = [
|
||||
'title' => 'Store new rule',
|
||||
'rule_group_id' => 1,
|
||||
'trigger' => 'store-journal',
|
||||
'strict' => 1,
|
||||
'stop_processing' => 1,
|
||||
'active' => 1,
|
||||
'rule_triggers' => [
|
||||
[
|
||||
'name' => 'description_is',
|
||||
'value' => 'Hello',
|
||||
'stop_processing' => 1,
|
||||
],
|
||||
],
|
||||
'rule_actions' => [
|
||||
],
|
||||
];
|
||||
|
||||
// test API
|
||||
$response = $this->post('/api/v1/rules', $data, ['Accept' => 'application/json']);
|
||||
$response->assertStatus(422);
|
||||
}
|
||||
|
||||
}
|
@ -90,7 +90,7 @@ class RuleGroupControllerTest extends TestCase
|
||||
public function testShow(): void
|
||||
{
|
||||
/** @var RuleGroup $ruleGroup */
|
||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||
$ruleGroup = $this->user()->ruleGroups()->first();
|
||||
$ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
|
||||
$ruleGroupRepos->shouldReceive('setUser')->once();
|
||||
|
||||
|
@ -28,9 +28,7 @@ use FireflyIII\Exceptions\FireflyException;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollector;
|
||||
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
|
||||
use FireflyIII\Helpers\Filter\NegativeAmountFilter;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
@ -46,7 +44,7 @@ class TransactionControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
@ -1329,16 +1327,8 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testShowDeposit(): void
|
||||
{
|
||||
$loop = 0;
|
||||
do {
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 2)->whereNull('deleted_at')->first();
|
||||
$count = $journal->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
$transaction = $journal->transactions()->first();
|
||||
|
||||
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$transaction = $deposit->transactions()->first();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')
|
||||
@ -1350,7 +1340,7 @@ class TransactionControllerTest extends TestCase
|
||||
$collector->setUser($this->user());
|
||||
$collector->withOpposingAccount()->withCategoryInformation()->withBudgetInformation();
|
||||
$collector->setAllAssetAccounts();
|
||||
$collector->setJournals(new Collection([$journal]));
|
||||
$collector->setJournals(new Collection([$deposit]));
|
||||
$collector->setLimit(5)->setPage(1);
|
||||
$transactions = $collector->getTransactions();
|
||||
|
||||
@ -1374,7 +1364,7 @@ class TransactionControllerTest extends TestCase
|
||||
[
|
||||
'data' => [[
|
||||
'attributes' => [
|
||||
'description' => $journal->description,
|
||||
'description' => $deposit->description,
|
||||
'type' => 'Deposit',
|
||||
],
|
||||
]],
|
||||
@ -1393,15 +1383,7 @@ class TransactionControllerTest extends TestCase
|
||||
*/
|
||||
public function testShowWithdrawal(): void
|
||||
{
|
||||
$loop = 0;
|
||||
do {
|
||||
// this is kind of cheating but OK.
|
||||
/** @var TransactionJournal $journal */
|
||||
$journal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->whereNull('deleted_at')->first();
|
||||
$count = $journal->transactions()->count();
|
||||
$loop++;
|
||||
} while ($count !== 2 && $loop < 30);
|
||||
/** @var Transaction $transaction */
|
||||
$journal = $this->getRandomWithdrawal();
|
||||
$transaction = $journal->transactions()->first();
|
||||
$transaction->description = null;
|
||||
$transaction->save();
|
||||
@ -2441,7 +2423,7 @@ class TransactionControllerTest extends TestCase
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsById')->withArgs([[$account->id]])->andReturn(new Collection([$account]));
|
||||
|
||||
$data = [
|
||||
$data = [
|
||||
'description' => 'Some deposit #' . random_int(1, 10000),
|
||||
'date' => '2018-01-01',
|
||||
'transactions' => [
|
||||
@ -2452,12 +2434,7 @@ class TransactionControllerTest extends TestCase
|
||||
],
|
||||
],
|
||||
];
|
||||
do {
|
||||
/** @var TransactionJournal $deposit */
|
||||
$deposit = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 2)->first();
|
||||
$count = $deposit->transactions()->count();
|
||||
} while ($count !== 2);
|
||||
|
||||
$deposit = $this->getRandomDeposit();
|
||||
$transaction = $deposit->transactions()->first();
|
||||
$repository->shouldReceive('setUser');
|
||||
$repository->shouldReceive('update')->andReturn($deposit)->once();
|
||||
@ -2494,13 +2471,8 @@ class TransactionControllerTest extends TestCase
|
||||
],
|
||||
],
|
||||
];
|
||||
do {
|
||||
/** @var TransactionJournal $withdrawal */
|
||||
$withdrawal = $this->user()->transactionJournals()->inRandomOrder()->where('transaction_type_id', 1)->first();
|
||||
$count = $withdrawal->transactions()->count();
|
||||
} while ($count !== 2);
|
||||
|
||||
|
||||
$withdrawal = $this->getRandomWithdrawal();
|
||||
$transaction = $withdrawal->transactions()->first();
|
||||
$repository->shouldReceive('setUser');
|
||||
$repository->shouldReceive('update')->andReturn($withdrawal)->once();
|
||||
|
@ -40,7 +40,7 @@ class UserControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Passport::actingAs($this->user());
|
||||
|
@ -30,11 +30,12 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Preferences;
|
||||
use Tests\TestCase;
|
||||
|
||||
use Mockery;
|
||||
/**
|
||||
*
|
||||
* Class CreateControllerTest
|
||||
@ -60,9 +61,13 @@ class CreateControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
// get all types:
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Debt'])->andReturn(AccountType::find(11))->once();
|
||||
$accountRepos->shouldReceive('getAccountTypeByType')->withArgs(['Loan'])->andReturn(AccountType::find(9))->once();
|
||||
@ -87,7 +92,7 @@ class CreateControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
@ -116,7 +121,7 @@ class CreateControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('store')->once()->andReturn(factory(Account::class)->make());
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
@ -29,8 +29,10 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -57,10 +59,13 @@ class DeleteControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository->shouldReceive('getAccountsByType')->withArgs([[AccountType::ASSET]])->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$account = $this->user()->accounts()->where('account_type_id', 3)->whereNull('deleted_at')->first();
|
||||
$response = $this->get(route('accounts.delete', [$account->id]));
|
||||
@ -78,7 +83,6 @@ class DeleteControllerTest extends TestCase
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository->shouldReceive('findNull')->withArgs([0])->once()->andReturn(null);
|
||||
$repository->shouldReceive('destroy')->andReturn(true);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
@ -31,6 +31,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@ -56,11 +57,16 @@ class EditControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::find(1))->atLeast()->once();
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$accountRepos->shouldReceive('getNoteText')->andReturn('Some text')->once();
|
||||
@ -97,9 +103,13 @@ class EditControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditLiability(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
$repository->shouldReceive('get')->andReturn(new Collection);
|
||||
@ -139,9 +149,13 @@ class EditControllerTest extends TestCase
|
||||
public function testEditNull(): void
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(2));
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(null);
|
||||
@ -187,6 +201,7 @@ class EditControllerTest extends TestCase
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('update')->once();
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
||||
|
@ -28,6 +28,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@ -67,6 +68,11 @@ class IndexControllerTest extends TestCase
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]));
|
||||
$repository->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
|
@ -30,6 +30,7 @@ use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
@ -56,7 +57,14 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$transaction = $journal->transactions()->where('amount', '>', 0)->first();
|
||||
$repository->shouldReceive('firstNull')->andReturn($journal);
|
||||
@ -80,6 +88,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testEditRedirect(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile.edit', [$journal->id]));
|
||||
@ -95,7 +106,13 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcile(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile', [1, '20170101', '20170131']));
|
||||
@ -126,7 +143,13 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcileNoDates(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
@ -144,7 +167,13 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcileNoEndDate(): void
|
||||
{
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$repository->shouldReceive('findNull')->once()->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$this->be($this->user());
|
||||
@ -162,6 +191,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testReconcileNotAsset(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$account = $this->user()->accounts()->where('account_type_id', '!=', 6)->where('account_type_id', '!=', 3)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile', [$account->id, '20170101', '20170131']));
|
||||
@ -175,8 +207,16 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testShow(): void
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(), 'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
|
||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getAssetTransaction')->once()->andReturn($journal->transactions()->first());
|
||||
|
||||
@ -196,8 +236,12 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testShowError(): void
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository = $this->mock(JournalRepositoryInterface::class);
|
||||
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
|
||||
$repository->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
$repository->shouldReceive('getAssetTransaction')->once()->andReturnNull();
|
||||
|
||||
@ -217,6 +261,9 @@ class ReconcileControllerTest extends TestCase
|
||||
*/
|
||||
public function testShowSomethingElse(): void
|
||||
{
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('accounts.reconcile.show', [$journal->id]));
|
||||
@ -234,6 +281,8 @@ class ReconcileControllerTest extends TestCase
|
||||
{
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('reconcileById')->andReturn(true);
|
||||
$journalRepos->shouldReceive('store')->andReturn(new TransactionJournal);
|
||||
@ -262,6 +311,9 @@ class ReconcileControllerTest extends TestCase
|
||||
public function testUpdate(): void
|
||||
{
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->andReturn(new TransactionJournal);
|
||||
$journalRepos->shouldReceive('getJournalSourceAccounts')->andReturn(new Collection([new Account]));
|
||||
$journalRepos->shouldReceive('getJournalDestinationAccounts')->andReturn(new Collection([new Account]));
|
||||
@ -285,9 +337,7 @@ class ReconcileControllerTest extends TestCase
|
||||
public function testUpdateNotReconcile(): void
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', '!=', 5)->first();
|
||||
$data = [
|
||||
'amount' => '5',
|
||||
];
|
||||
$data = ['amount' => '5',];
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);
|
||||
@ -302,9 +352,7 @@ class ReconcileControllerTest extends TestCase
|
||||
public function testUpdateZero(): void
|
||||
{
|
||||
$journal = $this->user()->transactionJournals()->where('transaction_type_id', 5)->first();
|
||||
$data = [
|
||||
'amount' => '0',
|
||||
];
|
||||
$data = ['amount' => '0',];
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('accounts.reconcile.update', [$journal->id]), $data);
|
||||
|
@ -32,9 +32,11 @@ use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use Illuminate\Pagination\LengthAwarePaginator;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
@ -68,6 +70,10 @@ class ShowControllerTest extends TestCase
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
@ -100,41 +106,6 @@ class ShowControllerTest extends TestCase
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowLiability(string $range): void
|
||||
{
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
$account = $this->user()->accounts()->where('account_type_id', 12)->whereNull('deleted_at')->first();
|
||||
|
||||
// mock stuff:
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
||||
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||
$repository->shouldReceive('isLiability')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('accounts.show', [$account->id]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('accounts.show.all', [$account->id]));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @dataProvider dateRangeProvider
|
||||
@ -150,6 +121,10 @@ class ShowControllerTest extends TestCase
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
@ -189,9 +164,8 @@ class ShowControllerTest extends TestCase
|
||||
public function testShowBrokenBadDates(): void
|
||||
{
|
||||
// mock
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$this->session(['start' => '2018-01-01', 'end' => '2017-12-01']);
|
||||
|
||||
$this->be($this->user());
|
||||
@ -207,7 +181,6 @@ class ShowControllerTest extends TestCase
|
||||
{
|
||||
// mock
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
@ -232,6 +205,12 @@ class ShowControllerTest extends TestCase
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$userRepos = $this->mock(UserRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
// mock hasRole for user repository:
|
||||
$userRepos->shouldReceive('hasRole')->withArgs([Mockery::any(),'owner'])->andReturn(true)->atLeast()->once();
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$collector->shouldReceive('setAccounts')->andReturnSelf();
|
||||
$collector->shouldReceive('setRange')->andReturnSelf();
|
||||
@ -239,7 +218,7 @@ class ShowControllerTest extends TestCase
|
||||
$collector->shouldReceive('setPage')->andReturnSelf();
|
||||
$collector->shouldReceive('getPaginatedTransactions')->andReturn(new LengthAwarePaginator([], 0, 10));
|
||||
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$repository->shouldReceive('oldestJournalDate')->andReturn(new Carbon);
|
||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||
$repository->shouldReceive('isLiability')->andReturn(false);
|
||||
@ -265,8 +244,7 @@ class ShowControllerTest extends TestCase
|
||||
{
|
||||
// mock stuff
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
@ -277,4 +255,39 @@ class ShowControllerTest extends TestCase
|
||||
$response->assertStatus(302);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Account\ShowController
|
||||
* @dataProvider dateRangeProvider
|
||||
*
|
||||
* @param string $range
|
||||
*/
|
||||
public function testShowLiability(string $range): void
|
||||
{
|
||||
$date = new Carbon;
|
||||
$this->session(['start' => $date, 'end' => clone $date]);
|
||||
$account = $this->user()->accounts()->where('account_type_id', 12)->whereNull('deleted_at')->first();
|
||||
|
||||
// mock stuff:
|
||||
$tasker = $this->mock(AccountTaskerInterface::class);
|
||||
$journalRepos = $this->mock(JournalRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$repository = $this->mock(AccountRepositoryInterface::class);
|
||||
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
$journalRepos->shouldReceive('firstNull')->once()->andReturn(new TransactionJournal);
|
||||
$tasker->shouldReceive('amountOutInPeriod')->withAnyArgs()->andReturn('-1');
|
||||
$tasker->shouldReceive('amountInInPeriod')->withAnyArgs()->andReturn('1');
|
||||
|
||||
|
||||
$repository->shouldReceive('getMetaValue')->andReturn('');
|
||||
$repository->shouldReceive('isLiability')->andReturn(true);
|
||||
|
||||
$this->be($this->user());
|
||||
$this->changeDateRange($this->user(), $range);
|
||||
$response = $this->get(route('accounts.show', [$account->id]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertRedirect(route('accounts.show.all', [$account->id]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class ConfigurationControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -35,7 +35,7 @@ class HomeControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -36,7 +36,7 @@ class LinkControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,7 +40,7 @@ class UpdateControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class AttachmentControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -34,7 +34,7 @@ class ForgotPasswordControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -36,7 +36,7 @@ class TwoFactorControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -51,7 +51,7 @@ class BillControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -159,9 +159,9 @@ class AmountControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '100';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
@ -169,45 +169,6 @@ class AmountControllerTest extends TestCase
|
||||
$collector->shouldReceive('getTransactions')->andReturn($incomeCollection, $expenseCollection)->times(2);
|
||||
|
||||
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getAverageAvailable')->andReturn('100.123')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.income.info', ['20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Budget\AmountController
|
||||
*/
|
||||
public function testInfoIncomeInversed(): void
|
||||
{
|
||||
Log::debug('Now in testInfoIncome()');
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '100';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '150';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
|
||||
$collector->shouldReceive('getTransactions')->andReturn($incomeCollection, $expenseCollection)->times(2);
|
||||
|
||||
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
@ -242,9 +203,9 @@ class AmountControllerTest extends TestCase
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '150';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '100';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
@ -257,6 +218,42 @@ class AmountControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Budget\AmountController
|
||||
*/
|
||||
public function testInfoIncomeInversed(): void
|
||||
{
|
||||
Log::debug('Now in testInfoIncome()');
|
||||
// mock stuff
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$repository = $this->mock(BudgetRepositoryInterface::class);
|
||||
$collector = $this->mock(TransactionCollectorInterface::class);
|
||||
|
||||
$collector->shouldReceive('setAllAssetAccounts')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setRange')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('setTypes')->andReturnSelf()->times(2);
|
||||
$collector->shouldReceive('withOpposingAccount')->andReturnSelf()->times(2);
|
||||
|
||||
// collect transactions to return. First an expense, then income.
|
||||
$income = new Transaction;
|
||||
$income->transaction_amount = '100';
|
||||
$incomeCollection = new Collection([$income]);
|
||||
$expense = new Transaction;
|
||||
$expense->transaction_amount = '150';
|
||||
$expenseCollection = new Collection([$expense]);
|
||||
|
||||
$collector->shouldReceive('getTransactions')->andReturn($incomeCollection, $expenseCollection)->times(2);
|
||||
|
||||
|
||||
$repository->shouldReceive('getAvailableBudget')->andReturn('100.123');
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection);
|
||||
$repository->shouldReceive('getAverageAvailable')->andReturn('100.123')->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('budgets.income.info', ['20170101', '20170131']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Budget\AmountController
|
||||
|
@ -49,7 +49,7 @@ class AccountControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,10 +40,10 @@ class BillControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug('Now in Feature/Controllers/Chart/Test.');
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,10 +46,10 @@ class BudgetControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug('Now in Feature/Controllers/Chart/Test.');
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ class BudgetReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class CategoryControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class CategoryReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class ExpenseReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -37,7 +37,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -26,9 +26,10 @@ use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
||||
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
|
||||
use FireflyIII\Repositories\Account\AccountTaskerInterface;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Steam;
|
||||
use Tests\TestCase;
|
||||
use Mockery;
|
||||
|
||||
/**
|
||||
* Class ReportControllerTest
|
||||
*/
|
||||
@ -37,7 +38,7 @@ class ReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -55,7 +56,7 @@ class ReportControllerTest extends TestCase
|
||||
$accountRepos->shouldReceive('setUser');
|
||||
|
||||
$accountRepos->shouldReceive('getMetaValue')->times(2)
|
||||
->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1','0');
|
||||
->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('1', '0');
|
||||
$accountRepos->shouldReceive('getMetaValue')
|
||||
->withArgs([Mockery::any(), 'currency_id'])->andReturn(1);
|
||||
$accountRepos->shouldReceive('getMetaValue')
|
||||
|
@ -46,7 +46,7 @@ class TagReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class CurrencyControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -314,7 +314,7 @@ class CurrencyControllerTest extends TestCase
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('currencies.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('error','Could not store the new currency.');
|
||||
$response->assertSessionHas('error', 'Could not store the new currency.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,7 +39,7 @@ class DebugControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class ExportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class HelpControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -48,7 +48,7 @@ class HomeControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -26,9 +26,9 @@ namespace Tests\Feature\Controllers\Import;
|
||||
|
||||
use FireflyIII\Models\ImportJob;
|
||||
use FireflyIII\Repositories\ImportJob\ImportJobRepositoryInterface;
|
||||
use Tests\TestCase;
|
||||
use Log;
|
||||
use Mockery;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -48,11 +48,12 @@ class CallbackControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\CallbackController
|
||||
*/
|
||||
public function testYnabBasic(): void {
|
||||
public function testYnabBasic(): void
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// config for job:
|
||||
$config = [];
|
||||
$config = [];
|
||||
$newConfig = ['auth_code' => 'abc'];
|
||||
|
||||
// mock calls.
|
||||
@ -72,7 +73,8 @@ class CallbackControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\CallbackController
|
||||
*/
|
||||
public function testYnabBasicBadJob(): void {
|
||||
public function testYnabBasicBadJob(): void
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// mock calls.
|
||||
@ -87,11 +89,12 @@ class CallbackControllerTest extends TestCase
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Import\CallbackController
|
||||
*/
|
||||
public function testYnabBasicNoCode(): void {
|
||||
public function testYnabBasicNoCode(): void
|
||||
{
|
||||
$repository = $this->mock(ImportJobRepositoryInterface::class);
|
||||
|
||||
// config for job:
|
||||
$config = [];
|
||||
$config = [];
|
||||
$newConfig = ['auth_code' => 'abc'];
|
||||
|
||||
// mock calls.
|
||||
|
@ -46,7 +46,7 @@ class IndexControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -40,7 +40,7 @@ class JobConfigurationControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class JobStatusControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -45,7 +45,7 @@ class JavascriptControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -62,7 +62,9 @@ class JavascriptControllerTest extends TestCase
|
||||
$account = factory(Account::class)->make();
|
||||
|
||||
$accountRepos->shouldReceive('getAccountsByType')->andReturn(new Collection([$account]))
|
||||
->withArgs([[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT,AccountType::LOAN,AccountType::MORTGAGE, AccountType::CREDITCARD]])->once();
|
||||
->withArgs(
|
||||
[[AccountType::DEFAULT, AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE, AccountType::CREDITCARD]]
|
||||
)->once();
|
||||
$currencyRepos->shouldReceive('findByCodeNull')->withArgs(['EUR'])->andReturn(new TransactionCurrency);
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
|
||||
|
@ -52,7 +52,7 @@ class AutoCompleteControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -44,7 +44,7 @@ class BoxControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -182,37 +182,6 @@ class BoxControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
public function testNetWorthNoInclude(): void
|
||||
{
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
'balance' => '3',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$netWorthHelper = $this->mock(NetWorthInterface::class);
|
||||
$netWorthHelper->shouldReceive('setUser')->once();
|
||||
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('0');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
@ -278,6 +247,37 @@ class BoxControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
public function testNetWorthNoInclude(): void
|
||||
{
|
||||
$result = [
|
||||
[
|
||||
'currency' => TransactionCurrency::find(1),
|
||||
'balance' => '3',
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
$netWorthHelper = $this->mock(NetWorthInterface::class);
|
||||
$netWorthHelper->shouldReceive('setUser')->once();
|
||||
$netWorthHelper->shouldReceive('getNetWorthByCurrency')->once()->andReturn($result);
|
||||
|
||||
$accountRepos = $this->mock(AccountRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$accountRepos->shouldReceive('getActiveAccountsByType')->andReturn(new Collection([$this->user()->accounts()->first()]));
|
||||
$currencyRepos->shouldReceive('findNull')->andReturn(TransactionCurrency::find(1));
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'accountRole'])->andReturn('ccAsset');
|
||||
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'include_net_worth'])->andReturn('0');
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.box.net-worth'));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\BoxController
|
||||
*/
|
||||
|
@ -40,7 +40,7 @@ class ExchangeControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
@ -61,6 +61,20 @@ class ExchangeControllerTest extends TestCase
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\ExchangeController
|
||||
*/
|
||||
public function testGetRateAmount(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$repository->shouldReceive('getExchangeRate')->andReturn($rate);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.rate', ['EUR', 'USD', '20170101']) . '?amount=10');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\ExchangeController
|
||||
*/
|
||||
@ -78,18 +92,4 @@ class ExchangeControllerTest extends TestCase
|
||||
$response = $this->get(route('json.rate', ['EUR', 'USD', '20170101']));
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Json\ExchangeController
|
||||
*/
|
||||
public function testGetRateAmount(): void
|
||||
{
|
||||
$repository = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$rate = factory(CurrencyExchangeRate::class)->make();
|
||||
$repository->shouldReceive('getExchangeRate')->andReturn($rate);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('json.rate', ['EUR', 'USD', '20170101']) . '?amount=10');
|
||||
$response->assertStatus(200);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class FrontpageControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -37,7 +37,7 @@ class IntroControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -41,7 +41,7 @@ class ReconcileControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class JsonControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -42,7 +42,7 @@ class NewUserControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -50,7 +50,7 @@ class PiggyBankControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class ReportControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -43,7 +43,7 @@ class PreferencesControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -46,7 +46,7 @@ class ProfileControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -28,6 +28,7 @@ use Carbon\Carbon;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
@ -74,35 +75,189 @@ class CreateControllerTest extends TestCase
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$tomorrow = Carbon::create()->addDays(2);
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$data = [
|
||||
'title' => 'hello',
|
||||
'title' => 'hello' . random_int(1, 100000),
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'repetition_type' => 'daily',
|
||||
'skip' => 0,
|
||||
'recurring_description' => 'Some descr',
|
||||
'recurring_description' => 'Some descr' . random_int(1, 100000),
|
||||
'active' => '1',
|
||||
'apply_rules' => '1',
|
||||
'foreign_amount' => '1',
|
||||
'foreign_currency_id' => '2',
|
||||
|
||||
// mandatory for transaction:
|
||||
'transaction_description' => 'Some descr',
|
||||
'transaction_type' => 'withdrawal',
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '30',
|
||||
|
||||
// mandatory account info:
|
||||
'source_id' => '1',
|
||||
'source_name' => '',
|
||||
'destination_id' => '',
|
||||
'destination_name' => 'Some Expense',
|
||||
|
||||
// optional fields:
|
||||
'budget_id' => '1',
|
||||
'category' => 'CategoryA',
|
||||
'tags' => 'A,B,C',
|
||||
'create_another' => '1',
|
||||
'repetition_end' => 'times',
|
||||
'repetitions' => 3,
|
||||
];
|
||||
|
||||
'repetition_end' => 'times',
|
||||
'repetitions' => 3,
|
||||
$recurringRepos->shouldReceive('store')->andReturn($recurrence)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('recurring.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\CreateController
|
||||
* @covers \FireflyIII\Http\Requests\RecurrenceFormRequest
|
||||
*/
|
||||
public function testStoreDeposit(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tomorrow = Carbon::create()->addDays(2);
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$data = [
|
||||
'title' => 'hello' . random_int(1, 100000),
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'repetition_type' => 'daily',
|
||||
'skip' => 0,
|
||||
'recurring_description' => 'Some descr' . random_int(1, 100000),
|
||||
'active' => '1',
|
||||
'apply_rules' => '1',
|
||||
'foreign_amount' => '1',
|
||||
'foreign_currency_id' => '2',
|
||||
|
||||
// mandatory for transaction:
|
||||
'transaction_description' => 'Some descr',
|
||||
'transaction_type' => 'deposit',
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '30',
|
||||
|
||||
// mandatory account info:
|
||||
'source_id' => '2',
|
||||
'source_name' => 'Some source',
|
||||
'destination_id' => '1',
|
||||
'destination_name' => 'Some Expense',
|
||||
|
||||
// optional fields:
|
||||
'budget_id' => '1',
|
||||
'category' => 'CategoryA',
|
||||
'tags' => 'A,B,C',
|
||||
'create_another' => '1',
|
||||
'repetition_end' => 'times',
|
||||
'repetitions' => 3,
|
||||
];
|
||||
|
||||
$recurringRepos->shouldReceive('store')->andReturn($recurrence)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('recurring.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\CreateController
|
||||
* @covers \FireflyIII\Http\Requests\RecurrenceFormRequest
|
||||
*/
|
||||
public function testStoreTransfer(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$tomorrow = Carbon::create()->addDays(2);
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$data = [
|
||||
'title' => 'hello' . random_int(1, 100000),
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'repetition_type' => 'daily',
|
||||
'skip' => 0,
|
||||
'recurring_description' => 'Some descr' . random_int(1, 100000),
|
||||
'active' => '1',
|
||||
'apply_rules' => '1',
|
||||
'foreign_amount' => '1',
|
||||
'foreign_currency_id' => '2',
|
||||
|
||||
// mandatory for transaction:
|
||||
'transaction_description' => 'Some descr',
|
||||
'transaction_type' => 'transfer',
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '30',
|
||||
|
||||
// mandatory account info:
|
||||
'source_id' => '2',
|
||||
'source_name' => 'Some source',
|
||||
'destination_id' => '1',
|
||||
'destination_name' => 'Some Expense',
|
||||
|
||||
// optional fields:
|
||||
'budget_id' => '1',
|
||||
'category' => 'CategoryA',
|
||||
'tags' => 'A,B,C',
|
||||
'create_another' => '1',
|
||||
'repetition_end' => 'times',
|
||||
'repetitions' => 3,
|
||||
];
|
||||
|
||||
$recurringRepos->shouldReceive('store')->andReturn($recurrence)->once();
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('recurring.store'), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\CreateController
|
||||
* @covers \FireflyIII\Http\Requests\RecurrenceFormRequest
|
||||
*/
|
||||
public function testStoreUntilDate(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
|
||||
$tomorrow = Carbon::create()->addDays(2);
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$data = [
|
||||
'title' => 'hello' . random_int(1, 100000),
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'repetition_type' => 'daily',
|
||||
'skip' => 0,
|
||||
'recurring_description' => 'Some descr' . random_int(1, 100000),
|
||||
'active' => '1',
|
||||
'apply_rules' => '1',
|
||||
'foreign_amount' => '1',
|
||||
'foreign_currency_id' => '2',
|
||||
|
||||
// mandatory for transaction:
|
||||
'transaction_description' => 'Some descr',
|
||||
'transaction_type' => 'withdrawal',
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '30',
|
||||
|
||||
// mandatory account info:
|
||||
'source_id' => '1',
|
||||
'destination_name' => 'Some Expense',
|
||||
|
||||
// optional fields:
|
||||
'budget_id' => '1',
|
||||
'category' => 'CategoryA',
|
||||
'tags' => 'A,B,C',
|
||||
'create_another' => '1',
|
||||
'repetition_end' => 'until_date',
|
||||
'repeat_until' => $tomorrow->format('Y-m-d'),
|
||||
];
|
||||
|
||||
$recurringRepos->shouldReceive('store')->andReturn($recurrence)->once();
|
||||
|
77
tests/Feature/Controllers/Recurring/DeleteControllerTest.php
Normal file
77
tests/Feature/Controllers/Recurring/DeleteControllerTest.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* DeleteControllerTest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Recurring;
|
||||
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class DeleteControllerTest
|
||||
*/
|
||||
class DeleteControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\DeleteController
|
||||
*/
|
||||
public function testDelete(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$recurringRepos->shouldReceive('getTransactions')->andReturn(new Collection())->once();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('recurring.delete', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\DeleteController
|
||||
*/
|
||||
public function testDestroy(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$recurringRepos->shouldReceive('destroy')->once();
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('recurring.destroy', [1]));
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
|
||||
}
|
125
tests/Feature/Controllers/Recurring/EditControllerTest.php
Normal file
125
tests/Feature/Controllers/Recurring/EditControllerTest.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
/**
|
||||
* EditControllerTest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Recurring;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use FireflyIII\Repositories\Budget\BudgetRepositoryInterface;
|
||||
use FireflyIII\Repositories\Category\CategoryRepositoryInterface;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class EditControllerTest
|
||||
*/
|
||||
class EditControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\EditController
|
||||
*/
|
||||
public function testEdit(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
|
||||
$recurringRepos->shouldReceive('setUser');
|
||||
$recurringRepos->shouldReceive('getNoteText')->andReturn('Note!');
|
||||
$recurringRepos->shouldReceive('repetitionDescription')->andReturn('dunno');
|
||||
$recurringRepos->shouldReceive('getXOccurrences')->andReturn([]);
|
||||
$budgetRepos->shouldReceive('findNull')->andReturn($this->user()->budgets()->first());
|
||||
|
||||
|
||||
$budgetRepos->shouldReceive('getActiveBudgets')->andReturn(new Collection)->once();
|
||||
//\Amount::shouldReceive('getDefaultCurrency')->andReturn(TransactionCurrency::find(1));
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('recurring.edit', [1]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\EditController
|
||||
* @covers \FireflyIII\Http\Requests\RecurrenceFormRequest
|
||||
*/
|
||||
public function testUpdate(): void
|
||||
{
|
||||
$recurringRepos = $this->mock(RecurringRepositoryInterface::class);
|
||||
$budgetRepos = $this->mock(BudgetRepositoryInterface::class);
|
||||
$categoryRepos = $this->mock(CategoryRepositoryInterface::class);
|
||||
|
||||
$recurringRepos->shouldReceive('update')->once();
|
||||
|
||||
$tomorrow = Carbon::create()->addDays(2);
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$data = [
|
||||
'id' => $recurrence->id,
|
||||
'title' => 'hello',
|
||||
'first_date' => $tomorrow->format('Y-m-d'),
|
||||
'repetition_type' => 'daily',
|
||||
'skip' => 0,
|
||||
'recurring_description' => 'Some descr',
|
||||
'active' => '1',
|
||||
'apply_rules' => '1',
|
||||
'return_to_edit' => '1',
|
||||
// mandatory for transaction:
|
||||
'transaction_description' => 'Some descr',
|
||||
'transaction_type' => 'withdrawal',
|
||||
'transaction_currency_id' => '1',
|
||||
'amount' => '30',
|
||||
// mandatory account info:
|
||||
'source_id' => '1',
|
||||
'source_name' => '',
|
||||
'destination_id' => '',
|
||||
'destination_name' => 'Some Expense',
|
||||
|
||||
// optional fields:
|
||||
'budget_id' => '1',
|
||||
'category' => 'CategoryA',
|
||||
'tags' => 'A,B,C',
|
||||
'create_another' => '1',
|
||||
'repetition_end' => 'times',
|
||||
'repetitions' => 3,
|
||||
];
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->post(route('recurring.update', [1]), $data);
|
||||
$response->assertStatus(302);
|
||||
$response->assertSessionHas('success');
|
||||
}
|
||||
|
||||
}
|
97
tests/Feature/Controllers/Recurring/IndexControllerTest.php
Normal file
97
tests/Feature/Controllers/Recurring/IndexControllerTest.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* IndexControllerTest.php
|
||||
* Copyright (c) 2018 thegrumpydictator@gmail.com
|
||||
*
|
||||
* This file is part of Firefly III.
|
||||
*
|
||||
* Firefly III is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Firefly III is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Controllers\Recurring;
|
||||
|
||||
use FireflyIII\Models\Configuration;
|
||||
use FireflyIII\Repositories\Recurring\RecurringRepositoryInterface;
|
||||
use Illuminate\Support\Collection;
|
||||
use Log;
|
||||
use Tests\TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* Class IndexControllerTest
|
||||
*/
|
||||
class IndexControllerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \FireflyIII\Http\Controllers\Recurring\IndexController
|
||||
*/
|
||||
public function testIndex(): void
|
||||
{
|
||||
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
|
||||
$config = new Configuration;
|
||||
$config->data = 0;
|
||||
|
||||
$falseConfig = new Configuration;
|
||||
$falseConfig->data = false;
|
||||
|
||||
$collection = $this->user()->recurrences()->take(2)->get();
|
||||
|
||||
// mock cron job config:
|
||||
\FireflyConfig::shouldReceive('get')->withArgs(['last_rt_job', 0])->once()->andReturn($config);
|
||||
\FireflyConfig::shouldReceive('get')->withArgs(['is_demo_site', false])->once()->andReturn($falseConfig);
|
||||
|
||||
$repository->shouldReceive('get')->andReturn($collection)->once();
|
||||
$repository->shouldReceive('setUser');
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Notes');
|
||||
$repository->shouldReceive('repetitionDescription')->andReturn('Bla');
|
||||
$repository->shouldReceive('getXOccurrences')->andReturn([]);
|
||||
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('recurring.index'));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
public function testShow(): void
|
||||
{
|
||||
$repository = $this->mock(RecurringRepositoryInterface::class);
|
||||
$recurrence = $this->user()->recurrences()->first();
|
||||
$repository->shouldReceive('setUser');
|
||||
$repository->shouldReceive('getNoteText')->andReturn('Notes');
|
||||
$repository->shouldReceive('repetitionDescription')->andReturn('Bla');
|
||||
$repository->shouldReceive('getXOccurrences')->andReturn([]);
|
||||
$repository->shouldReceive('getTransactions')->andReturn(new Collection);
|
||||
|
||||
$this->be($this->user());
|
||||
$response = $this->get(route('recurring.show', [$recurrence->id]));
|
||||
$response->assertStatus(200);
|
||||
$response->assertSee('<ol class="breadcrumb">');
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -38,7 +38,7 @@ class AccountControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
@ -39,7 +39,7 @@ class BalanceControllerTest extends TestCase
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function setUp()
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Log::debug(sprintf('Now in %s.', \get_class($this)));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user