set('ide-helper', [ 'model_locations' => [ // This is calculated from the base_path() which points to // vendor/orchestra/testbench-core/laravel '/../../../../tests/Console/ModelsCommand/Relations/Models', ], ]); } 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->assertEmpty($tester->getDisplay()); $expectedContent = <<<'PHP' hasMany(Simple::class); } public function relationHasOne(): HasOne { return $this->hasOne(Simple::class); } public function relationBelongsTo(): BelongsTo { return $this->belongsTo(Simple::class); } public function relationBelongsToMany(): BelongsToMany { return $this->belongsToMany(Simple::class); } public function relationMorphTo(): MorphTo { return $this->morphTo(); } public function relationMorphOne(): MorphOne { return $this->morphOne(Simple::class, 'relationMorphTo'); } public function relationMorphMany(): MorphMany { return $this->morphMany(Simple::class, 'relationMorphTo'); } public function relationMorphedByMany(): MorphToMany { return $this->morphedByMany(Simple::class, 'foo'); } // Custom relations public function relationBelongsToInAnotherNamespace(): BelongsTo { return $this->belongsTo(AnotherModel::class); } } PHP; $this->assertSame($expectedContent, $actualContent); } }