diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index bb77b26..8f4e42e 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -22,7 +22,7 @@ jobs: uses: actions/cache@v1 with: path: ~/.composer/cache/files - key: dependencies-laravel-6.x-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + key: dependencies-laravel-7.x-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/README.md b/README.md index a6e57ed..9c942eb 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ This Laravel Notes will allow you to add a notes system into your Laravel projec * Easy setup & configuration. * Well documented & IDE Friendly. * Well tested with maximum code quality. - * Laravel `5.1` to `6.x` are supported. + * Laravel `5.1` to `7.x` are supported. * Made with :heart: & :coffee:. ## Table of contents @@ -42,7 +42,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail. - [ARCANEDEV][link-author] - [All Contributors][link-contributors] -[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.1%20to%206.x-orange.svg?style=flat-square +[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.1%20to%207.x-orange.svg?style=flat-square [badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-notes.svg?style=flat-square [badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/LaravelNotes/run-tests?style=flat-square [badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelNotes.svg?style=flat-square diff --git a/_docs/0-Home.md b/_docs/0-Home.md index 32aaaef..6fbc651 100644 --- a/_docs/0-Home.md +++ b/_docs/0-Home.md @@ -8,7 +8,7 @@ This Laravel Notes will allow you to add a notes system into your Laravel projec * Easy setup & configuration. * Well documented & IDE Friendly. * Well tested with maximum code quality. - * Laravel `5.1` to `6.x` are supported. + * Laravel `5.1` to `7.x` are supported. * Made with :heart: & :coffee:. ## Table of contents diff --git a/_docs/1-Installation-and-Setup.md b/_docs/1-Installation-and-Setup.md index a110c38..e8c7692 100644 --- a/_docs/1-Installation-and-Setup.md +++ b/_docs/1-Installation-and-Setup.md @@ -10,6 +10,7 @@ | Laravel Notes | Laravel | |:-----------------------------------------|:---------------------------------------------------------------------------------------| +| ![Laravel Notes v7.x][laravel_notes_7_x] | ![Laravel v7.x][laravel_7_x] | | ![Laravel Notes v6.x][laravel_notes_6_x] | ![Laravel v6.x][laravel_6_x] | | ![Laravel Notes v5.x][laravel_notes_5_x] | ![Laravel v5.8][laravel_5_8] | | ![Laravel Notes v4.x][laravel_notes_4_x] | ![Laravel v5.7][laravel_5_7] | @@ -18,6 +19,7 @@ | ![Laravel Notes v1.x][laravel_notes_1_x] | ![Laravel v5.4][laravel_5_4] | | ![Laravel Notes v0.x][laravel_notes_0_x] | ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] | +[laravel_7_x]: https://img.shields.io/badge/v7.x-supported-brightgreen.svg?style=flat-square "Laravel v7.x" [laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.x" [laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8" [laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7" @@ -28,6 +30,7 @@ [laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2" [laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1" +[laravel_notes_7_x]: https://img.shields.io/badge/version-7.x-blue.svg?style=flat-square "LaravelNotes v7.x" [laravel_notes_6_x]: https://img.shields.io/badge/version-6.x-blue.svg?style=flat-square "LaravelNotes v6.x" [laravel_notes_5_x]: https://img.shields.io/badge/version-5.x-blue.svg?style=flat-square "LaravelNotes v5.x" [laravel_notes_4_x]: https://img.shields.io/badge/version-4.x-blue.svg?style=flat-square "LaravelNotes v4.x" diff --git a/_docs/2-Configuration.md b/_docs/2-Configuration.md index e4641cb..cdc6d90 100644 --- a/_docs/2-Configuration.md +++ b/_docs/2-Configuration.md @@ -30,8 +30,8 @@ return [ */ 'authors' => [ - 'table' => config('auth.table', 'users'), - 'model' => config('auth.model', App\User::class), + 'table' => 'users', + 'model' => App\User::class, ], 'notes' => [ diff --git a/composer.json b/composer.json index 83532cb..1ed48f2 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,13 @@ "type": "library", "license": "MIT", "require": { - "php": "^7.2.0", - "arcanedev/support": "^5.1" + "php": "^7.2.5", + "arcanedev/support": "^7.0" }, "require-dev": { - "orchestra/testbench": "^4.6", + "orchestra/testbench": "^5.0", "mockery/mockery": "^1.3.1", - "phpunit/phpunit": "^8.4|^9.0" + "phpunit/phpunit": "^8.5|^9.0" }, "autoload": { "psr-4": { diff --git a/config/notes.php b/config/notes.php index ff7efad..3b9ee35 100644 --- a/config/notes.php +++ b/config/notes.php @@ -19,8 +19,8 @@ */ 'authors' => [ - 'table' => config('auth.table', 'users'), - 'model' => config('auth.model', App\User::class), + 'table' => 'users', + 'model' => App\User::class, ], 'notes' => [ diff --git a/database/migrations/2016_10_00_000001_create_notes_table.php b/database/migrations/2016_10_00_000001_create_notes_table.php index bb5aa97..ce32e1b 100644 --- a/database/migrations/2016_10_00_000001_create_notes_table.php +++ b/database/migrations/2016_10_00_000001_create_notes_table.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Arcanedev\LaravelNotes\Bases\Migration; +use Arcanedev\LaravelNotes\Database\Migration; use Illuminate\Database\Schema\Blueprint; /** diff --git a/src/Bases/Migration.php b/src/Database/Migration.php similarity index 87% rename from src/Bases/Migration.php rename to src/Database/Migration.php index be1cc03..c62ef1f 100644 --- a/src/Bases/Migration.php +++ b/src/Database/Migration.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace Arcanedev\LaravelNotes\Bases; +namespace Arcanedev\LaravelNotes\Database; use Arcanedev\Support\Database\Migration as BaseMigration; /** * Class Migration * - * @package Arcanedev\LaravelMessenger\Bases + * @package Arcanedev\LaravelNotes\Database * @author ARCANEDEV */ abstract class Migration extends BaseMigration diff --git a/src/Models/Note.php b/src/Models/Note.php index 12b76a2..dfd12d6 100644 --- a/src/Models/Note.php +++ b/src/Models/Note.php @@ -4,7 +4,7 @@ namespace Arcanedev\LaravelNotes\Models; -use Arcanedev\Support\Database\Model; +use Arcanedev\Support\Database\PrefixedModel; use Illuminate\Support\Arr; /** @@ -24,7 +24,7 @@ * @property \Illuminate\Database\Eloquent\Model author * @property \Illuminate\Database\Eloquent\Model noteable */ -class Note extends Model +class Note extends PrefixedModel { /* ----------------------------------------------------------------- | Properties diff --git a/tests/Models/NoteTest.php b/tests/Models/NoteTest.php index 54de69b..72bd8fa 100644 --- a/tests/Models/NoteTest.php +++ b/tests/Models/NoteTest.php @@ -16,7 +16,6 @@ */ class NoteTest extends TestCase { - /* ----------------------------------------------------------------- | Tests [Has One Note] | ----------------------------------------------------------------- @@ -25,8 +24,7 @@ class NoteTest extends TestCase /** @test */ public function it_can_create_a_note(): void { - /** @var Post $post */ - $post = $this->factory->create(Post::class); + $post = $this->createPost(); static::assertNull($post->note); @@ -44,8 +42,7 @@ public function it_can_create_a_note(): void /** @test */ public function it_should_create_single_note_for_has_one_note_trait(): void { - /** @var Post $post */ - $post = $this->factory->create(Post::class); + $post = $this->createPost(); static::assertNull($post->note); @@ -71,12 +68,8 @@ public function it_should_create_single_note_for_has_one_note_trait(): void /** @test */ public function it_can_create_with_author(): void { - /** - * @var User $user - * @var Post $post - */ - $user = $this->factory->create(User::class); - $post = $this->factory->create(Post::class); + $user = $this->createUser(); + $post = $this->createPost(); $note = $post->createNote($content = 'Hello world #1', $user); @@ -93,8 +86,7 @@ public function it_can_create_with_author(): void /** @test */ public function it_can_update_note(): void { - /** @var Post $post */ - $post = $this->factory->create(Post::class); + $post = $this->createPost(); static::assertNull($post->note); @@ -120,8 +112,7 @@ public function it_can_update_note(): void /** @test */ public function it_can_reverse_relation(): void { - /** @var Post $post */ - $post = $this->factory->create(Post::class); + $post = $this->createPost(); static::assertNull($post->note); @@ -140,8 +131,7 @@ public function it_can_reverse_relation(): void /** @test */ public function it_can_add_note(): void { - /** @var User $user */ - $user = $this->factory->create(User::class); + $user = $this->createUser(); static::assertCount(0, $user->notes); @@ -154,8 +144,7 @@ public function it_can_add_note(): void /** @test */ public function it_can_add_note_without_get_current_author_id_method(): void { - /** @var \Arcanedev\LaravelNotes\Tests\Stubs\Models\UserWithAuthorId $user */ - $user = $this->factory->create(UserWithAuthorId::class); + $user = $this->createUserWithAuthorId(); static::assertCount(0, $user->notes); @@ -168,8 +157,7 @@ public function it_can_add_note_without_get_current_author_id_method(): void /** @test */ public function it_can_find_note_by_its_id(): void { - /** @var User $user */ - $user = $this->factory->create(User::class); + $user = $this->createUser(); $created = $user->createNote($content = 'Hello world #1'); $note = $user->findNote($created->id); @@ -180,8 +168,7 @@ public function it_can_find_note_by_its_id(): void /** @test */ public function it_can_retrieve_authored_notes(): void { - /** @var \Arcanedev\LaravelNotes\Tests\Stubs\Models\User $user */ - $user = $this->factory->create(User::class); + $user = $this->createUser(); static::assertCount(0, $user->notes); static::assertCount(0, $user->authoredNotes); @@ -196,12 +183,8 @@ public function it_can_retrieve_authored_notes(): void /** @test */ public function it_must_retrieve_authored_notes_foreach_owner(): void { - /** - * @var \Arcanedev\LaravelNotes\Tests\Stubs\Models\User $userOne - * @var \Arcanedev\LaravelNotes\Tests\Stubs\Models\User $userTwo - */ - $userOne = $this->factory->create(UserWithAuthorId::class); - $userTwo = $this->factory->create(UserWithAuthorId::class); + $userOne = $this->createUserWithAuthorId(); + $userTwo = $this->createUserWithAuthorId(); $userOne->createNote('Hello World #1'); $userOne->createNote('Hello World #2', $userTwo); @@ -212,4 +195,39 @@ public function it_must_retrieve_authored_notes_foreach_owner(): void static::assertCount(0, $userTwo->notes); static::assertCount(1, $userTwo->authoredNotes); } + + /* ----------------------------------------------------------------- + | Other Methods + | ----------------------------------------------------------------- + */ + + /** + * Create a post. + * + * @return \Arcanedev\LaravelNotes\Tests\Stubs\Models\Post|mixed + */ + protected function createPost() + { + return factory(Post::class)->create(); + } + + /** + * Create a user. + * + * @return \Arcanedev\LaravelNotes\Tests\Stubs\Models\User|mixed + */ + protected function createUser() + { + return factory(User::class)->create(); + } + + /** + * Create a user with author id associated. + * + * @return \Arcanedev\LaravelNotes\Tests\Stubs\Models\UserWithAuthorId|mixed + */ + protected function createUserWithAuthorId() + { + return factory(UserWithAuthorId::class)->create(); + } } diff --git a/tests/Stubs/Models/Post.php b/tests/Stubs/Models/Post.php index 002516f..9b0f19b 100644 --- a/tests/Stubs/Models/Post.php +++ b/tests/Stubs/Models/Post.php @@ -5,7 +5,7 @@ namespace Arcanedev\LaravelNotes\Tests\Stubs\Models; use Arcanedev\LaravelNotes\Traits\HasOneNote; -use Arcanedev\Support\Database\Model; +use Arcanedev\Support\Database\PrefixedModel; use Illuminate\Support\Arr; /** @@ -18,7 +18,7 @@ * @property string title * @property string content */ -class Post extends Model +class Post extends PrefixedModel { /* ----------------------------------------------------------------- | Traits diff --git a/tests/Stubs/Models/User.php b/tests/Stubs/Models/User.php index d840a33..26c6a24 100644 --- a/tests/Stubs/Models/User.php +++ b/tests/Stubs/Models/User.php @@ -5,7 +5,7 @@ namespace Arcanedev\LaravelNotes\Tests\Stubs\Models; use Arcanedev\LaravelNotes\Traits\{AuthoredNotes, HasManyNotes}; -use Arcanedev\Support\Database\Model; +use Arcanedev\Support\Database\PrefixedModel; use Illuminate\Support\Arr; /** @@ -16,7 +16,7 @@ * * @property int id */ -class User extends Model +class User extends PrefixedModel { /* ----------------------------------------------------------------- | Traits diff --git a/tests/TestCase.php b/tests/TestCase.php index 6b75a2f..e6ea52b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,8 +4,8 @@ namespace Arcanedev\LaravelNotes\Tests; +use Arcanedev\LaravelNotes\Tests\Stubs\Models\User; use Orchestra\Testbench\TestCase as BaseTestCase; -use Illuminate\Database\Eloquent\Factory as ModelFactory; /** * Class TestCase @@ -33,7 +33,7 @@ public function setUp(): void parent::setUp(); $this->migrate(); - $this->loadFactories(); + $this->withFactories(__DIR__.'/fixtures/factories'); } /** @@ -58,10 +58,10 @@ protected function getPackageProviders($app): array protected function getEnvironmentSetUp($app): void { // Laravel App Configs - $app['config']->set('auth.model', Stubs\Models\User::class); + $app['config']->set('auth.model', User::class); // Laravel Messenger Configs - $app['config']->set('notes.authors.model', Stubs\Models\User::class); + $app['config']->set('notes.authors.model', User::class); } /* ----------------------------------------------------------------- @@ -83,13 +83,4 @@ protected function migrate(): void $this->loadMigrationsFrom($path); } } - - /** - * Load Model Factories. - */ - private function loadFactories(): void - { - $this->factory = $this->app->make(ModelFactory::class); - $this->factory->load(__DIR__.'/fixtures/factories'); - } } diff --git a/tests/fixtures/migrations/2016_10_00_000000_create_users_table.php b/tests/fixtures/migrations/2016_10_00_000000_create_users_table.php index 68a50b1..64449e8 100644 --- a/tests/fixtures/migrations/2016_10_00_000000_create_users_table.php +++ b/tests/fixtures/migrations/2016_10_00_000000_create_users_table.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Arcanedev\LaravelNotes\Bases\Migration; +use Arcanedev\LaravelNotes\Database\Migration; use Illuminate\Database\Schema\Blueprint; /** diff --git a/tests/fixtures/migrations/2016_10_01_000000_create_posts_table.php b/tests/fixtures/migrations/2016_10_01_000000_create_posts_table.php index f67e36e..adc49ed 100644 --- a/tests/fixtures/migrations/2016_10_01_000000_create_posts_table.php +++ b/tests/fixtures/migrations/2016_10_01_000000_create_posts_table.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Arcanedev\LaravelNotes\Bases\Migration; +use Arcanedev\LaravelNotes\Database\Migration; use Illuminate\Database\Schema\Blueprint; /**