Skip to content

Commit

Permalink
Mock igniter class
Browse files Browse the repository at this point in the history
Signed-off-by: Sam Poyigi <[email protected]>
  • Loading branch information
sampoyigi committed Dec 28, 2024
1 parent 2a31ba5 commit 6aefb7d
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions tests/Classes/ApiManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,7 @@
});

it('does not register routes when database does not exist', function() {
$igniter = new class extends Igniter
{
public static function clear()
{
static::$hasDatabase = null;
}
};
$igniter::clear();
Igniter::shouldReceive('hasDatabase')->andReturnFalse();
$schema = $this->createMock(Builder::class);
$connection = $this->createMock(Connection::class);
$connection->expects($this->once())->method('getSchemaBuilder')->willReturn($schema);
Expand All @@ -88,22 +81,7 @@ public static function clear()
});

it('does not register routes when table does not exist', function() {
$igniter = new class extends Igniter
{
public static function clear()
{
static::$hasDatabase = null;
}
};
$igniter::clear();
$schema = $this->createMock(Builder::class);
$connection = $this->createMock(Connection::class);
$connection->expects($this->once())->method('getSchemaBuilder')->willReturn($schema);
$schema->expects($this->exactly(2))->method('hasTable')->willReturnMap([
['settings', true],
['extension_settings', true],
]);
app()->instance('db.connection', $connection);
Igniter::shouldReceive('hasDatabase')->andReturnTrue();
Schema::shouldReceive('hasTable')->with('igniter_api_resources')->andReturn(false);
Route::shouldReceive('middleware')->never();

Expand Down

0 comments on commit 6aefb7d

Please sign in to comment.