From 18eeafd12de85706d2f7b2db366729dbed664155 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:03:31 +0200 Subject: [PATCH 01/13] Laravel 11 support --- .github/workflows/main.yml | 7 ++----- composer.json | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4add4ff..533b66a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,12 +17,9 @@ 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 name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index 5254692..31e8290 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,9 @@ } ], "require": { - "php": "^8.0", - "illuminate/events": "^9.52|^10.0", - "illuminate/support": "^9.52|^10.0", + "php": "^8.1", + "illuminate/events": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", "symfony/event-dispatcher": "^5.1", "symfony/workflow": "^5.1", "symfony/property-access": "^5.1" @@ -29,7 +29,7 @@ "require-dev": { "funkjedi/composer-include-files": "^1.0", "mockery/mockery": "^1.3|^1.4.2", - "orchestra/testbench": "^6.24|^7.0|^8.0", + "orchestra/testbench": "^8.0|^9.0", "phpunit/phpunit": "^9.5|^10.0" }, "extra": { From e7652c7535af47be0ea1b63234d6e506f910e341 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:04:55 +0200 Subject: [PATCH 02/13] update styleci --- .styleci.yml | 1 - 1 file changed, 1 deletion(-) 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 From 529013870e3b90ddccb650e81411c279a3d3277d Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:12:56 +0200 Subject: [PATCH 03/13] fix depencies --- .github/workflows/main.yml | 3 +++ composer.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 533b66a..794e54d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,9 @@ jobs: php: [8.1, 8.2, 8.3] laravel: [10.*, 11.*] dependency-version: [prefer-lowest, prefer-stable] + exclude: + - laravel: 11.* + php: 8.1 name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} diff --git a/composer.json b/composer.json index 31e8290..06517ec 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php": "^8.1", "illuminate/events": "^10.0|^11.0", "illuminate/support": "^10.0|^11.0", - "symfony/event-dispatcher": "^5.1", + "symfony/event-dispatcher": "^6.0|^7.0", "symfony/workflow": "^5.1", "symfony/property-access": "^5.1" }, From 69b80a4bd862b0f2d814da2e7c37c731314df106 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:29:38 +0200 Subject: [PATCH 04/13] fix test --- ...e_users_Test_table.php => add_new_column_to_users_table.php} | 0 tests/TestCase.php | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/Fixtures/database/migrations/{0000_00_00_000000_create_users_Test_table.php => add_new_column_to_users_table.php} (100%) 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/'); } From d4388c3a5f1c6670f2b05dcbfb8efccdbc33d0ee Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:42:45 +0200 Subject: [PATCH 05/13] fix test --- composer.json | 2 +- phpunit.xml | 12 ++++++++- tests/Unit/UserUnitTest.php | 43 ++++---------------------------- tests/WorkflowSubscriberTest.php | 8 ++---- 4 files changed, 19 insertions(+), 46 deletions(-) diff --git a/composer.json b/composer.json index 06517ec..98eab24 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "funkjedi/composer-include-files": "^1.0", "mockery/mockery": "^1.3|^1.4.2", "orchestra/testbench": "^8.0|^9.0", - "phpunit/phpunit": "^9.5|^10.0" + "phpunit/phpunit": "^10.0|^11.0" }, "extra": { "include_files": [ diff --git a/phpunit.xml b/phpunit.xml index 3cc6b8f..ea49601 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,15 @@ - + ./tests 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..0937bb7 100644 --- a/tests/WorkflowSubscriberTest.php +++ b/tests/WorkflowSubscriberTest.php @@ -8,12 +8,8 @@ */ 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 = []; From 7f8180345ab88c150e4f86f55ad8cde4b946df09 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:44:05 +0200 Subject: [PATCH 06/13] apply styleci --- tests/WorkflowSubscriberTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/WorkflowSubscriberTest.php b/tests/WorkflowSubscriberTest.php index 0937bb7..edbcd90 100644 --- a/tests/WorkflowSubscriberTest.php +++ b/tests/WorkflowSubscriberTest.php @@ -8,7 +8,6 @@ */ class WorkflowSubscriberTest extends TestCase { - public function test_if_workflow_subscriber_emit_events() { global $events; From 1436f17beb5ae80ae0f26ee6c338c90562a52a85 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:46:01 +0200 Subject: [PATCH 07/13] add test debug --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 794e54d..7fe1014 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,4 +51,4 @@ jobs: - name: Run PHPUnit tests run: | - vendor/bin/phpunit --testdox + vendor/bin/phpunit --debug From 3eb792b990f224db8ba591183d18d47787d6f30b Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:47:26 +0200 Subject: [PATCH 08/13] fix --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7fe1014..4753547 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,4 +51,4 @@ jobs: - name: Run PHPUnit tests run: | - vendor/bin/phpunit --debug + vendor/bin/phpunit From 773702c8f27c05248a46a0c2afb337caf2e109ad Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 16:59:42 +0200 Subject: [PATCH 09/13] update phpunit.xml --- phpunit.xml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index ea49601..8e65bfa 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -17,11 +17,7 @@ - - - - - - + + From 41bc522dca4ae429d11b5f268be212452cd1fa17 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 17:04:49 +0200 Subject: [PATCH 10/13] pin version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 98eab24..02590a9 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,7 @@ "require-dev": { "funkjedi/composer-include-files": "^1.0", "mockery/mockery": "^1.3|^1.4.2", - "orchestra/testbench": "^8.0|^9.0", + "orchestra/testbench": "^8.0|^9.15", "phpunit/phpunit": "^10.0|^11.0" }, "extra": { From 718f0b1fcc0c82804deac4083c1fcb7cbfb86029 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Wed, 26 Nov 2025 17:07:12 +0200 Subject: [PATCH 11/13] refactor --- phpunit.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/phpunit.xml b/phpunit.xml index 8e65bfa..a23b818 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -17,7 +17,6 @@ - From b23c94391f7a2939578f5700879d667ba10b5df5 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Thu, 27 Nov 2025 11:16:07 +0200 Subject: [PATCH 12/13] migration file should be pubished --- README.md | 18 ++++++++++++------ src/StateWorkflowServiceProvider.php | 12 +----------- 2 files changed, 13 insertions(+), 17 deletions(-) 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/src/StateWorkflowServiceProvider.php b/src/StateWorkflowServiceProvider.php index 933850e..1258b1a 100644 --- a/src/StateWorkflowServiceProvider.php +++ b/src/StateWorkflowServiceProvider.php @@ -78,17 +78,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'); } } From bfa6b62b113175f9ce098db00581105331c0ef44 Mon Sep 17 00:00:00 2001 From: norbybaru Date: Thu, 27 Nov 2025 11:17:28 +0200 Subject: [PATCH 13/13] fix --- src/StateWorkflowServiceProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/StateWorkflowServiceProvider.php b/src/StateWorkflowServiceProvider.php index 1258b1a..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(); }