mirror of
https://github.com/barryvdh/laravel-ide-helper.git
synced 2026-08-18 18:13:11 +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:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Barryvdh\LaravelIdeHelper\Tests\Console\MetaCommand;
|
||||
|
||||
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
|
||||
use Barryvdh\LaravelIdeHelper\Tests\TestCase;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Mockery\MockInterface;
|
||||
|
||||
class MetaCommandTest extends TestCase
|
||||
{
|
||||
public function testCommand(): void
|
||||
{
|
||||
$this->mockFilesystem();
|
||||
|
||||
/** @var Filesystem|MockInterface $mockFileSystem */
|
||||
$mockFileSystem = $this->app->make(Filesystem::class);
|
||||
$this->instance('files', $mockFileSystem);
|
||||
|
||||
$mockFileSystem
|
||||
->shouldReceive('getRequire')
|
||||
->andReturnUsing(function ($__path, $__data) {
|
||||
return (static function () use ($__path, $__data) {
|
||||
extract($__data, EXTR_SKIP);
|
||||
|
||||
return require $__path;
|
||||
})();
|
||||
});
|
||||
|
||||
$this->artisan('ide-helper:meta');
|
||||
|
||||
// We're not testing the whole file, just some basic structure elements
|
||||
self::assertStringContainsString("namespace PHPSTORM_META {\n", $this->mockFilesystemOutput);
|
||||
self::assertStringContainsString("PhpStorm Meta file, to provide autocomplete information for PhpStorm\n", $this->mockFilesystemOutput);
|
||||
self::assertStringContainsString('override(', $this->mockFilesystemOutput);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get package providers.
|
||||
*
|
||||
* @param \Illuminate\Foundation\Application $app
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [IdeHelperServiceProvider::class];
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,9 @@ namespace Barryvdh\LaravelIdeHelper\Tests\Console\ModelsCommand;
|
||||
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
|
||||
use Barryvdh\LaravelIdeHelper\Tests\SnapshotPhpDriver;
|
||||
use Barryvdh\LaravelIdeHelper\Tests\TestCase;
|
||||
use Illuminate\Filesystem\Filesystem;
|
||||
use Mockery;
|
||||
|
||||
abstract class AbstractModelsCommand extends TestCase
|
||||
{
|
||||
protected $mockFilesystemOutput;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -57,33 +53,6 @@ abstract class AbstractModelsCommand extends TestCase
|
||||
$config->set('ide-helper.type_overrides', []);
|
||||
}
|
||||
|
||||
protected function mockFilesystem()
|
||||
{
|
||||
$this->mockOutput = '';
|
||||
|
||||
$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);
|
||||
}
|
||||
|
||||
protected function assertMatchesMockedSnapshot()
|
||||
{
|
||||
$this->assertMatchesSnapshot($this->mockFilesystemOutput, new SnapshotPhpDriver());
|
||||
|
||||
Reference in New Issue
Block a user