diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 0000000..70be7a6 --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,27 @@ +name: Check and fix code styling with php-cs-fixer + +on: + pull_request: + push: + branches: + - master + +jobs: + style: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Run php-cs-fixer + uses: docker://oskarstark/php-cs-fixer-ga + with: + args: --config=.php_cs.dist --allow-risky=yes + + - name: Commit changes + uses: stefanzweifel/git-auto-commit-action@v4.10.0 + with: + commit_message: Automatically applied php-cs-fixer changes diff --git a/.github/workflows/php-unit.yml b/.github/workflows/php-unit.yml new file mode 100644 index 0000000..f6b0b11 --- /dev/null +++ b/.github/workflows/php-unit.yml @@ -0,0 +1,39 @@ +name: Check if all phpunit tests are passing or not + +on: + pull_request: + push: + branches: + - master + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ ubuntu-latest ] + php: [ 7.4, 8.0 ] + laravel: [ 8.* ] + dependency-version: [ prefer-stable ] + include: + - laravel: 8.* + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - 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 + coverage: none + + - name: Install Dependencies + run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/src/Commands/PrettyRoutesCommand.php b/src/Commands/PrettyRoutesCommand.php index cae4060..bc7bc48 100644 --- a/src/Commands/PrettyRoutesCommand.php +++ b/src/Commands/PrettyRoutesCommand.php @@ -187,6 +187,7 @@ protected function displayRoutes(array $routes) 'PATCH' => 'yellow', 'DELETE' => 'red', ][$m] ?? 'white'; + return sprintf("%s", $color, $m); }, explode('|', $method))); diff --git a/tests/SnapshotTest.php b/tests/SnapshotTest.php index 4a5b452..e88665c 100644 --- a/tests/SnapshotTest.php +++ b/tests/SnapshotTest.php @@ -3,7 +3,6 @@ namespace Wulfheart\PrettyRoutes\Tests; - use Illuminate\Support\Facades\Artisan; use Spatie\Snapshots\MatchesSnapshots; diff --git a/tests/TestCase.php b/tests/TestCase.php index 850d4ba..64f9a42 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -24,11 +24,11 @@ public function defineRoutes($router): void return view('welcome'); }); - $router->get('admin', fn() => true); + $router->get('admin', fn () => true); $router->resource('test', Controller::class); - $router->get('/{one?}/{two}/some/{three?}', fn() => true); - $router->post('some/thing/{one?}/{two}/some/{three?}', fn() => true); + $router->get('/{one?}/{two}/some/{three?}', fn () => true); + $router->post('some/thing/{one?}/{two}/some/{three?}', fn () => true); } }