markTestSkipped('This test requires Laravel 7.0 or higher'); } } protected function getEnvironmentSetUp($app) { parent::getEnvironmentSetUp($app); $app['config']->set('ide-helper', [ 'model_locations' => [ // This is calculated from the base_path() which points to // vendor/orchestra/testbench-core/laravel '/../../../../tests/Console/ModelsCommand/LaravelCustomCasts/Models', ], ]); } public function test_it_parses_casted_properties_correctly(): void { $actualContent = null; $mockFilesystem = Mockery::mock(Filesystem::class); $mockFilesystem ->shouldReceive('get') ->andReturn(file_get_contents(__DIR__.'/Models/CustomCast.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' CustomCasterWithReturnType::class, 'casted_property_with_return_docblock' => CustomCasterWithDocblockReturn::class, 'casted_property_with_return_docblock_fqn' => CustomCasterWithDocblockReturnFqn::class, 'casted_property_with_return_primitive' => CustomCasterWithPrimitiveReturn::class, 'casted_property_with_return_primitive_docblock' => CustomCasterWithPrimitiveDocblockReturn::class, 'casted_property_with_return_nullable_primitive' => CustomCasterWithNullablePrimitiveReturn::class, 'casted_property_without_return' => CustomCasterWithoutReturnType::class, ]; } PHP; $this->assertSame($expectedContent, $actualContent); } }