Skip to content

Commit

Permalink
Fix test mock
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Nov 12, 2023
1 parent 6f477a6 commit 28b456a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
4 changes: 3 additions & 1 deletion app/src/Authorize/AccessConditions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
11 changes: 1 addition & 10 deletions app/tests/Bakery/CreateAdminUserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 28b456a

Please sign in to comment.