set('ide-helper', [ 'model_locations' => [ // This is calculated from the base_path() which points to // vendor/orchestra/testbench-core/laravel '/../../../../tests/Console/ModelsCommand/ModelHooks/Models', ], 'model_hooks' => [ CustomProperty::class, CustomMethod::class, UnsetMethod::class, ], ]); } public function test(): void { $actualContent = null; $mockFilesystem = Mockery::mock(Filesystem::class); $mockFilesystem ->shouldReceive('get') ->andReturn(file_get_contents(__DIR__ . '/Models/Simple.php')) ->once(); $mockFilesystem ->shouldReceive('put') ->with( Mockery::any(), Mockery::capture($actualContent) ) ->andReturn(1) // Simulate we wrote _something_ to the file ->once(); $this->instance(Filesystem::class, $mockFilesystem); $command = $this->app->make(ModelsCommand::class); $tester = $this->runCommand($command, [ '--write' => true, ]); $this->assertSame(0, $tester->getStatusCode()); $this->assertStringContainsString('Written new phpDocBlock to', $tester->getDisplay()); $expectedContent = <<<'PHP' |Simple custom($custom) * @method static \Illuminate\Database\Eloquent\Builder|Simple newQuery() * @method static \Illuminate\Database\Eloquent\Builder|Simple query() * @method static \Illuminate\Database\Eloquent\Builder|Simple whereId($value) * @mixin \Eloquent */ class Simple extends Model { } PHP; $this->assertSame($expectedContent, $actualContent); } }