Skip to content

Commit

Permalink
Added laravel 11 and PHP 8.3 support; Fixed github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
korridor committed Feb 29, 2024
1 parent 4d0a8e0 commit 6233e16
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
with:
command: install
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
php_version: 8.1
php_version: 8.3

- name: Run PHP-CS-Fixer
run: vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff --dry-run
Expand All @@ -30,7 +30,7 @@ jobs:
with:
command: install
only_args: -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist --ignore-platform-reqs
php_version: 8.1
php_version: 8.3

- name: Run PHP CodeSniffer
run: vendor/bin/phpcs --extensions=php
23 changes: 23 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,35 @@ jobs:
- php: 8.2
laravel: 10.*
composer-flag: '--prefer-stable'
- php: 8.3
laravel: 10.*
composer-flag: '--prefer-stable'
- php: 8.1
laravel: 10.*
composer-flag: '--prefer-lowest'
- php: 8.2
laravel: 10.*
composer-flag: '--prefer-lowest'
- php: 8.3
laravel: 10.*
composer-flag: '--prefer-lowest'
# Laravel 11.*
- php: 8.2
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-stable'
- php: 8.3
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-stable'
- php: 8.2
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-lowest'
- php: 8.2
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-lowest'

runs-on: ubuntu-latest

Expand Down
27 changes: 26 additions & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,35 @@ jobs:
- php: 8.2
laravel: 10.*
composer-flag: '--prefer-stable'
- php: 8.3
laravel: 10.*
composer-flag: '--prefer-stable'
- php: 8.1
laravel: 10.*
composer-flag: '--prefer-lowest'
- php: 8.2
laravel: 10.*
composer-flag: '--prefer-lowest'
- php: 8.3
laravel: 10.*
composer-flag: '--prefer-lowest'
# Laravel 11.*
- php: 8.2
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-stable'
- php: 8.3
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-stable'
- php: 8.2
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-lowest'
- php: 8.2
laravel: 11.*
testbench: 9.*
composer-flag: '--prefer-lowest'

runs-on: ubuntu-latest

Expand All @@ -43,4 +66,6 @@ jobs:
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text --coverage-clover=coverage.xml

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
"email": "[email protected]"
}
],
"minimum-stability": "stable",
"require": {
"php": ">=8.1",
"illuminate/database": "^10"
"illuminate/database": "^10|^11"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"nunomaduro/larastan": "^2.0",
"orchestra/testbench": "^8.9",
"orchestra/testbench": "^8|^9",
"phpunit/phpunit": "^10",
"squizlabs/php_codesniffer": "^3.5"
},
Expand All @@ -43,5 +42,7 @@
},
"config": {
"sort-packages": true
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.1-cli
FROM php:8.3-cli

ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

Expand Down
2 changes: 1 addition & 1 deletion license.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The MIT License (MIT)
=====================

Copyright © `2021` `korridor`
Copyright © `2024` `korridor`

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ composer require korridor/laravel-has-many-merged "^0"

This package is tested for the following Laravel versions:

- 10.* (PHP 8.1, 8.2)
- 10.* (PHP 8.1, 8.2, 8.3)
- 11.* (PHP 8.2, 8.3)

## Usage examples

Expand Down
7 changes: 5 additions & 2 deletions tests/HasManyMergedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ public function testHasManyMergedWithTwoUsersWereBothAreSenderOrReceiverOfTheSam

// Act
$this->db::connection()->enableQueryLog();
$user1 = User::find(11);
$user2 = User::find(12);
/** @var User|null $user1 */
$user1 = User::query()->find(11);
/** @var User|null $user2 */
$user2 = User::query()->find(12);
$messagesOfUser1 = $user1->messages;
$messagesOfUser2 = $user2->messages;
$queries = $this->db::connection()->getQueryLog();
Expand Down Expand Up @@ -177,6 +179,7 @@ public function testHasManyMergedWithTwoUsersWereBothAreSenderOrReceiverOfTheSam
// Assert
$this->assertEquals(1, count($users));
$this->assertEquals(2, $users->first()->other_unique_id);
$this->assertCount(2, $queries);
}

public function testHasManyMergedWithTwoUsersWereBothAreSenderOrReceiverOfTheSameFourMessagesWithLazyEagerLoading(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/Models/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Message extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'id',
Expand Down
4 changes: 3 additions & 1 deletion tests/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Korridor\LaravelHasManyMerged\Tests\Models;

use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Korridor\LaravelHasManyMerged\HasManyMerged;
Expand All @@ -15,6 +16,7 @@
* @property string $name
* @property int $messages_sum_content_integer
* @property int $messages_count
* @property-read Collection<int, Message> $messages
*/
class User extends Model
{
Expand All @@ -30,7 +32,7 @@ class User extends Model
/**
* The attributes that are mass assignable.
*
* @var string[]
* @var array<int, string>
*/
protected $fillable = [
'id',
Expand Down

0 comments on commit 6233e16

Please sign in to comment.