diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 75798a5..b52e60e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -13,7 +13,7 @@ jobs: strategy: matrix: - php: [ 8.0, 8.1, 8.2 ] + php: [ 8.1, 8.2 ] os: [ ubuntu-latest, windows-latest ] name: PHP${{ matrix.php }} - ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index 6b2e64a..4c76487 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,5 @@ # Cache and coverage. /\.coverage/ /\.phpunit\.result\.cache +/\.phpunit\.cache/ \.scannerwork/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b9c89c..9569123 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change Log +## 6.0.0 + +**Added** + +- Add `phpHeaderDoc` option to generate a documentation block in generated file header. + +**Changed** + +- **BREAKING** Drop support for PHP 8.0. + ## 5.0.0 **Added** diff --git a/composer.json b/composer.json index 55253e0..e3e3abf 100644 --- a/composer.json +++ b/composer.json @@ -26,21 +26,21 @@ "bin/phpunitgen" ], "require": { - "php": "~8.0.12 || ~8.1.0 || ~8.2.0", + "php": "~8.1.0 || ~8.2.0", "ext-json": "*", "league/container": "^3.3", "league/flysystem": "^3.0", - "phpunitgen/core": "^3.0", - "symfony/console": "^4.4 || ^5.0 || ^6.0", - "symfony/stopwatch": "^4.3 || ^5.0 || ^6.0", - "symfony/yaml": "^4.3 || ^5.0 || ^6.0", + "phpunitgen/core": "^4.0", + "symfony/console": "^4.4 || ^5.0 || ^6.0 || ^7.0", + "symfony/stopwatch": "^4.3 || ^5.0 || ^6.0 || ^7.0", + "symfony/yaml": "^4.3 || ^5.0 || ^6.0 || ^7.0", "tightenco/collect": "^8.0 || ^9.0" }, "require-dev": { "laravel/framework": "^9.0", "mockery/mockery": "^1.3", "orchestra/testbench": "^7.0", - "phpunit/phpunit": "^9.1" + "phpunit/phpunit": "^9.0" }, "autoload": { "psr-4": { diff --git a/config/phpunitgen.json b/config/phpunitgen.json index 50f2a8d..1f10410 100644 --- a/config/phpunitgen.json +++ b/config/phpunitgen.json @@ -27,6 +27,7 @@ "version" ], "phpDoc": [], + "phpHeaderDoc": "", "options": { "context": "laravel" } diff --git a/config/phpunitgen.php b/config/phpunitgen.php index 2668579..8d9f4f9 100644 --- a/config/phpunitgen.php +++ b/config/phpunitgen.php @@ -171,6 +171,17 @@ */ 'phpDoc' => [], + /* + |-------------------------------------------------------------------------- + | PHP header documentation lines. + | + | The documentation header to append to generated files. + | Should be a full documentation content (with lines breaks, opening tags, + | etc.) or an empty string to disable printing a documentation header. + |-------------------------------------------------------------------------- + */ + 'phpHeaderDoc' => '', + /* |-------------------------------------------------------------------------- | Options. diff --git a/config/phpunitgen.yml b/config/phpunitgen.yml index 54a6c5b..c0b8e2c 100644 --- a/config/phpunitgen.yml +++ b/config/phpunitgen.yml @@ -22,5 +22,6 @@ mergedPhpDoc: - license - version phpDoc: [] +phpHeaderDoc: options: context: laravel diff --git a/src/Config/ConsoleConfig.php b/src/Config/ConsoleConfig.php index f9ea886..70c3eea 100644 --- a/src/Config/ConsoleConfig.php +++ b/src/Config/ConsoleConfig.php @@ -32,6 +32,7 @@ class ConsoleConfig extends Config implements ConsoleConfigContract 'excludedMethods' => self::TYPE_ARRAY, 'mergedPhpDoc' => self::TYPE_ARRAY, 'phpDoc' => self::TYPE_ARRAY, + 'phpHeaderDoc' => self::TYPE_STRING, 'options' => self::TYPE_ARRAY, 'overwriteFiles' => self::TYPE_BOOL, 'excludedFiles' => self::TYPE_ARRAY, diff --git a/tests/Feature/CommandFinishedListenerTest.php b/tests/Feature/CommandFinishedListenerTest.php index d045264..72b81d6 100644 --- a/tests/Feature/CommandFinishedListenerTest.php +++ b/tests/Feature/CommandFinishedListenerTest.php @@ -469,7 +469,7 @@ public function testItRunsWithClass(string $expectedPath, string $makeName): voi $this->assertSame(1, $this->commandFinishedListener->handle($event)); } - public function runWithClassDataProvider(): array + public static function runWithClassDataProvider(): array { return [ ['Broadcasting', 'channel'], diff --git a/tests/Feature/CommandsTest.php b/tests/Feature/CommandsTest.php index efa03aa..8347094 100644 --- a/tests/Feature/CommandsTest.php +++ b/tests/Feature/CommandsTest.php @@ -100,7 +100,7 @@ public function testItRunsWithExistingConfig(string $commandClass): void $this->assertStringContainsString('Memory usage:', $output); } - public function commandsDataProvider(): array + public static function commandsDataProvider(): array { return [ [RunCommand::class], diff --git a/tests/Feature/LaravelIntegrationTest.php b/tests/Feature/LaravelIntegrationTest.php index d5c6e07..fc02666 100644 --- a/tests/Feature/LaravelIntegrationTest.php +++ b/tests/Feature/LaravelIntegrationTest.php @@ -57,6 +57,14 @@ protected function deleteAffectedDirectories(): void } } + /** + * {@inheritdoc} + */ + protected function defineEnvironment($app) + { + $app['env'] = 'local'; + } + /** * {@inheritdoc} */ diff --git a/tests/Unit/Config/ConsoleConfigTest.php b/tests/Unit/Config/ConsoleConfigTest.php index 6f041d0..e4b427f 100644 --- a/tests/Unit/Config/ConsoleConfigTest.php +++ b/tests/Unit/Config/ConsoleConfigTest.php @@ -44,6 +44,7 @@ public function testWhenDefaultConfiguration(): void 'version', ], 'phpDoc' => [], + 'phpHeaderDoc' => '', 'options' => [ 'context' => 'laravel', ], @@ -73,6 +74,7 @@ public function testWhenCompleteConfiguration(): void 'excludedMethods' => [], 'mergedPhpDoc' => [], 'phpDoc' => ['@author John Doe'], + 'phpHeaderDoc' => '/* Some header */', 'options' => ['custom' => 'option'], ], ConsoleConfig::make([ 'overwriteFiles' => true, @@ -95,6 +97,7 @@ public function testWhenCompleteConfiguration(): void 'excludedMethods' => [], 'mergedPhpDoc' => [], 'phpDoc' => ['@author John Doe'], + 'phpHeaderDoc' => '/* Some header */', 'options' => ['custom' => 'option'], ])->toArray()); } @@ -122,6 +125,7 @@ public function testGetters(): void 'excludedMethods' => [], 'mergedPhpDoc' => [], 'phpDoc' => ['@author John Doe'], + 'phpHeaderDoc' => '/* Some header */', 'options' => ['custom' => 'option'], ]); @@ -145,6 +149,7 @@ public function testGetters(): void $this->assertSame([], $config->excludedMethods()); $this->assertSame([], $config->mergedPhpDoc()); $this->assertSame(['@author John Doe'], $config->phpDoc()); + $this->assertSame('/* Some header */', $config->phpHeaderDoc()); $this->assertSame(['custom' => 'option'], $config->options()); $this->assertSame('option', $config->getOption('custom')); $this->assertSame(null, $config->getOption('unknown')); diff --git a/tests/Unit/Files/TargetResolverTest.php b/tests/Unit/Files/TargetResolverTest.php index b055141..5d72057 100644 --- a/tests/Unit/Files/TargetResolverTest.php +++ b/tests/Unit/Files/TargetResolverTest.php @@ -65,7 +65,7 @@ public function testItResolvesTargetPath( $this->assertSame($expected, $this->targetResolver->resolve($classFactory, $sourcePath, $targetPath)); } - public function targetResolverDataProvider(): array + public static function targetResolverDataProvider(): array { return [ ['tests/Models/PostTest.php', '', 'john/app/Models/Post.php', 'tests'],