From 28b456a9ec12e79d5bf8352d911a68ffcc9c3a78 Mon Sep 17 00:00:00 2001 From: Louis Charette Date: Sun, 12 Nov 2023 15:03:12 -0500 Subject: [PATCH] Fix test mock --- app/src/Authorize/AccessConditions.php | 4 +++- app/tests/Bakery/CreateAdminUserTest.php | 11 +---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/app/src/Authorize/AccessConditions.php b/app/src/Authorize/AccessConditions.php index 1746b44..b2ee98d 100644 --- a/app/src/Authorize/AccessConditions.php +++ b/app/src/Authorize/AccessConditions.php @@ -25,9 +25,11 @@ */ class AccessConditions implements AccessConditionsInterface { + protected UserInterface $user; + public function __construct( protected Config $config, - protected ?UserInterface $user = null, + ?UserInterface $user = null, ) { $this->user = $user ?? new User(); } diff --git a/app/tests/Bakery/CreateAdminUserTest.php b/app/tests/Bakery/CreateAdminUserTest.php index 4b8c9d7..1010315 100644 --- a/app/tests/Bakery/CreateAdminUserTest.php +++ b/app/tests/Bakery/CreateAdminUserTest.php @@ -144,16 +144,7 @@ public function testForFailedDbConnection(): void $connection = Mockery::mock(Connection::class) ->shouldReceive('getPdo')->once()->andThrow(new PDOException()) ->getMock(); - - $manager = Mockery::mock(DatabaseManager::class) - ->shouldReceive('getDefaultConnection')->once()->andReturn('test') - ->getMock(); - - $db = Mockery::mock(Capsule::class) - ->shouldReceive('getDatabaseManager')->once()->andReturn($manager) - ->shouldReceive('getConnection')->once()->andReturn($connection) - ->getMock(); - $this->ci->set(Capsule::class, $db); + $this->ci->set(Connection::class, $connection); /** @var CreateAdminUser */ $command = $this->ci->get(CreateAdminUser::class);