Skip to content

Commit

Permalink
Mock the filesystem
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jun 24, 2024
1 parent dd698ab commit d9bb52a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/framework/tests/Unit/DataCollectionUnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ public static function mockFiles(array $files): void
assert(str_contains($file, '.'), 'File must have an extension.');
}

$filesystem = Mockery::mock(Filesystem::class);
$filesystem->shouldReceive('get')
->andReturnUsing(function (string $file) use ($files) {
$file = unslash(str_replace(Hyde::path(), '', $file));
$files = static::arrayGlob($files, $file, 'md');

return array_values($files)[0] ?? '';
});

app()->instance(Filesystem::class, $filesystem);

static::$mockFiles = $files;
}

Expand Down

0 comments on commit d9bb52a

Please sign in to comment.