diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4add4ff..4753547 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,12 +17,12 @@ jobs: strategy: fail-fast: false matrix: - php: [8.0, 8.1, 8.2] - laravel: [9.*, 10.*] + php: [8.1, 8.2, 8.3] + laravel: [10.*, 11.*] dependency-version: [prefer-lowest, prefer-stable] exclude: - - laravel: 10.* - php: 8.0 + - laravel: 11.* + php: 8.1 name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} @@ -51,4 +51,4 @@ jobs: - name: Run PHPUnit tests run: | - vendor/bin/phpunit --testdox + vendor/bin/phpunit diff --git a/.styleci.yml b/.styleci.yml index 9c21065..5c27c16 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -13,7 +13,6 @@ enabled: - no_blank_lines_after_phpdoc - no_blank_lines_after_return - no_blank_lines_after_throw - - no_blank_lines_between_imports - no_blank_lines_between_traits - no_empty_comment - no_empty_phpdoc diff --git a/README.md b/README.md index 606b11c..74a7710 100644 --- a/README.md +++ b/README.md @@ -8,17 +8,23 @@ Each step or stage in the process is called a state. You do also define transiti A workflow consist of **state** and **actions** to get from one state to another. These **actions** are called **transitions** which describes how to get from one state to another. ## Installation -``` -$ composer require ringierimu/state-workflow +```bash +composer require ringierimu/state-workflow ``` Publish `config/workflow.php` file -```php -$ php artisan vendor:publish --provider="Ringierimu\StateWorkflow\StateWorkflowServiceProvider" +```bash +php artisan vendor:publish --tag="state-workflow-config" ``` -Run migrations + +Publish migration +```bash +php artisan vendor:publish --tag="state-workflow-migration" ``` -$ php artisan migrate + +Run migration +```bash +php artisan migrate ``` ## Configuration 1. Open `config/workflow.php` and configure it diff --git a/composer.json b/composer.json index 5254692..02590a9 100644 --- a/composer.json +++ b/composer.json @@ -19,18 +19,18 @@ } ], "require": { - "php": "^8.0", - "illuminate/events": "^9.52|^10.0", - "illuminate/support": "^9.52|^10.0", - "symfony/event-dispatcher": "^5.1", + "php": "^8.1", + "illuminate/events": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", + "symfony/event-dispatcher": "^6.0|^7.0", "symfony/workflow": "^5.1", "symfony/property-access": "^5.1" }, "require-dev": { "funkjedi/composer-include-files": "^1.0", "mockery/mockery": "^1.3|^1.4.2", - "orchestra/testbench": "^6.24|^7.0|^8.0", - "phpunit/phpunit": "^9.5|^10.0" + "orchestra/testbench": "^8.0|^9.15", + "phpunit/phpunit": "^10.0|^11.0" }, "extra": { "include_files": [ diff --git a/phpunit.xml b/phpunit.xml index 3cc6b8f..a23b818 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,15 @@ - + ./tests @@ -7,11 +17,6 @@ - - - - - - + diff --git a/src/StateWorkflowServiceProvider.php b/src/StateWorkflowServiceProvider.php index 933850e..028481a 100644 --- a/src/StateWorkflowServiceProvider.php +++ b/src/StateWorkflowServiceProvider.php @@ -18,7 +18,6 @@ public function boot() { $this->publishConfig(); $this->publishDatabase(); - $this->loadMigrations(); $this->registerCommands(); } @@ -78,17 +77,7 @@ protected function publishDatabase() $path = 'migrations/' . date('Y_m_d_His', time()); $this->publishes([ $this->migrationPath() . '/create_state_workflow_histories_table.php' => database_path($path . '_create_state_workflow_histories_table.php'), - ], 'state-workflow-migrations'); - } - } - - /** - * Load migration files. - */ - protected function loadMigrations() - { - if ($this->app->runningInConsole()) { - $this->loadMigrationsFrom($this->migrationPath()); + ], 'state-workflow-migration'); } } diff --git a/tests/Fixtures/database/migrations/0000_00_00_000000_create_users_Test_table.php b/tests/Fixtures/database/migrations/add_new_column_to_users_table.php similarity index 100% rename from tests/Fixtures/database/migrations/0000_00_00_000000_create_users_Test_table.php rename to tests/Fixtures/database/migrations/add_new_column_to_users_table.php diff --git a/tests/TestCase.php b/tests/TestCase.php index 54f9f29..bad1d17 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -52,7 +52,7 @@ protected function getEnvironmentSetUp($app) */ protected function defineDatabaseMigrations() { - $this->loadLaravelMigrations(); + $this->loadMigrationsFrom(base_path('migrations')); $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); $this->loadMigrationsFrom(__DIR__ . '/Fixtures/database/migrations/'); } diff --git a/tests/Unit/UserUnitTest.php b/tests/Unit/UserUnitTest.php index 166fbed..6069e96 100644 --- a/tests/Unit/UserUnitTest.php +++ b/tests/Unit/UserUnitTest.php @@ -12,49 +12,23 @@ */ class UserUnitTest extends TestCase { - /** - * @test - * - * @throws \ReflectionException - */ - public function it_return_workflow_instance() + public function test_it_return_workflow_instance() { $this->assertInstanceOf(StateWorkflow::class, $this->user->workflow()); } - /** - * Test current state to be new. - * - * @test - * - * @throws \ReflectionException - */ - public function is_current_state_new() + public function test_is_current_state_new() { $this->assertEquals('new', $this->user->state()); } - /** - * Test if transition can be applied or not. - * - * @test - * - * @throws \ReflectionException - */ - public function can_apply_transition() + public function test_can_apply_transition() { $this->assertTrue($this->user->canTransition('create')); $this->assertFalse($this->user->canTransition('block')); } - /** - * Test invalid transition. - * - * @test - * - * @throws \ReflectionException - */ - public function invalid_transition_throws_exception() + public function test_invalid_transition_throws_exception() { $expectedExceptionClass = class_exists(NotEnabledTransitionException::class) ? NotEnabledTransitionException::class @@ -64,14 +38,7 @@ public function invalid_transition_throws_exception() $this->user->applyTransition('block'); } - /** - * Change Model states by applying transitions. - * - * @test - * - * @throws \ReflectionException - */ - public function apply_transitions() + public function test_apply_transitions() { $this->user->applyTransition('create'); $this->user = $this->user->refresh(); diff --git a/tests/WorkflowSubscriberTest.php b/tests/WorkflowSubscriberTest.php index f62e445..edbcd90 100644 --- a/tests/WorkflowSubscriberTest.php +++ b/tests/WorkflowSubscriberTest.php @@ -8,12 +8,7 @@ */ class WorkflowSubscriberTest extends TestCase { - /** - * @test - * - * @throws \ReflectionException - */ - public function if_workflow_subscriber_emit_events() + public function test_if_workflow_subscriber_emit_events() { global $events; $events = [];