Improved code coverage for events and reports.

This commit is contained in:
James Cole 2018-08-24 16:07:33 +02:00
parent 2b54363dd7
commit 850a0ae17e
14 changed files with 566 additions and 101 deletions

View File

@ -54,6 +54,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
*
* @return string
* @throws FireflyException
* @codeCoverageIgnore
*/
public function generate(): string
{
@ -91,6 +92,65 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $result;
}
/**
* Get the audit report.
*
* @param Account $account
* @param Carbon $date
*
* @return array
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
* @throws FireflyException
*/
public function getAuditReport(Account $account, Carbon $date): array
{
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$accountRepository->setUser($account->user);
/** @var TransactionCollectorInterface $collector */
$collector = app(TransactionCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end);
$journals = $collector->getTransactions();
$journals = $journals->reverse();
$dayBeforeBalance = app('steam')->balance($account, $date);
$startBalance = $dayBeforeBalance;
$currency = $currencyRepos->findNull((int)$accountRepository->getMetaValue($account, 'currency_id'));
if (null === $currency) {
throw new FireflyException('Unexpected NULL value in account currency preference.');
}
/** @var Transaction $transaction */
foreach ($journals as $transaction) {
$transaction->before = $startBalance;
$transactionAmount = $transaction->transaction_amount;
if ($currency->id === $transaction->foreign_currency_id) {
$transactionAmount = $transaction->transaction_foreign_amount;
}
$newBalance = bcadd($startBalance, $transactionAmount);
$transaction->after = $newBalance;
$startBalance = $newBalance;
}
$return = [
'journals' => $journals->reverse(),
'exists' => $journals->count() > 0,
'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
'endBalance' => app('steam')->balance($account, $this->end),
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
'dayBeforeBalance' => $dayBeforeBalance,
];
return $return;
}
/**
* Account collection setter.
*
@ -187,63 +247,4 @@ class MonthReportGenerator implements ReportGeneratorInterface
{
return $this;
}
/**
* Get the audit report.
*
* @param Account $account
* @param Carbon $date
*
* @return array
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // not that long
* @throws FireflyException
*/
private function getAuditReport(Account $account, Carbon $date): array
{
/** @var CurrencyRepositoryInterface $currencyRepos */
$currencyRepos = app(CurrencyRepositoryInterface::class);
/** @var AccountRepositoryInterface $accountRepository */
$accountRepository = app(AccountRepositoryInterface::class);
$accountRepository->setUser($account->user);
/** @var TransactionCollectorInterface $collector */
$collector = app(TransactionCollectorInterface::class);
$collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end);
$journals = $collector->getTransactions();
$journals = $journals->reverse();
$dayBeforeBalance = app('steam')->balance($account, $date);
$startBalance = $dayBeforeBalance;
$currency = $currencyRepos->findNull((int)$accountRepository->getMetaValue($account, 'currency_id'));
if (null === $currency) {
throw new FireflyException('Unexpected NULL value in account currency preference.');
}
/** @var Transaction $transaction */
foreach ($journals as $transaction) {
$transaction->before = $startBalance;
$transactionAmount = $transaction->transaction_amount;
if ($currency->id === $transaction->foreign_currency_id) {
$transactionAmount = $transaction->transaction_foreign_amount;
}
$newBalance = bcadd($startBalance, $transactionAmount);
$transaction->after = $newBalance;
$startBalance = $newBalance;
}
$return = [
'journals' => $journals->reverse(),
'exists' => $journals->count() > 0,
'end' => $this->end->formatLocalized((string)trans('config.month_and_day')),
'endBalance' => app('steam')->balance($account, $this->end),
'dayBefore' => $date->formatLocalized((string)trans('config.month_and_day')),
'dayBeforeBalance' => $dayBeforeBalance,
];
return $return;
}
}

View File

@ -65,10 +65,10 @@ class APIEventHandler
Log::error($e->getTraceAsString());
Session::flash('error', 'Possible email error: ' . $e->getMessage());
}
// @codeCoverageIgnoreEnd
Log::debug('If no error above this line, message was sent.');
}
// @codeCoverageIgnoreEnd
return true;

View File

@ -57,16 +57,17 @@ class AdminEventHandler
Log::debug('Trying to send message...');
Mail::to($email)->send(new AdminTestMail($email, $ipAddress));
// @codeCoverageIgnoreStart
// Laravel cannot pretend this process failed during testing.
} catch (Exception $e) {
Log::debug('Send message failed! :(');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
Session::flash('error', 'Possible email error: ' . $e->getMessage());
}
// @codeCoverageIgnoreEnd
Log::debug('If no error above this line, message was sent.');
}
// @codeCoverageIgnoreEnd
return true;
}
}

View File

@ -55,12 +55,14 @@ class AutomationHandler
Mail::to($user->email)->send(new ReportNewJournalsMail($user->email, '127.0.0.1', $event->journals));
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::debug('Send message failed! :(');
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
// @codeCoverageIgnoreEnd
Log::debug('Done!');
}
// @codeCoverageIgnoreEnd
return true;
}
}

View File

@ -25,8 +25,6 @@ namespace FireflyIII\Handlers\Events;
use FireflyIII\Events\StoredTransactionJournal;
use FireflyIII\Models\Rule;
use FireflyIII\Models\RuleGroup;
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
use FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use FireflyIII\TransactionRules\Processor;
@ -35,28 +33,6 @@ use FireflyIII\TransactionRules\Processor;
*/
class StoredJournalEventHandler
{
/** @var JournalRepositoryInterface The journal repository. */
public $journalRepository;
/** @var PiggyBankRepositoryInterface The Piggy bank repository */
public $repository;
/** @var RuleGroupRepositoryInterface The rule group repository */
public $ruleGroupRepository;
/**
* StoredJournalEventHandler constructor.
*
* @param PiggyBankRepositoryInterface $repository
* @param JournalRepositoryInterface $journalRepository
* @param RuleGroupRepositoryInterface $ruleGroupRepository
*/
public function __construct(
PiggyBankRepositoryInterface $repository, JournalRepositoryInterface $journalRepository, RuleGroupRepositoryInterface $ruleGroupRepository
) {
$this->repository = $repository;
$this->journalRepository = $journalRepository;
$this->ruleGroupRepository = $ruleGroupRepository;
}
/**
* This method grabs all the users rules and processes them.
*
@ -67,13 +43,15 @@ class StoredJournalEventHandler
*/
public function processRules(StoredTransactionJournal $storedJournalEvent): bool
{
// get all the user's rule groups, with the rules, order by 'order'.
$journal = $storedJournalEvent->journal;
$groups = $this->ruleGroupRepository->getActiveGroups($journal->user);
// create objects:
$ruleGroupRepos = app(RuleGroupRepositoryInterface::class);
$groups = $ruleGroupRepos->getActiveGroups($journal->user);
/** @var RuleGroup $group */
foreach ($groups as $group) {
$rules = $this->ruleGroupRepository->getActiveStoreRules($group);
$rules = $ruleGroupRepos->getActiveStoreRules($group);
/** @var Rule $rule */
foreach ($rules as $rule) {
$processor = Processor::make($rule);

View File

@ -141,12 +141,10 @@ class UserEventHandler
$uri = route('profile.confirm-email-change', [$token->data]);
try {
Mail::to($newEmail)->send(new ConfirmEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());
}
// @codeCoverageIgnoreEnd
return true;
}
@ -167,12 +165,10 @@ class UserEventHandler
$uri = route('profile.undo-email-change', [$token->data, hash('sha256', $oldEmail)]);
try {
Mail::to($oldEmail)->send(new UndoEmailChangeMail($newEmail, $oldEmail, $uri, $ipAddress));
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());
}
// @codeCoverageIgnoreEnd
return true;
}
@ -194,13 +190,10 @@ class UserEventHandler
// send email.
try {
Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress));
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());
}
// @codeCoverageIgnoreEnd
return true;
}
@ -224,11 +217,9 @@ class UserEventHandler
// send email.
try {
Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress));
// @codeCoverageIgnoreStart
} catch (Exception $e) {
Log::error($e->getMessage());
}
// @codeCoverageIgnoreEnd
}
return true;

View File

@ -56,7 +56,8 @@ class VersionCheckEventHandler
$sandstorm = 1 === (int)getenv('SANDSTORM');
if (true === $sandstorm) {
Log::debug('This is Sandstorm instance, done.');
return; // @codeCoverageIgnore
return;
}
/** @var UserRepositoryInterface $repository */
@ -65,6 +66,7 @@ class VersionCheckEventHandler
$user = $event->user;
if (!$repository->hasRole($user, 'owner')) {
Log::debug('User is not admin, done.');
return;
}

View File

@ -0,0 +1,230 @@
<?php
/**
* MonthReportGeneratorTest.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\Unit\Generator\Report\Audit;
use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Generator\Report\Audit\MonthReportGenerator;
use FireflyIII\Helpers\Collector\TransactionCollectorInterface;
use FireflyIII\Models\Account;
use FireflyIII\Models\TransactionCurrency;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Currency\CurrencyRepositoryInterface;
use Illuminate\Support\Collection;
use Log;
use Mockery;
use Steam;
use Tests\TestCase;
/**
*
* Class MonthReportGeneratorTest
*/
class MonthReportGeneratorTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Generator\Report\Audit\MonthReportGenerator
*/
public function testBasic(): void
{
/** @var Account $account */
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$date = new Carbon;
$start = Carbon::create()->startOfMonth();
$end = Carbon::create()->endOfMonth();
$generator = new MonthReportGenerator();
$generator->setStartDate($start);
$generator->setEndDate($end);
$collection = new Collection;
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
Steam::shouldReceive('balance')->times(2)->andReturn('100');
// mock calls:
$accountRepos->shouldReceive('setUser')->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->once();
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first())->once();
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn($collection);
try {
$result = $generator->getAuditReport($account, $date);
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
$this->assertFalse($result['exists']);
$this->assertEquals('100', $result['endBalance']);
}
/**
* @covers \FireflyIII\Generator\Report\Audit\MonthReportGenerator
*/
public function testBasicNoCurrency(): void
{
/** @var Account $account */
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$date = new Carbon;
$start = Carbon::create()->startOfMonth();
$end = Carbon::create()->endOfMonth();
$generator = new MonthReportGenerator();
$generator->setStartDate($start);
$generator->setEndDate($end);
$collection = new Collection;
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
Steam::shouldReceive('balance')->times(1)->andReturn('100');
// mock calls:
$accountRepos->shouldReceive('setUser')->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->once();
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(null)->once();
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn($collection);
try {
$generator->getAuditReport($account, $date);
} catch (FireflyException $e) {
$this->assertEquals('Unexpected NULL value in account currency preference.', $e->getMessage());
}
}
/**
* @covers \FireflyIII\Generator\Report\Audit\MonthReportGenerator
*/
public function testBasicWithForeign(): void
{
/** @var Account $account */
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$date = new Carbon;
$start = Carbon::create()->startOfMonth();
$end = Carbon::create()->endOfMonth();
$generator = new MonthReportGenerator();
$generator->setStartDate($start);
$generator->setEndDate($end);
$collection = new Collection;
$transaction = $this->user()->transactions()->first();
$transaction->transaction_amount = '30';
$transaction->foreign_currency_id = 1;
$transaction->transaction_foreign_amount = '30';
$collection->push($transaction);
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
Steam::shouldReceive('balance')->times(2)->andReturn('100');
// mock calls:
$accountRepos->shouldReceive('setUser')->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->once();
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first())->once();
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn($collection);
try {
$result = $generator->getAuditReport($account, $date);
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
$this->assertTrue($result['exists']);
$this->assertEquals('100', $result['endBalance']);
}
/**
* @covers \FireflyIII\Generator\Report\Audit\MonthReportGenerator
*/
public function testBasicWithTransactions(): void
{
/** @var Account $account */
$account = $this->user()->accounts()->where('account_type_id', 3)->first();
$date = new Carbon;
$start = Carbon::create()->startOfMonth();
$end = Carbon::create()->endOfMonth();
$generator = new MonthReportGenerator();
$generator->setStartDate($start);
$generator->setEndDate($end);
$collection = new Collection;
$transaction = $this->user()->transactions()->first();
$transaction->transaction_amount = '30';
$collection->push($transaction);
// mock stuff
$currencyRepos = $this->mock(CurrencyRepositoryInterface::class);
$accountRepos = $this->mock(AccountRepositoryInterface::class);
$collector = $this->mock(TransactionCollectorInterface::class);
Steam::shouldReceive('balance')->times(2)->andReturn('100');
// mock calls:
$accountRepos->shouldReceive('setUser')->once();
$accountRepos->shouldReceive('getMetaValue')->withArgs([Mockery::any(), 'currency_id'])->andReturn('1')->once();
$currencyRepos->shouldReceive('findNull')->withArgs([1])->andReturn(TransactionCurrency::first())->once();
$collector->shouldReceive('setAccounts')->andReturnSelf();
$collector->shouldReceive('setRange')->andReturnSelf();
$collector->shouldReceive('getTransactions')->andReturn($collection);
try {
$result = $generator->getAuditReport($account, $date);
} catch (FireflyException $e) {
$this->assertTrue(false, $e->getMessage());
}
$this->assertTrue($result['exists']);
$this->assertEquals('100', $result['endBalance']);
}
}

View File

@ -0,0 +1,76 @@
<?php
/**
* APIEventHandlerTest.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\Unit\Handlers\Events;
use FireflyIII\Handlers\Events\APIEventHandler;
use FireflyIII\Mail\AccessTokenCreatedMail;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Facades\Mail;
use Laravel\Passport\Events\AccessTokenCreated;
use Log;
use Tests\TestCase;
/**
*
* Class APIEventHandlerTest
*/
class APIEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Handlers\Events\APIEventHandler
*/
public function testAccessTokenCreated(): void
{
Mail::fake();
// mock objects.
$repository = $this->mock(UserRepositoryInterface::class);
// mock calls.
$repository->shouldReceive('findNull')->withArgs([1])->andReturn($this->user())->once();
$event = new AccessTokenCreated('1', '1', '1');
$handler = new APIEventHandler;
$handler->accessTokenCreated($event);
// assert a message was sent.
Mail::assertSent(
AccessTokenCreatedMail::class, function ($mail) {
return $mail->hasTo('thegrumpydictator@gmail.com') && '127.0.0.1' === $mail->ipAddress;
}
);
}
}

View File

@ -31,12 +31,21 @@ use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Facades\Mail;
use Mockery;
use Tests\TestCase;
use Log;
/**
* Class AdminEventHandlerTest
*/
class AdminEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Handlers\Events\AdminEventHandler
@ -77,6 +86,6 @@ class AdminEventHandlerTest extends TestCase
}
);
}
}
}

View File

@ -0,0 +1,80 @@
<?php
/**
* AutomationHandlerTest.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\Unit\Handlers\Events;
use FireflyIII\Events\RequestedReportOnJournals;
use FireflyIII\Handlers\Events\AutomationHandler;
use FireflyIII\Mail\ReportNewJournalsMail;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Mail;
use Log;
use stdClass;
use Tests\TestCase;
/**
*
* Class AutomationHandlerTest
*/
class AutomationHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Handlers\Events\AutomationHandler
* @covers \FireflyIII\Events\RequestedReportOnJournals
*/
public function testReportJournals(): void
{
Mail::fake();
// mock repositories
$repository = $this->mock(UserRepositoryInterface::class);
$journals = new Collection;
$journals->push(new stdClass);
// mock calls.
$repository->shouldReceive('findNull')->withArgs([1])->andReturn($this->user())->once();
$event = new RequestedReportOnJournals(1, $journals);
$handler = new AutomationHandler();
$handler->reportJournals($event);
// assert a message was sent.
Mail::assertSent(
ReportNewJournalsMail::class, function ($mail) {
return $mail->hasTo('thegrumpydictator@gmail.com') && '127.0.0.1' === $mail->ipAddress;
}
);
}
}

View File

@ -0,0 +1,74 @@
<?php
/**
* StoredJournalEventHandlerTest.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\Unit\Handlers\Events;
use FireflyIII\Events\StoredTransactionJournal;
use FireflyIII\Handlers\Events\StoredJournalEventHandler;
use FireflyIII\Repositories\RuleGroup\RuleGroupRepositoryInterface;
use Log;
use Tests\TestCase;
/**
*
* Class StoredJournalEventHandlerTest
*/
class StoredJournalEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Handlers\Events\StoredJournalEventHandler
* @covers \FireflyIII\Events\StoredTransactionJournal
*/
public function testProcessRules(): void
{
// $ruleGroupRepos = $this->mock(RuleGroupRepositoryInterface::class);
// $journal = $this->user()->transactionJournals()->inRandomOrder()->first();
// $piggy = $this->user()->piggyBanks()->inRandomOrder()->first();
// $event = new StoredTransactionJournal($journal, $piggy->id);
// $ruleGroups = $this->user()->ruleGroups()->take(1)->get();
// $rules = $this->user()->rules()->take(1)->get();
//
// // mock calls:
// $ruleGroupRepos->shouldReceive('setUser')->once();
// $ruleGroupRepos->shouldReceive('getActiveGroups')->andReturn($ruleGroups)->once();
// $ruleGroupRepos->shouldReceive('getActiveStoreRules')->andReturn($rules)->once();
//
//
//
// $handler = new StoredJournalEventHandler;
// $handler->processRules($event);
$this->assertTrue(true);
}
}

View File

@ -36,6 +36,7 @@ use Illuminate\Auth\Events\Login;
use Illuminate\Support\Facades\Mail;
use Mockery;
use Tests\TestCase;
use Log;
/**
* Class UserEventHandlerTest
@ -46,6 +47,15 @@ use Tests\TestCase;
*/
class UserEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
* @covers \FireflyIII\Handlers\Events\UserEventHandler
* @covers \FireflyIII\Events\RegisteredUser

View File

@ -34,12 +34,23 @@ use FireflyIII\Services\Github\Object\Release;
use FireflyIII\Services\Github\Request\UpdateRequest;
use Mockery;
use Tests\TestCase;
use Log;
/**
* Class VersionCheckEventHandlerTest
*/
class VersionCheckEventHandlerTest extends TestCase
{
/**
*
*/
public function setUp(): void
{
parent::setUp();
Log::debug(sprintf('Now in %s.', \get_class($this)));
}
/**
*
*/