Skip to content

Commit

Permalink
Laravel 11 support final touches
Browse files Browse the repository at this point in the history
  • Loading branch information
slavarazum committed Mar 20, 2024
1 parent 166d07b commit 054efe9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 26 deletions.
24 changes: 9 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,31 @@ name: tests

on:
push:
branches: [main]
branches: [ main ]
pull_request:
branches: [main]
branches: [ main ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.2, 8.1, 8.0]
laravel: [9, 10, 11]
stability: [prefer-lowest, prefer-stable]
os: [ ubuntu-latest ]
php: [ 8.3, 8.2, 8.1 ]
laravel: [ 10, 11 ]
stability: [ prefer-lowest, prefer-stable ]
exclude:
- php: 8.0
laravel: 11
- php: 8.1
laravel: 11
- php: 8.0
laravel: 10.*
- php: 8.3
laravel: 9

services:
redis:
image: redis
ports:
- 6379:6379

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

steps:
- name: Checkout code
Expand All @@ -52,11 +46,11 @@ jobs:
- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" --no-interaction --no-update
composer require "illuminate/contracts=^${{ matrix.laravel }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
- name: List Installed Dependencies
run: composer show -D

- name: Execute tests
run: vendor/bin/pest
run: composer test:unit
19 changes: 11 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
],
"require": {
"php": "^8.1",
"illuminate/broadcasting": "^10.0|^11.0",
"illuminate/console": "^10.0|^11.0",
"illuminate/contracts": "^10.0|^11.0",
"illuminate/http": "^10.0|^11.0",
"illuminate/queue": "^10.0|^11.0",
"illuminate/routing": "^10.0|^11.0",
"illuminate/broadcasting": "^10.0|^11.0.6",
"illuminate/console": "^10.0|^11.0.6",
"illuminate/contracts": "^10.0|^11.0.6",
"illuminate/http": "^10.0|^11.0.6",
"illuminate/queue": "^10.0|^11.0.6",
"illuminate/routing": "^10.0|^11.0.6",
"laravel/prompts": "^0.1.16",
"spatie/laravel-package-tools": "^1.14.1"
},
Expand All @@ -54,7 +54,10 @@
"autoload": {
"psr-4": {
"Qruto\\Wave\\": "src"
}
},
"files": [
"src/helpers.php"
]
},
"autoload-dev": {
"psr-4": {
Expand Down Expand Up @@ -91,7 +94,7 @@
"extra": {
"laravel": {
"providers": [
"Qruto\\Wave\\WaveServiceProvider"
"Qruto\\Wave\\WaveServiceProvider"
]
}
},
Expand Down
8 changes: 6 additions & 2 deletions src/WaveServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ public function configurePackage(Package $package): void
->hasConfigFile()
->hasRoute('routes')
->hasCommand(SsePingCommand::class)
->hasCommand(ConfigPublishCommand::class)
->hasCommand(BroadcastingInstallCommand::class)
->hasCommand(ServeCommand::class);

if (laravel11OrHigher()) {
$package
->hasCommand(ConfigPublishCommand::class)
->hasCommand(BroadcastingInstallCommand::class);
}
}

public function registeringPackage()
Expand Down
12 changes: 12 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Qruto\Wave;

use Illuminate\Foundation\Application;

if (! function_exists('laravel11OrHigher')) {
function laravel11OrHigher(): bool
{
return explode('.', Application::VERSION)[0] >= 11;
}
}
4 changes: 3 additions & 1 deletion tests/Feature/BroadcastingInstallCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Process;

use function Qruto\Wave\laravel11OrHigher;

it('completely installs all required assets for broadcasting in default scenario', function () {
File::shouldReceive('copy')
->once()
Expand Down Expand Up @@ -40,4 +42,4 @@

$this->assertFileExists($this->app->configPath('broadcasting.php'));
unlink($this->app->configPath('broadcasting.php'));
});
})->skip(! laravel11OrHigher(), '`install:broadcasting` command is only available for Laravel 11 or higher.');

0 comments on commit 054efe9

Please sign in to comment.