Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Fix test coverage.
James Cole29a81eb05e21
diff --git a/app/Handlers/Events/UserEventHandler.php b/app/Handlers/Events/UserEventHandler.phpindex 41d7b83c80..ff76eeedbc 100644--- a/app/Handlers/Events/UserEventHandler.php+++ b/app/Handlers/Events/UserEventHandler.php@@ -141,9 +141,11 @@ 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());}+ // @codeCoverageIgnoreEndreturn true;}@@ -165,9 +167,11 @@ 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());}+ // @codeCoverageIgnoreEndreturn true;}@@ -190,9 +194,11 @@ class UserEventHandler// send email.try {Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress));+ // @codeCoverageIgnoreStart} catch (Exception $e) {Log::error($e->getMessage());}+ // @codeCoverageIgnoreEndreturn true;}@@ -217,9 +223,11 @@ class UserEventHandler// send email.try {Mail::to($email)->send(new RegisteredUserMail($uri, $ipAddress));+ // @codeCoverageIgnoreStart} catch (Exception $e) {Log::error($e->getMessage());}+ // @codeCoverageIgnoreEnd}return true;diff --git a/tests/Feature/Controllers/Transaction/SplitControllerTest.php b/tests/Feature/Controllers/Transaction/SplitControllerTest.phpindex b0f7d7bb5e..e10dd064b9 100644--- a/tests/Feature/Controllers/Transaction/SplitControllerTest.php+++ b/tests/Feature/Controllers/Transaction/SplitControllerTest.php@@ -271,6 +271,7 @@ class SplitControllerTest extends TestCase$billRepos = $this->mock(BillRepositoryInterface::class);$billRepos->shouldReceive('scan');+ $ruleRepos->shouldReceive('setUser')->once();$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);@@ -368,6 +369,7 @@ class SplitControllerTest extends TestCase$billRepos = $this->mock(BillRepositoryInterface::class);$billRepos->shouldReceive('scan');+ $ruleRepos->shouldReceive('setUser')->once();$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);@@ -424,6 +426,7 @@ class SplitControllerTest extends TestCase$billRepos = $this->mock(BillRepositoryInterface::class);$billRepos->shouldReceive('scan');+ $ruleRepos->shouldReceive('setUser')->once();$ruleRepos->shouldReceive('getActiveGroups')->andReturn(new Collection);diff --git a/tests/Unit/Handlers/Events/UserEventHandlerTest.php b/tests/Unit/Handlers/Events/UserEventHandlerTest.phpindex 72c7c8d7be..7b79511aae 100644--- a/tests/Unit/Handlers/Events/UserEventHandlerTest.php+++ b/tests/Unit/Handlers/Events/UserEventHandlerTest.php@@ -34,9 +34,10 @@ use FireflyIII\Models\Role;use FireflyIII\Repositories\User\UserRepositoryInterface;use Illuminate\Auth\Events\Login;use Illuminate\Support\Facades\Mail;+use Log;use Mockery;+use Preferences;use Tests\TestCase;-use Log;/*** Class UserEventHandlerTest@@ -151,6 +152,26 @@ class UserEventHandlerTest extends TestCase$this->assertTrue(true);}+ /**+ * @covers \FireflyIII\Handlers\Events\UserEventHandler+ */+ public function testDemoUserBackToEnglish(): void+ {+ $repository = $this->mock(UserRepositoryInterface::class);+ $user = $this->emptyUser();+ $event = new Login($user, true);+ $listener = new UserEventHandler();++ // mock stuff+ $repository->shouldReceive('hasRole')->withArgs([Mockery::any(), 'demo'])->once()->andReturn(true);++ Preferences::shouldReceive('setForUser')->withArgs([Mockery::any(), 'language', 'en_US'])->once();+ Preferences::shouldReceive('mark')->once();++ $listener->demoUserBackToEnglish($event);+ $this->assertTrue(true);+ }+/*** @covers \FireflyIII\Handlers\Events\UserEventHandler* @covers \FireflyIII\Events\UserChangedEmaildiff --git a/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php b/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.phpindex 9c54051d92..c1c9ed4ff8 100644--- a/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php+++ b/tests/Unit/Handlers/Events/VersionCheckEventHandlerTest.php@@ -32,9 +32,9 @@ use FireflyIII\Models\Configuration;use FireflyIII\Repositories\User\UserRepositoryInterface;use FireflyIII\Services\Github\Object\Release;use FireflyIII\Services\Github\Request\UpdateRequest;+use Log;use Mockery;use Tests\TestCase;-use Log;/*** Class VersionCheckEventHandlerTest@@ -52,7 +52,8 @@ class VersionCheckEventHandlerTest extends TestCase/**- *+ * @covers \FireflyIII\Events\RequestedVersionCheckStatus+ * @covers \FireflyIII\Handlers\Events\VersionCheckEventHandler*/public function testCheckForUpdatesError(): void{@@ -114,7 +115,8 @@ class VersionCheckEventHandlerTest extends TestCase}/**- *+ * @covers \FireflyIII\Events\RequestedVersionCheckStatus+ * @covers \FireflyIII\Handlers\Events\VersionCheckEventHandler*/public function testCheckForUpdatesNoAdmin(): void{@@ -156,7 +158,22 @@ class VersionCheckEventHandlerTest extends TestCase}/**- *+ * @covers \FireflyIII\Events\RequestedVersionCheckStatus+ * @covers \FireflyIII\Handlers\Events\VersionCheckEventHandler+ */+ public function testCheckForUpdatesSandstorm(): void+ {+ putenv('SANDSTORM=1');++ $event = new RequestedVersionCheckStatus($this->user());+ $handler = new VersionCheckEventHandler;+ $handler->checkForUpdates($event);+ putenv('SANDSTORM=0');+ }++ /**+ * @covers \FireflyIII\Events\RequestedVersionCheckStatus+ * @covers \FireflyIII\Handlers\Events\VersionCheckEventHandler*/public function testCheckForUpdatesTooRecent(): void{