diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 6ffac9e..6530ebb 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: true matrix: - php: [7.2, 7.3, 7.4] + php: [7.3, 7.4] dependency-version: [prefer-lowest, prefer-stable] name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }} @@ -22,7 +22,7 @@ jobs: uses: actions/cache@v2 with: path: ~/.composer/cache/files - key: dependencies-laravel-7.x-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + key: dependencies-laravel-8.x-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} - name: Setup PHP uses: shivammathur/setup-php@v2 diff --git a/.scrutinizer.yml b/.scrutinizer.yml index a34f2cb..5dc7cd4 100644 --- a/.scrutinizer.yml +++ b/.scrutinizer.yml @@ -23,7 +23,7 @@ checks: tools: external_code_coverage: timeout: 600 - runs: 6 + runs: 4 php_code_sniffer: enabled: true config: diff --git a/README.md b/README.md index 9c942eb..dc42d4e 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 `7.x` are supported. + * Laravel `5.1` to `8.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%207.x-orange.svg?style=flat-square +[badge_laravel]: https://img.shields.io/badge/For%20Laravel-5.1%20to%208.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 6fbc651..d1d714d 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 `7.x` are supported. + * Laravel `5.1` to `8.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 e5c76a6..ffc0325 100644 --- a/_docs/1-Installation-and-Setup.md +++ b/_docs/1-Installation-and-Setup.md @@ -10,6 +10,7 @@ | Laravel | Laravel Notes | |:-----------------------------|:-----------------------------------------| +| ![Laravel v8.x][laravel_8_x] | ![Laravel Notes v8.x][laravel_notes_8_x] | | ![Laravel v7.x][laravel_7_x] | ![Laravel Notes v7.x][laravel_notes_7_x] | | ![Laravel v6.x][laravel_6_x] | ![Laravel Notes v6.x][laravel_notes_6_x] | | ![Laravel v5.8][laravel_5_8] | ![Laravel Notes v5.x][laravel_notes_5_x] | @@ -21,6 +22,7 @@ | ![Laravel v5.2][laravel_5_2] | ![Laravel Notes v0.x][laravel_notes_0_x] | | ![Laravel v5.1][laravel_5_1] | ![Laravel Notes v0.x][laravel_notes_0_x] | +[laravel_8_x]: https://img.shields.io/badge/version-8.x-blue.svg?style=flat-square "Laravel v8.x" [laravel_7_x]: https://img.shields.io/badge/version-7.x-blue.svg?style=flat-square "Laravel v7.x" [laravel_6_x]: https://img.shields.io/badge/version-6.x-blue.svg?style=flat-square "Laravel v6.x" [laravel_5_8]: https://img.shields.io/badge/version-5.8-blue.svg?style=flat-square "Laravel v5.8" @@ -32,6 +34,7 @@ [laravel_5_2]: https://img.shields.io/badge/version-5.2-blue.svg?style=flat-square "Laravel v5.2" [laravel_5_1]: https://img.shields.io/badge/version-5.1-blue.svg?style=flat-square "Laravel v5.1" +[laravel_notes_8_x]: https://img.shields.io/badge/version-8.x-blue.svg?style=flat-square "LaravelNotes v8.x" [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" diff --git a/composer.json b/composer.json index 603d32f..53a5953 100644 --- a/composer.json +++ b/composer.json @@ -14,13 +14,13 @@ "type": "library", "license": "MIT", "require": { - "php": "^7.2.5", - "arcanedev/support": "^7.0" + "php": "^7.3", + "arcanedev/support": "^8.0" }, "require-dev": { "mockery/mockery": "^1.3.1", - "orchestra/testbench": "^5.0", - "phpunit/phpunit": "^8.5|^9.0" + "orchestra/testbench": "^6.0", + "phpunit/phpunit": "^9.3" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a7b98b7..aedef0a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,31 +1,26 @@ - +> - ./tests/ - ./tests/fixtures/ + ./tests + ./tests/fixtures - - - ./src/ - - + + + ./src + + + + + + + - - - - - diff --git a/tests/Models/NoteTest.php b/tests/Models/NoteTest.php index e4e07ca..84ba0d3 100644 --- a/tests/Models/NoteTest.php +++ b/tests/Models/NoteTest.php @@ -5,7 +5,8 @@ namespace Arcanedev\LaravelNotes\Tests\Models; use Arcanedev\LaravelNotes\Models\Note; -use Arcanedev\LaravelNotes\Tests\Stubs\Models\{Post, User, UserWithAuthorId}; +use Arcanedev\LaravelNotes\Tests\Stubs\Factories\{PostFactory, UserFactory, UserWithAuthorIdFactory}; +use Arcanedev\LaravelNotes\Tests\Stubs\Models\User; use Arcanedev\LaravelNotes\Tests\TestCase; /** @@ -205,9 +206,9 @@ public function it_must_retrieve_authored_notes_foreach_owner(): void * * @return \Arcanedev\LaravelNotes\Tests\Stubs\Models\Post|mixed */ - protected function createPost() + protected static function createPost() { - return factory(Post::class)->create(); + return PostFactory::new()->create(); } /** @@ -215,9 +216,9 @@ protected function createPost() * * @return \Arcanedev\LaravelNotes\Tests\Stubs\Models\User|mixed */ - protected function createUser() + protected static function createUser() { - return factory(User::class)->create(); + return UserFactory::new()->create(); } /** @@ -225,8 +226,8 @@ protected function createUser() * * @return \Arcanedev\LaravelNotes\Tests\Stubs\Models\UserWithAuthorId|mixed */ - protected function createUserWithAuthorId() + protected static function createUserWithAuthorId() { - return factory(UserWithAuthorId::class)->create(); + return UserWithAuthorIdFactory::new()->create(); } } diff --git a/tests/Stubs/Factories/NoteFactory.php b/tests/Stubs/Factories/NoteFactory.php new file mode 100644 index 0000000..07880d8 --- /dev/null +++ b/tests/Stubs/Factories/NoteFactory.php @@ -0,0 +1,45 @@ + + */ +class NoteFactory extends Factory +{ + /* ----------------------------------------------------------------- + | Properties + | ----------------------------------------------------------------- + */ + + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = User::class; + + /* ----------------------------------------------------------------- + | Main Methods + | ----------------------------------------------------------------- + */ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'content' => $this->faker->paragraph, + ]; + } +} diff --git a/tests/Stubs/Factories/PostFactory.php b/tests/Stubs/Factories/PostFactory.php new file mode 100644 index 0000000..c147655 --- /dev/null +++ b/tests/Stubs/Factories/PostFactory.php @@ -0,0 +1,46 @@ + + */ +class PostFactory extends Factory +{ + /* ----------------------------------------------------------------- + | Properties + | ----------------------------------------------------------------- + */ + + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = Post::class; + + /* ----------------------------------------------------------------- + | Main Methods + | ----------------------------------------------------------------- + */ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'title' => $this->faker->paragraph, + 'content' => $this->faker->paragraphs(5, true), + ]; + } +} diff --git a/tests/Stubs/Factories/UserFactory.php b/tests/Stubs/Factories/UserFactory.php new file mode 100644 index 0000000..7104b85 --- /dev/null +++ b/tests/Stubs/Factories/UserFactory.php @@ -0,0 +1,46 @@ + + */ +class UserFactory extends Factory +{ + /* ----------------------------------------------------------------- + | Properties + | ----------------------------------------------------------------- + */ + + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = User::class; + + /* ----------------------------------------------------------------- + | Main Methods + | ----------------------------------------------------------------- + */ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => $this->faker->name, + 'email' => $this->faker->safeEmail, + ]; + } +} diff --git a/tests/Stubs/Factories/UserWithAuthorIdFactory.php b/tests/Stubs/Factories/UserWithAuthorIdFactory.php new file mode 100644 index 0000000..04d35f8 --- /dev/null +++ b/tests/Stubs/Factories/UserWithAuthorIdFactory.php @@ -0,0 +1,46 @@ + + */ +class UserWithAuthorIdFactory extends Factory +{ + /* ----------------------------------------------------------------- + | Properties + | ----------------------------------------------------------------- + */ + + /** + * The name of the factory's corresponding model. + * + * @var string + */ + protected $model = UserWithAuthorId::class; + + /* ----------------------------------------------------------------- + | Main Methods + | ----------------------------------------------------------------- + */ + + /** + * Define the model's default state. + * + * @return array + */ + public function definition(): array + { + return [ + 'name' => $this->faker->name, + 'email' => $this->faker->safeEmail, + ]; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index ab85eef..9e348c1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,14 +14,6 @@ */ abstract class TestCase extends BaseTestCase { - /* ----------------------------------------------------------------- - | Properties - | ----------------------------------------------------------------- - */ - - /** @var \Illuminate\Database\Eloquent\Factory */ - protected $factory; - /* ----------------------------------------------------------------- | Main Methods | ----------------------------------------------------------------- @@ -31,8 +23,7 @@ public function setUp(): void { parent::setUp(); - $this->migrate(); - $this->withFactories(__DIR__.'/fixtures/factories'); + $this->migrate();; } /** diff --git a/tests/fixtures/factories/ModelFactory.php b/tests/fixtures/factories/ModelFactory.php deleted file mode 100644 index 4002e8c..0000000 --- a/tests/fixtures/factories/ModelFactory.php +++ /dev/null @@ -1,35 +0,0 @@ -define(Note::class, function (Faker $f) { - return [ - 'content' => $f->paragraph, - ]; -}); - -$factory->define(User::class, function (Faker $f) { - return [ - 'name' => $f->name, - 'email' => $f->safeEmail, - ]; -}); - -$factory->define(UserWithAuthorId::class, function (Faker $f) { - return [ - 'name' => $f->name, - 'email' => $f->safeEmail, - ]; -}); - -$factory->define(Post::class, function (Faker $f) { - return [ - 'title' => $f->paragraph, - 'content' => $f->paragraphs(5, true), - ]; -});