/
githubmirror
/
framework
Обзор
Документация
Войти
/
githubmirror
/
framework
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
13.x
tests/Integration/Console/GeneratorCommandTest.php
68 строк
2 KB
Ahmed Alaa
Add missing void return type to test methods (#56860)
02 сен 2025, 01:45
Не верифицирован
02 сен 2025, 01:45
c0bae54
Код
Авторство
О чём код?
<?php namespace Illuminate\Tests\Integration\Console; use Orchestra\Testbench\Concerns\InteractsWithPublishedFiles; use Orchestra\Testbench\TestCase; use PHPUnit\Framework\Attributes\DataProvider; class GeneratorCommandTest extends TestCase { use InteractsWithPublishedFiles; protected $files = [ 'app/Console/Commands/FooCommand.php', 'resources/views/foo/php.blade.php', 'tests/Feature/fixtures.php/SomeTest.php', ]; public function testItChopsPhpExtension(): void { $this->artisan('make:command', ['name' => 'FooCommand.php']) ->assertExitCode(0); $this->assertFilenameExists('app/Console/Commands/FooCommand.php'); $this->assertFileContains([ 'class FooCommand extends Command', ], 'app/Console/Commands/FooCommand.php'); } public function testItChopsPhpExtensionFromMakeViewCommands(): void { $this->artisan('make:view', ['name' => 'foo.php']) ->assertExitCode(0); $this->assertFilenameExists('resources/views/foo/php.blade.php'); } public function testItOnlyChopsPhpExtensionFromFilename(): void { $this->artisan('make:test', ['name' => 'fixtures.php/SomeTest']) ->assertExitCode(0); $this->assertFilenameExists('tests/Feature/fixtures.php/SomeTest.php'); $this->assertFileContains([ 'class SomeTest extends TestCase', ], 'tests/Feature/fixtures.php/SomeTest.php'); } #[DataProvider('reservedNamesDataProvider')] public function testItCannotGenerateClassUsingReservedName($given): void { $this->artisan('make:command', ['name' => $given]) ->expectsOutputToContain('The name "'.$given.'" is reserved by PHP.') ->assertExitCode(0); } public static function reservedNamesDataProvider() { yield ['__halt_compiler']; yield ['__HALT_COMPILER']; yield ['array']; yield ['ARRAY']; yield ['__class__']; yield ['__CLASS__']; } }