Fixing issue where incorrect autoloader unregistered (#1210)

Co-authored-by: Terence Marks <[email protected]>
This commit is contained in:
Terence Marks
2021-04-09 07:54:00 +02:00
committed by GitHub
co-authored by Terence Marks
parent c1ddd30532
commit ca94ffd99a
3 changed files with 48 additions and 8 deletions
@@ -8,6 +8,7 @@ use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Barryvdh\LaravelIdeHelper\Tests\TestCase;
use Illuminate\Filesystem\Filesystem;
use Mockery\MockInterface;
use stdClass;
class MetaCommandTest extends TestCase
{
@@ -37,6 +38,38 @@ class MetaCommandTest extends TestCase
self::assertStringContainsString('override(', $this->mockFilesystemOutput);
}
public function testUnregisterAutoloader(): void
{
$current = spl_autoload_functions();
$appended = function () { };
$this->app->bind('registers-autoloader', function () use ($appended)
{
spl_autoload_register($appended);
return new stdClass();
});
$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');
self::assertSame(array_merge($current, [$appended]), spl_autoload_functions());
}
/**
* Get package providers.
*