Skip to content

Commit

Permalink
Merge pull request #3 from rumspeed/scotrumery/issue2
Browse files Browse the repository at this point in the history
Update for Laravel v11 Support
  • Loading branch information
scotrumery authored Jul 21, 2024
2 parents bade759 + 1f4e363 commit 15c20c4
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 54 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ permissions:
jobs:
php-code-styling:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/laravel-pint-action@2.3.0
uses: aglipanci/laravel-pint-action@2.4

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
8 changes: 5 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ on:
paths:
- '**.php'
- 'phpstan.neon.dist'
- '.github/workflows/phpstan.yml'

jobs:
phpstan:
name: phpstan
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.2'
coverage: none

- name: Install composer dependencies
uses: ramsey/composer-install@v2
uses: ramsey/composer-install@v3

- name: Run PHPStan
run: ./vendor/bin/phpstan --error-format=github
21 changes: 14 additions & 7 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,28 @@ name: run-tests

on:
push:
branches: [main]
pull_request:
branches: [main]
paths:
- '**.php'
- '.github/workflows/run-tests.yml'
- 'phpunit.xml.dist'
- 'composer.json'
- 'composer.lock'

jobs:
test:
runs-on: ${{ matrix.os }}
timeout-minutes: 5
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest]
php: [8.2, 8.1]
laravel: [10.*]
php: [8.3, 8.2]
laravel: [11.*, 10.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 11.*
testbench: 9.*
carbon: ^2.63
- laravel: 10.*
testbench: 8.*
carbon: ^2.63
Expand All @@ -25,14 +32,14 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
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: pcov
coverage: none

- name: Setup problem matchers
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ permissions:
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 5

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main

Expand All @@ -24,7 +25,7 @@ jobs:
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
}
],
"require": {
"php": "^8.1",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0"
"php": "^8.2",
"spatie/laravel-package-tools": "^1.16",
"illuminate/contracts": "^10.0||^11.0"
},
"require-dev": {
"laravel/pint": "^1.0",
"nunomaduro/collision": "^7.9",
"nunomaduro/larastan": "^2.0.1",
"orchestra/testbench": "^8.0",
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.0||^7.10",
"larastan/larastan": "^2.9",
"orchestra/testbench": "^9.0.0||^8.22.0",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^10.2"
"phpstan/phpstan-phpunit": "^1.3",
"phpunit/phpunit": "^11.0.1"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 9 additions & 9 deletions src/Models/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
/**
* Class Note
*
* @property int $id
* @property string $content
* @property int $noteable_id
* @property string $noteable_type
* @property int $author_id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Illuminate\Database\Eloquent\Model $author
* @property \Illuminate\Database\Eloquent\Model $noteable
* @property int $id
* @property string $content
* @property int $noteable_id
* @property string $noteable_type
* @property int $author_id
* @property \Carbon\Carbon $created_at
* @property \Carbon\Carbon $updated_at
* @property \Illuminate\Database\Eloquent\Model $author
* @property \Illuminate\Database\Eloquent\Model $noteable
*/
class Note extends Model
{
Expand Down
2 changes: 1 addition & 1 deletion src/Traits/HasManyNotes.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function findNote($id)
* @param string $content
* @return array
*/
protected function prepareNoteAttributes($content, Model $author = null)
protected function prepareNoteAttributes($content, ?Model $author = null)
{
return [
'author_id' => is_null($author) ? $this->getCurrentAuthorId() : $author->getKey(),
Expand Down
4 changes: 2 additions & 2 deletions src/Traits/HasOneNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function createNote($content, $author = null, $reload = true)
* @param bool $reload
* @return bool
*/
public function updateNote($content, Model $author = null, $reload = true)
public function updateNote($content, ?Model $author = null, $reload = true)
{
$updated = $this->note->update(
$this->prepareNoteAttributes($content, $author)
Expand All @@ -88,7 +88,7 @@ public function updateNote($content, Model $author = null, $reload = true)
* @param string $content
* @return array
*/
protected function prepareNoteAttributes($content, Model $author = null)
protected function prepareNoteAttributes($content, ?Model $author = null)
{
return [
'author_id' => is_null($author) ? $this->getCurrentAuthorId() : $author->getKey(),
Expand Down
3 changes: 1 addition & 2 deletions tests/LaravelNotesServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public function tearDown(): void
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_be_instantiated(): void
public function test_it_can_be_instantiated(): void
{
$expectations = [
\Illuminate\Support\ServiceProvider::class,
Expand Down
20 changes: 5 additions & 15 deletions tests/NoteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ class NoteTest extends TestCase
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_create_a_note(): void
public function test_it_can_create_a_note(): void
{
$post = $this->createPost();

Expand All @@ -33,8 +32,7 @@ public function it_can_create_a_note(): void
static::assertNull($post->note->author);
}

/** @test */
public function it_should_create_single_note_for_has_one_note_trait(): void
public function test_it_should_create_single_note_for_has_one_note_trait(): void
{
$post = $this->createPost();

Expand All @@ -59,8 +57,7 @@ public function it_should_create_single_note_for_has_one_note_trait(): void
static::assertCount(1, Note::all());
}

/** @test */
public function it_can_create_with_author(): void
public function test_it_can_create_with_author(): void
{
$user = $this->createUser();
$post = $this->createPost();
Expand All @@ -77,8 +74,7 @@ public function it_can_create_with_author(): void
static::assertEquals($user->id, $post->note->author->id);
}

/** @test */
public function it_can_update_note(): void
public function test_it_can_update_note(): void
{
$post = $this->createPost();

Expand All @@ -103,8 +99,7 @@ public function it_can_update_note(): void
static::assertCount(1, Note::all());
}

/** @test */
public function it_can_reverse_relation(): void
public function test_it_can_reverse_relation(): void
{
$post = $this->createPost();

Expand All @@ -122,7 +117,6 @@ public function it_can_reverse_relation(): void
| -----------------------------------------------------------------
*/

/** @test */
public function it_can_add_note(): void
{
$user = $this->createUser();
Expand All @@ -135,7 +129,6 @@ public function it_can_add_note(): void
static::assertNull($note->author);
}

/** @test */
public function it_can_add_note_without_get_current_author_id_method(): void
{
$user = $this->createUserWithAuthorId();
Expand All @@ -148,7 +141,6 @@ public function it_can_add_note_without_get_current_author_id_method(): void
static::assertSame($user->id, $note->author->id);
}

/** @test */
public function it_can_find_note_by_its_id(): void
{
$user = $this->createUser();
Expand All @@ -159,7 +151,6 @@ public function it_can_find_note_by_its_id(): void
static::assertSame($note->id, $created->id);
}

/** @test */
public function it_can_retrieve_authored_notes(): void
{
$user = $this->createUser();
Expand All @@ -174,7 +165,6 @@ public function it_can_retrieve_authored_notes(): void
static::assertCount(2, $user->authoredNotes()->get());
}

/** @test */
public function it_must_retrieve_authored_notes_foreach_owner(): void
{
$userOne = $this->createUserWithAuthorId();
Expand Down
2 changes: 1 addition & 1 deletion tests/Stubs/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
*/
class User extends Model
{
use AuthoredNotes;
/* -----------------------------------------------------------------
| Traits
| -----------------------------------------------------------------
*/

use HasFactory;
use HasManyNotes;
use AuthoredNotes;

/* -----------------------------------------------------------------
| Properties
Expand Down

0 comments on commit 15c20c4

Please sign in to comment.