From 32aa8cc722c8aaa94e968b5f32653497595858b4 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 17:43:49 +0100 Subject: [PATCH 01/27] Update .gitignore --- .gitignore | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 808f8c5..9a43686 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,14 @@ +.idea +.php_cs +.php_cs.cache +.phpunit.result.cache build composer.lock +coverage docs +phpunit.xml +phpstan.neon +testbench.yaml vendor -coverage \ No newline at end of file +node_modules +.php-cs-fixer.cache From 37147b063194fe72801f87a562322cd016e94a52 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 17:51:30 +0100 Subject: [PATCH 02/27] Added dependabot --- .github/dependabot.yml | 12 ++++++++ .github/workflows/dependabot-auto-merge.yml | 32 +++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/dependabot-auto-merge.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..30c8a49 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +# Please see the documentation for all configuration options: +# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" + labels: + - "dependencies" \ No newline at end of file diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml new file mode 100644 index 0000000..ca2197d --- /dev/null +++ b/.github/workflows/dependabot-auto-merge.yml @@ -0,0 +1,32 @@ +name: dependabot-auto-merge +on: pull_request_target + +permissions: + pull-requests: write + contents: write + +jobs: + dependabot: + runs-on: ubuntu-latest + if: ${{ github.actor == 'dependabot[bot]' }} + steps: + + - name: Dependabot metadata + id: metadata + uses: dependabot/fetch-metadata@v1.6.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + + - name: Auto-merge Dependabot PRs for semver-minor updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-minor'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + + - name: Auto-merge Dependabot PRs for semver-patch updates + if: ${{steps.metadata.outputs.update-type == 'version-update:semver-patch'}} + run: gh pr merge --auto --merge "$PR_URL" + env: + PR_URL: ${{github.event.pull_request.html_url}} + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} From c3588d40981fc737e8ee7abf957f099396cb2df1 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 17:51:41 +0100 Subject: [PATCH 03/27] Updated core files --- .editorconfig | 6 +++--- .gitattributes | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/.editorconfig b/.editorconfig index cd8eb86..a7c44dd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,6 +1,3 @@ -; This file is for unifying the coding style for different editors and IDEs. -; More information at http://editorconfig.org - root = true [*] @@ -13,3 +10,6 @@ trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 diff --git a/.gitattributes b/.gitattributes index bb6265e..9e9519b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -2,10 +2,18 @@ # https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html # Ignore all test and documentation with "export-ignore". +/.github export-ignore /.gitattributes export-ignore /.gitignore export-ignore -/.travis.yml export-ignore /phpunit.xml.dist export-ignore -/.scrutinizer.yml export-ignore +/art export-ignore +/docs export-ignore /tests export-ignore /.editorconfig export-ignore +/.php_cs.dist.php export-ignore +/psalm.xml export-ignore +/psalm.xml.dist export-ignore +/testbench.yaml export-ignore +/UPGRADING.md export-ignore +/phpstan.neon.dist export-ignore +/phpstan-baseline.neon export-ignore From f84306c49e310dc2df17d283875f7344af92b0c6 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 17:52:50 +0100 Subject: [PATCH 04/27] Create release.yml --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1487878 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,28 @@ +name: "Release" + +on: + release: + types: [released] + +jobs: + update: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: main + + - name: Update Changelog + uses: stefanzweifel/changelog-updater-action@v1 + with: + latest-version: ${{ github.event.release.name }} + release-notes: ${{ github.event.release.body }} + + - name: Commit updated CHANGELOG + uses: stefanzweifel/git-auto-commit-action@v4 + with: + branch: main + commit_message: Update CHANGELOG + file_pattern: CHANGELOG.md From fdbf12cfd07f0bfd1e0512e635880cfa15cfcd7b Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:08:29 +0100 Subject: [PATCH 05/27] Improved readme --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a914322..ab520da 100644 --- a/README.md +++ b/README.md @@ -37,13 +37,13 @@ You can simply wrap the function around your favicon icon names, like this: ``` -## Customization +### Customization You can completely customize which environments you want to have enabled for the favicon generation, as well as the font and colors that will be used. To modify the default values, publish the package configuration file using: -``` +```bash php artisan vendor:publish --provider='BeyondCode\LaravelFavicon\FaviconServiceProvider' --tag='config' ``` @@ -136,15 +136,15 @@ The `shouldGenerateFavicon` method can be used to determine if a custom favicon ## FAQ -- My ICO files are not working, why? +### My ICO files are not working, why? In order to modify ICO files, you need the Imagick PHP library installed and enabled in your `config/favicon.php` file. -- Is there a performance impact when I'm using this package? +### Is there a performance impact when I'm using this package? No - the default generator only modifies your favicon when the specified environment is enabled. This means, that production environments only see the static assets that you already have. -### Changelog +## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. @@ -152,7 +152,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recen Please see [CONTRIBUTING](CONTRIBUTING.md) for details. -### Security +## Security If you discover any security related issues, please email marcel@beyondco.de instead of using the issue tracker. From da2435b616714d5be36d1dde2ecd353e330def04 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:08:48 +0100 Subject: [PATCH 06/27] Added compatibility table --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index ab520da..04901ae 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,19 @@ composer require beyondcode/laravel-favicon The service provider for this package will be automatically registered for you. +### Compatibility + +| | 1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | +|-------|-----|-----|-----|-----|-----|-----| +| 5.6.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 5.7.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 5.8.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 6.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | +| 7.x | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | +| 8.x | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | +| 9.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | +| 10.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | + ## Usage To make use of this package, make use of the `favicon` helper function that this package provides. From 2e90e22d435d79ce77d8ad36b7384435287ae52d Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:22:38 +0100 Subject: [PATCH 07/27] Drop older laravel versions and bump packages --- README.md | 20 ++++++++++---------- composer.json | 12 ++++++------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 04901ae..98d2d46 100644 --- a/README.md +++ b/README.md @@ -27,16 +27,16 @@ The service provider for this package will be automatically registered for you. ### Compatibility -| | 1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | -|-------|-----|-----|-----|-----|-----|-----| -| 5.6.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 5.7.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 5.8.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 6.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | -| 7.x | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | -| 8.x | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | -| 9.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | -| 10.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | +| | 1.0 | 1.1 | 1.2 | 1.3 | 1.4 | 1.5 | 2.0 | +|-------|-----|-----|-----|-----|-----|-----|-----| +| 5.6.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| 5.7.x | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| 5.8.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| 6.x | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | +| 7.x | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ❌ | +| 8.x | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ❌ | +| 9.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | +| 10.x | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ## Usage diff --git a/composer.json b/composer.json index d1d6a87..5683e38 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,14 @@ } ], "require": { - "php": "^7.1|^8.0|^8.1|^8.2", - "illuminate/http": "5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*|^10.0", - "illuminate/support": "5.6.*|5.7.*|5.8.*|6.*|7.*|8.*|9.*|^10.0", - "intervention/image": "^2.4" + "php": "^8.0|^8.1|^8.2", + "illuminate/http": "^9.0|^10.0", + "illuminate/support": "^9.0|^10.0", + "intervention/image": "^2.6" }, "require-dev": { - "phpunit/phpunit": "^7.0|^8.0|^9.0", - "orchestra/testbench": "^3.7|^4.0|^5.0|^6.0|^7.0" + "phpunit/phpunit": "^9.0|^10.0", + "orchestra/testbench": "^7.0|^8.0" }, "autoload": { "psr-4": { From efaf20580b7a2181bd469d9e05a7ce68e222adb3 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:29:47 +0100 Subject: [PATCH 08/27] Added php cs fixer --- .github/workflows/php-cs-fixer.yml | 23 +++++++++++++++++ .php_cs.dist.php | 40 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .github/workflows/php-cs-fixer.yml create mode 100644 .php_cs.dist.php diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..fbec801 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,23 @@ +name: Check & fix styling + +on: [push] + +jobs: + php-cs-fixer: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + ref: ${{ github.head_ref }} + + - name: Run PHP CS Fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs.dist.php --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v5 + with: + commit_message: Fix styling diff --git a/.php_cs.dist.php b/.php_cs.dist.php new file mode 100644 index 0000000..8d8a790 --- /dev/null +++ b/.php_cs.dist.php @@ -0,0 +1,40 @@ +in([ + __DIR__ . '/src', + __DIR__ . '/tests', + ]) + ->name('*.php') + ->notName('*.blade.php') + ->ignoreDotFiles(true) + ->ignoreVCS(true); + +return (new PhpCsFixer\Config()) + ->setRules([ + '@PSR12' => true, + 'array_syntax' => ['syntax' => 'short'], + 'ordered_imports' => ['sort_algorithm' => 'alpha'], + 'no_unused_imports' => true, + 'not_operator_with_successor_space' => true, + 'trailing_comma_in_multiline' => true, + 'phpdoc_scalar' => true, + 'unary_operator_spaces' => true, + 'binary_operator_spaces' => true, + 'blank_line_before_statement' => [ + 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], + ], + 'phpdoc_single_line_var_spacing' => true, + 'phpdoc_var_without_name' => true, + 'class_attributes_separation' => [ + 'elements' => [ + 'method' => 'one', + ], + ], + 'method_argument_space' => [ + 'on_multiline' => 'ensure_fully_multiline', + 'keep_multiple_spaces_after_comma' => true, + ], + 'single_trait_insert_per_statement' => true, + ]) + ->setFinder($finder); From dea3723308578b32af90a5492d69ab12f3fe3e47 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:30:25 +0100 Subject: [PATCH 09/27] Update composer.json --- composer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5683e38..10c460f 100644 --- a/composer.json +++ b/composer.json @@ -52,5 +52,7 @@ "BeyondCode\\LaravelFavicon\\FaviconServiceProvider" ] } - } + }, + "minimum-stability": "dev", + "prefer-stable": true } From b046fff1cbb8209e452715e86594d224f3ff5541 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:46:51 +0100 Subject: [PATCH 10/27] Added typehinting --- src/Favicon.php | 9 ++++----- src/FaviconServiceProvider.php | 6 +++--- src/Generators/EnvironmentGenerator.php | 11 ++++------- src/Http/Controllers/FaviconController.php | 3 ++- src/helpers.php | 2 +- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Favicon.php b/src/Favicon.php index babd0f7..498f64c 100644 --- a/src/Favicon.php +++ b/src/Favicon.php @@ -6,25 +6,24 @@ class Favicon { - /** @var array */ - protected $config; + protected array $config; public function __construct(array $config) { $this->config = $config; } - public function getFaviconText(string $environment) + public function getFaviconText(string $environment): mixed { return Arr::get($this->config, 'enabled_environments.'.$environment.'.text'); } - public function getFaviconColor(string $environment) + public function getFaviconColor(string $environment): mixed { return Arr::get($this->config, 'enabled_environments.'.$environment.'.color'); } - public function getFaviconBackgroundColor(string $environment) + public function getFaviconBackgroundColor(string $environment): mixed { return Arr::get($this->config, 'enabled_environments.'.$environment.'.background_color'); } diff --git a/src/FaviconServiceProvider.php b/src/FaviconServiceProvider.php index 134b4f3..5effa77 100644 --- a/src/FaviconServiceProvider.php +++ b/src/FaviconServiceProvider.php @@ -12,7 +12,7 @@ class FaviconServiceProvider extends ServiceProvider /** * Bootstrap the application services. */ - public function boot() + public function boot(): void { if ($this->app->runningInConsole()) { $this->publishes([ @@ -26,7 +26,7 @@ public function boot() /** * Register the application services. */ - public function register() + public function register(): void { $this->mergeConfigFrom(__DIR__.'/../config/favicon.php', 'favicon'); @@ -39,7 +39,7 @@ public function register() }); } - protected function registerRoutes() + protected function registerRoutes(): void { Route::get(config('favicon.url_prefix').'/{icon}', FaviconController::class) ->where('icon', '.*'); diff --git a/src/Generators/EnvironmentGenerator.php b/src/Generators/EnvironmentGenerator.php index 29bec33..f9139e2 100644 --- a/src/Generators/EnvironmentGenerator.php +++ b/src/Generators/EnvironmentGenerator.php @@ -12,14 +12,11 @@ class EnvironmentGenerator implements FaviconGenerator { - /** @var Favicon */ - protected $favicon; + protected Favicon $favicon; - /** @var ImageManager */ - protected $manager; + protected ImageManager $manager; - /** @var string */ - protected $environment; + protected string $environment; public function __construct(Favicon $favicon) { @@ -82,7 +79,7 @@ protected function calculateDynamicFontSize(AbstractFont $font, Image $icon, $pa } } - protected function createEnvironmentTextImage(AbstractFont $font) + protected function createEnvironmentTextImage(AbstractFont $font): Image { $size = $font->getBoxSize(); diff --git a/src/Http/Controllers/FaviconController.php b/src/Http/Controllers/FaviconController.php index b105cb6..073e310 100644 --- a/src/Http/Controllers/FaviconController.php +++ b/src/Http/Controllers/FaviconController.php @@ -4,10 +4,11 @@ use BeyondCode\LaravelFavicon\Generators\FaviconGenerator; use Illuminate\Http\Request; +use Illuminate\Http\Response; class FaviconController { - public function __invoke(Request $request, FaviconGenerator $generator) + public function __invoke(Request $request, FaviconGenerator $generator): Response { return $generator->generate($request->route('icon')); } diff --git a/src/helpers.php b/src/helpers.php index b93f886..b68e92f 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -3,7 +3,7 @@ use BeyondCode\LaravelFavicon\Generators\FaviconGenerator; if (! function_exists('favicon')) { - function favicon($image) + function favicon(string $image): string { if (app(FaviconGenerator::class)->shouldGenerateFavicon(app()->environment())) { return rtrim(config('app.url'), '/').'/'.config('favicon.url_prefix')."/$image"; From de7c9a4246e5fd175ed8d9e08ac31b04b14e1311 Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 29 Dec 2023 17:50:53 +0000 Subject: [PATCH 11/27] Add Pest dependencies --- composer.json | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 10c460f..6c23624 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,8 @@ "intervention/image": "^2.6" }, "require-dev": { - "phpunit/phpunit": "^9.0|^10.0", - "orchestra/testbench": "^7.0|^8.0" + "orchestra/testbench": "^7.0|^8.0", + "pestphp/pest": "^2.2" }, "autoload": { "psr-4": { @@ -41,7 +41,6 @@ "scripts": { "test": "vendor/bin/phpunit", "test-coverage": "vendor/bin/phpunit --coverage-html coverage" - }, "config": { "sort-packages": true From fe6ecc2c21e6a19e4775f261054d90dcad659ca1 Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 29 Dec 2023 17:50:53 +0000 Subject: [PATCH 12/27] Add base Pest file --- tests/Pest.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 tests/Pest.php diff --git a/tests/Pest.php b/tests/Pest.php new file mode 100644 index 0000000..fc70c72 --- /dev/null +++ b/tests/Pest.php @@ -0,0 +1,40 @@ + Date: Fri, 29 Dec 2023 17:50:53 +0000 Subject: [PATCH 13/27] Convert test cases --- tests/EnvironmentGeneratorTest.php | 38 +++++++--------- tests/FaviconTest.php | 70 ++++++++++++------------------ 2 files changed, 44 insertions(+), 64 deletions(-) diff --git a/tests/EnvironmentGeneratorTest.php b/tests/EnvironmentGeneratorTest.php index 9c5ea95..4a9343e 100644 --- a/tests/EnvironmentGeneratorTest.php +++ b/tests/EnvironmentGeneratorTest.php @@ -1,33 +1,27 @@ app['config']['app.env'] = 'production'; +test('the helper returns the icon file for invalid environments', function () { + app()['config']['app.env'] = 'production'; - $icon = favicon('some_icon'); + $icon = favicon('some_icon'); - $this->assertSame('some_icon', $icon); - } + $this->assertSame('some_icon', $icon); +}); - /** @test */ - public function the_helper_returns_the_icon_route_for_valid_environments() - { - $this->app['config']['app.env'] = 'local'; +test('the helper returns the icon route for valid environments', function () { + app()['config']['app.env'] = 'local'; - $icon = favicon('some_icon'); + $icon = favicon('some_icon'); - $this->assertSame('/laravel-favicon/some_icon', $icon); - } + $this->assertSame('/laravel-favicon/some_icon', $icon); +}); + +// Helpers +function getPackageProviders($app) +{ + return [FaviconServiceProvider::class]; } diff --git a/tests/FaviconTest.php b/tests/FaviconTest.php index 92f0651..d868687 100644 --- a/tests/FaviconTest.php +++ b/tests/FaviconTest.php @@ -1,53 +1,39 @@ favicon = new Favicon([ - 'enabled_environments' => [ - 'local' => [ - 'text' => 'DEV', - 'color' => '#000000', - 'background_color' => '#ffffff', - ], +uses(Orchestra\Testbench\TestCase::class); +beforeEach(function () { + $this->favicon = new Favicon([ + 'enabled_environments' => [ + 'local' => [ + 'text' => 'DEV', + 'color' => '#000000', + 'background_color' => '#ffffff', ], - ]); - } + ], + ]); +}); + - protected function getPackageProviders($app) - { - return [FaviconServiceProvider::class]; - } +it('returns environment specific color', function () { + $this->assertNull($this->favicon->getFaviconColor('unknown')); + $this->assertSame('#000000', $this->favicon->getFaviconColor('local')); +}); - /** @test */ - public function it_returns_environment_specific_color() - { - $this->assertNull($this->favicon->getFaviconColor('unknown')); - $this->assertSame('#000000', $this->favicon->getFaviconColor('local')); - } +it('returns environment specific text', function () { + $this->assertNull($this->favicon->getFaviconText('unknown')); + $this->assertSame('DEV', $this->favicon->getFaviconText('local')); +}); - /** @test */ - public function it_returns_environment_specific_text() - { - $this->assertNull($this->favicon->getFaviconText('unknown')); - $this->assertSame('DEV', $this->favicon->getFaviconText('local')); - } +it('returns environment specific background color', function () { + $this->assertNull($this->favicon->getFaviconBackgroundColor('unknown')); + $this->assertSame('#ffffff', $this->favicon->getFaviconBackgroundColor('local')); +}); - /** @test */ - public function it_returns_environment_specific_background_color() - { - $this->assertNull($this->favicon->getFaviconBackgroundColor('unknown')); - $this->assertSame('#ffffff', $this->favicon->getFaviconBackgroundColor('local')); - } +// Helpers +function getPackageProviders($app) +{ + return [FaviconServiceProvider::class]; } From d10454eb8b9c60f23b80f4533fc3778e0b852ceb Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 29 Dec 2023 17:50:53 +0000 Subject: [PATCH 14/27] Adopt expectation API --- tests/EnvironmentGeneratorTest.php | 4 ++-- tests/FaviconTest.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/EnvironmentGeneratorTest.php b/tests/EnvironmentGeneratorTest.php index 4a9343e..e0ad263 100644 --- a/tests/EnvironmentGeneratorTest.php +++ b/tests/EnvironmentGeneratorTest.php @@ -9,7 +9,7 @@ $icon = favicon('some_icon'); - $this->assertSame('some_icon', $icon); + expect($icon)->toBe('some_icon'); }); test('the helper returns the icon route for valid environments', function () { @@ -17,7 +17,7 @@ $icon = favicon('some_icon'); - $this->assertSame('/laravel-favicon/some_icon', $icon); + expect($icon)->toBe('/laravel-favicon/some_icon'); }); // Helpers diff --git a/tests/FaviconTest.php b/tests/FaviconTest.php index d868687..94b8960 100644 --- a/tests/FaviconTest.php +++ b/tests/FaviconTest.php @@ -18,18 +18,18 @@ it('returns environment specific color', function () { - $this->assertNull($this->favicon->getFaviconColor('unknown')); - $this->assertSame('#000000', $this->favicon->getFaviconColor('local')); + expect($this->favicon->getFaviconColor('unknown'))->toBeNull(); + expect($this->favicon->getFaviconColor('local'))->toBe('#000000'); }); it('returns environment specific text', function () { - $this->assertNull($this->favicon->getFaviconText('unknown')); - $this->assertSame('DEV', $this->favicon->getFaviconText('local')); + expect($this->favicon->getFaviconText('unknown'))->toBeNull(); + expect($this->favicon->getFaviconText('local'))->toBe('DEV'); }); it('returns environment specific background color', function () { - $this->assertNull($this->favicon->getFaviconBackgroundColor('unknown')); - $this->assertSame('#ffffff', $this->favicon->getFaviconBackgroundColor('local')); + expect($this->favicon->getFaviconBackgroundColor('unknown'))->toBeNull(); + expect($this->favicon->getFaviconBackgroundColor('local'))->toBe('#ffffff'); }); // Helpers From 596eb305fe412aa9ec3d916cc5d60169c34eb27f Mon Sep 17 00:00:00 2001 From: Shift Date: Fri, 29 Dec 2023 17:50:54 +0000 Subject: [PATCH 15/27] Optimize uses --- tests/Pest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Pest.php b/tests/Pest.php index fc70c72..f9ac1d7 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -1,5 +1,6 @@ Date: Fri, 29 Dec 2023 17:50:54 +0000 Subject: [PATCH 16/27] Use Pest test runner --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6c23624..4854d8c 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,7 @@ } }, "scripts": { - "test": "vendor/bin/phpunit", + "test": "vendor/bin/pest", "test-coverage": "vendor/bin/phpunit --coverage-html coverage" }, "config": { From 1ea772322ed08e752b9e0ca2780cc8d558e326c3 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:52:33 +0100 Subject: [PATCH 17/27] Remove PHP 8.0 support --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4854d8c..73d7b24 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^8.0|^8.1|^8.2", + "php": "^8.1|^8.2", "illuminate/http": "^9.0|^10.0", "illuminate/support": "^9.0|^10.0", "intervention/image": "^2.6" From 354456bbf6cb12fa14e29a87e3d4767ff79ec989 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:55:01 +0100 Subject: [PATCH 18/27] Delete .travis.yml --- .travis.yml | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 96dd1fe..0000000 --- a/.travis.yml +++ /dev/null @@ -1,40 +0,0 @@ -language: php - -php: - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - -env: - global: - - ILLUMINATE_VERSION="" - - TESTBENCH_VERSION="" - - matrix: - - COMPOSER_FLAGS="--prefer-lowest" - - COMPOSER_FLAGS="" - - ILLUMINATE_VERSION="5.7.*" TESTBENCH_VERSION="3.7.*" - - ILLUMINATE_VERSION="5.8.*" TESTBENCH_VERSION="3.8.*" - - ILLUMINATE_VERSION="6.*" TESTBENCH_VERSION="4.*" - -matrix: - exclude: - - php: 7.1 - env: ILLUMINATE_VERSION="6.*" TESTBENCH_VERSION="4.*" - -before_script: - - travis_retry composer self-update - - if [ "$ILLUMINATE_VERSION" != "" ] && [ "$TESTBENCH_VERSION" != "" ]; then - composer require "illuminate/http:${ILLUMINATE_VERSION}" --no-update; - composer require "illuminate/support:${ILLUMINATE_VERSION}" --no-update; - composer require "orchestra/testbench:${TESTBENCH_VERSION}" --no-update; - fi - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source - -script: - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover From 6836904c6ec0429c712eeaa7d179ad1f707180d6 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:55:17 +0100 Subject: [PATCH 19/27] Updated coverage command --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 73d7b24..b1bfc53 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ }, "scripts": { "test": "vendor/bin/pest", - "test-coverage": "vendor/bin/phpunit --coverage-html coverage" + "test-coverage": "vendor/bin/pest --coverage" }, "config": { "sort-packages": true From b5ace8fbe59482ce55ab3734aab5e18eaf7c1067 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:59:47 +0100 Subject: [PATCH 20/27] Converted expect into chain --- tests/FaviconTest.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/FaviconTest.php b/tests/FaviconTest.php index 94b8960..df52f52 100644 --- a/tests/FaviconTest.php +++ b/tests/FaviconTest.php @@ -18,18 +18,18 @@ it('returns environment specific color', function () { - expect($this->favicon->getFaviconColor('unknown'))->toBeNull(); - expect($this->favicon->getFaviconColor('local'))->toBe('#000000'); + expect($this->favicon->getFaviconColor('unknown'))->toBeNull() + ->and($this->favicon->getFaviconColor('local'))->toBe('#000000'); }); it('returns environment specific text', function () { - expect($this->favicon->getFaviconText('unknown'))->toBeNull(); - expect($this->favicon->getFaviconText('local'))->toBe('DEV'); + expect($this->favicon->getFaviconText('unknown'))->toBeNull() + ->and($this->favicon->getFaviconText('local'))->toBe('DEV'); }); it('returns environment specific background color', function () { - expect($this->favicon->getFaviconBackgroundColor('unknown'))->toBeNull(); - expect($this->favicon->getFaviconBackgroundColor('local'))->toBe('#ffffff'); + expect($this->favicon->getFaviconBackgroundColor('unknown'))->toBeNull() + ->and($this->favicon->getFaviconBackgroundColor('local'))->toBe('#ffffff'); }); // Helpers From c79527d4b395efb76c968ebd4bff315a3ea2c969 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 18:59:59 +0100 Subject: [PATCH 21/27] Update composer.json --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b1bfc53..24ae81c 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,10 @@ "test-coverage": "vendor/bin/pest --coverage" }, "config": { - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "pestphp/pest-plugin": true, + } }, "extra": { "laravel": { From 5c76405df71daf8f5d99d9074c55526ae2ed2234 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 19:04:39 +0100 Subject: [PATCH 22/27] Create phpstan.yml --- .github/workflows/phpstan.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..e2aabdc --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,26 @@ +name: PHPStan + +on: + push: + paths: + - '**.php' + - 'phpstan.neon.dist' + +jobs: + phpstan: + name: phpstan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '8.2' + coverage: none + + - name: Install composer dependencies + uses: ramsey/composer-install@v2 + + - name: Run PHPStan + run: ./vendor/bin/phpstan --error-format=github From 2289ee7eaecd9ab7750f53b7d055f6dedf4b08ca Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 19:05:06 +0100 Subject: [PATCH 23/27] Create run-tests.yml --- .github/workflows/run-tests.yml | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/run-tests.yml diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..dd09f2d --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,45 @@ +name: Tests + +on: [pull_request] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.1, 8.2] + laravel: [9.*, 10.*] + stability: [prefer-stable] + include: + - laravel: 10.* + testbench: ^8.0 + - laravel: 9.* + testbench: ^7.0 + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: Execute tests + run: vendor/bin/pest From 840dcc83006799d3be63805c0a31664f9f16d242 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 19:07:34 +0100 Subject: [PATCH 24/27] Delete .scrutinizer.yml --- .scrutinizer.yml | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index df16b68..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,19 +0,0 @@ -filter: - excluded_paths: [tests/*] - -checks: - php: - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true - From 370875f94487ee9a1d7a4b8b1086fad4efea561b Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 19:07:36 +0100 Subject: [PATCH 25/27] Delete .styleci.yml --- .styleci.yml | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 .styleci.yml diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index f4d3cbc..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,4 +0,0 @@ -preset: laravel - -disabled: - - single_class_element_per_statement From bd119980cbe54da2119495805b47997105ef2732 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Fri, 29 Dec 2023 19:26:58 +0100 Subject: [PATCH 26/27] Update composer.json --- composer.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 24ae81c..1b23a6c 100644 --- a/composer.json +++ b/composer.json @@ -22,8 +22,15 @@ "intervention/image": "^2.6" }, "require-dev": { - "orchestra/testbench": "^7.0|^8.0", - "pestphp/pest": "^2.2" + "nunomaduro/collision": "^7.0", + "nunomaduro/larastan": "^2.0.1", + "orchestra/testbench": "^8.0", + "pestphp/pest": "^2.2", + "pestphp/pest-plugin-laravel": "^2.0", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan-deprecation-rules": "^1.0", + "phpstan/phpstan-phpunit": "^1.0", + "phpunit/phpunit": "^10.0" }, "autoload": { "psr-4": { @@ -46,6 +53,7 @@ "sort-packages": true, "allow-plugins": { "pestphp/pest-plugin": true, + "phpstan/extension-installer": true } }, "extra": { From 512cb95b82bf2ab3916681fc38edbddee89e9777 Mon Sep 17 00:00:00 2001 From: "Daniel S. Billing" Date: Tue, 21 May 2024 13:39:46 +0200 Subject: [PATCH 27/27] Update run-tests.yml --- .github/workflows/run-tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index dd09f2d..e46e7fd 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,14 +9,14 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest, windows-latest] - php: [8.1, 8.2] - laravel: [9.*, 10.*] + php: [8.2, 8.3] + laravel: [10.*, 11.*] stability: [prefer-stable] include: - laravel: 10.* testbench: ^8.0 - - laravel: 9.* - testbench: ^7.0 + - laravel: 11.* + testbench: ^9.0 name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}