mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 01:57:13 +00:00
Make createLocalViewFactory compatible with Laravel 8 (#1026)
* Make createLocalViewFactory compatible with Laravel 8 Fixes https://github.com/barryvdh/laravel-ide-helper/issues/1024 * tests: move up mockFilesystem so it get be re-used in other tests Note: removed `$this->mockOutput = '';` as it was a no-op, that property doesn't exist (it was probably a typo, but I guess we don't need it anyway) * tests: show basic features for ide-helper:meta working
This commit is contained in:
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Mockery;
|
||||
use Orchestra\Testbench\TestCase as BaseTestCase;
|
||||
use Spatie\Snapshots\MatchesSnapshots;
|
||||
use Symfony\Component\Console\Tester\CommandTester;
|
||||
@@ -13,6 +15,8 @@ abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use MatchesSnapshots;
|
||||
|
||||
protected $mockFilesystemOutput;
|
||||
|
||||
/**
|
||||
* The `CommandTester` is directly returned, use methods like
|
||||
* `->getDisplay()` or `->getStatusCode()` on it.
|
||||
@@ -50,4 +54,30 @@ abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
$this->assertMatchesSnapshot($actualContent, new SnapshotTxtDriver());
|
||||
}
|
||||
|
||||
protected function mockFilesystem()
|
||||
{
|
||||
$mockFilesystem = Mockery::mock(Filesystem::class);
|
||||
|
||||
$mockFilesystem
|
||||
->shouldReceive('get')
|
||||
->andReturnUsing(function ($file) {
|
||||
return file_get_contents($file);
|
||||
});
|
||||
|
||||
$mockFilesystem
|
||||
->shouldReceive('put')
|
||||
->with(
|
||||
Mockery::any(),
|
||||
Mockery::any()
|
||||
)
|
||||
->andReturnUsing(function ($path, $contents) {
|
||||
$this->mockFilesystemOutput .= $contents;
|
||||
|
||||
return strlen($contents);
|
||||
});
|
||||
|
||||
$this->instance(Filesystem::class, $mockFilesystem);
|
||||
$this->instance('files', $mockFilesystem);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user