Skip to content

Commit 758d6a6

Browse files
authored
Laravel 11 support (#30)
* Laravel 11 support * update styleci * fix depencies * fix test * fix test * apply styleci * add test debug * fix * update phpunit.xml * pin version * refactor * migration file should be pubished * fix
1 parent 0a2a8df commit 758d6a6

10 files changed

Lines changed: 43 additions & 82 deletions

File tree

.github/workflows/main.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ jobs:
1717
strategy:
1818
fail-fast: false
1919
matrix:
20-
php: [8.0, 8.1, 8.2]
21-
laravel: [9.*, 10.*]
20+
php: [8.1, 8.2, 8.3]
21+
laravel: [10.*, 11.*]
2222
dependency-version: [prefer-lowest, prefer-stable]
2323
exclude:
24-
- laravel: 10.*
25-
php: 8.0
24+
- laravel: 11.*
25+
php: 8.1
2626

2727
name: PHP${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }}
2828

@@ -51,4 +51,4 @@ jobs:
5151
5252
- name: Run PHPUnit tests
5353
run: |
54-
vendor/bin/phpunit --testdox
54+
vendor/bin/phpunit

.styleci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ enabled:
1313
- no_blank_lines_after_phpdoc
1414
- no_blank_lines_after_return
1515
- no_blank_lines_after_throw
16-
- no_blank_lines_between_imports
1716
- no_blank_lines_between_traits
1817
- no_empty_comment
1918
- no_empty_phpdoc

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ Each step or stage in the process is called a state. You do also define transiti
88
A workflow consist of **state** and **actions** to get from one state to another.
99
These **actions** are called **transitions** which describes how to get from one state to another.
1010
## Installation
11-
```
12-
$ composer require ringierimu/state-workflow
11+
```bash
12+
composer require ringierimu/state-workflow
1313
```
1414

1515
Publish `config/workflow.php` file
16-
```php
17-
$ php artisan vendor:publish --provider="Ringierimu\StateWorkflow\StateWorkflowServiceProvider"
16+
```bash
17+
php artisan vendor:publish --tag="state-workflow-config"
1818
```
19-
Run migrations
19+
20+
Publish migration
21+
```bash
22+
php artisan vendor:publish --tag="state-workflow-migration"
2023
```
21-
$ php artisan migrate
24+
25+
Run migration
26+
```bash
27+
php artisan migrate
2228
```
2329
## Configuration
2430
1. Open `config/workflow.php` and configure it

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919
}
2020
],
2121
"require": {
22-
"php": "^8.0",
23-
"illuminate/events": "^9.52|^10.0",
24-
"illuminate/support": "^9.52|^10.0",
25-
"symfony/event-dispatcher": "^5.1",
22+
"php": "^8.1",
23+
"illuminate/events": "^10.0|^11.0",
24+
"illuminate/support": "^10.0|^11.0",
25+
"symfony/event-dispatcher": "^6.0|^7.0",
2626
"symfony/workflow": "^5.1",
2727
"symfony/property-access": "^5.1"
2828
},
2929
"require-dev": {
3030
"funkjedi/composer-include-files": "^1.0",
3131
"mockery/mockery": "^1.3|^1.4.2",
32-
"orchestra/testbench": "^6.24|^7.0|^8.0",
33-
"phpunit/phpunit": "^9.5|^10.0"
32+
"orchestra/testbench": "^8.0|^9.15",
33+
"phpunit/phpunit": "^10.0|^11.0"
3434
},
3535
"extra": {
3636
"include_files": [

phpunit.xml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.3/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
backupGlobals="false"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
processIsolation="false"
8+
stopOnFailure="false"
9+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd"
10+
cacheDirectory=".phpunit.cache"
11+
backupStaticProperties="false"
12+
>
313
<testsuites>
414
<testsuite name="Test Suite">
515
<directory suffix="Test.php">./tests</directory>
616
</testsuite>
717
</testsuites>
818
<php>
919
<env name="APP_ENV" value="testing"/>
10-
<env name="CACHE_DRIVER" value="array"/>
11-
<env name="SESSION_DRIVER" value="array"/>
12-
<env name="QUEUE_DRIVER" value="sync"/>
13-
<env name="DB_CONNECTION" value="sqlite"/>
14-
<env name="DB_DATABASE" value=":memory:"/>
15-
<ini name="memory_limit" value="512M"/>
20+
<env name="DB_CONNECTION" value="testing"/>
1621
</php>
1722
</phpunit>

src/StateWorkflowServiceProvider.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ public function boot()
1818
{
1919
$this->publishConfig();
2020
$this->publishDatabase();
21-
$this->loadMigrations();
2221
$this->registerCommands();
2322
}
2423

@@ -78,17 +77,7 @@ protected function publishDatabase()
7877
$path = 'migrations/' . date('Y_m_d_His', time());
7978
$this->publishes([
8079
$this->migrationPath() . '/create_state_workflow_histories_table.php' => database_path($path . '_create_state_workflow_histories_table.php'),
81-
], 'state-workflow-migrations');
82-
}
83-
}
84-
85-
/**
86-
* Load migration files.
87-
*/
88-
protected function loadMigrations()
89-
{
90-
if ($this->app->runningInConsole()) {
91-
$this->loadMigrationsFrom($this->migrationPath());
80+
], 'state-workflow-migration');
9281
}
9382
}
9483

tests/Fixtures/database/migrations/0000_00_00_000000_create_users_Test_table.php renamed to tests/Fixtures/database/migrations/add_new_column_to_users_table.php

File renamed without changes.

tests/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected function getEnvironmentSetUp($app)
5252
*/
5353
protected function defineDatabaseMigrations()
5454
{
55-
$this->loadLaravelMigrations();
55+
$this->loadMigrationsFrom(base_path('migrations'));
5656
$this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
5757
$this->loadMigrationsFrom(__DIR__ . '/Fixtures/database/migrations/');
5858
}

tests/Unit/UserUnitTest.php

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,23 @@
1212
*/
1313
class UserUnitTest extends TestCase
1414
{
15-
/**
16-
* @test
17-
*
18-
* @throws \ReflectionException
19-
*/
20-
public function it_return_workflow_instance()
15+
public function test_it_return_workflow_instance()
2116
{
2217
$this->assertInstanceOf(StateWorkflow::class, $this->user->workflow());
2318
}
2419

25-
/**
26-
* Test current state to be new.
27-
*
28-
* @test
29-
*
30-
* @throws \ReflectionException
31-
*/
32-
public function is_current_state_new()
20+
public function test_is_current_state_new()
3321
{
3422
$this->assertEquals('new', $this->user->state());
3523
}
3624

37-
/**
38-
* Test if transition can be applied or not.
39-
*
40-
* @test
41-
*
42-
* @throws \ReflectionException
43-
*/
44-
public function can_apply_transition()
25+
public function test_can_apply_transition()
4526
{
4627
$this->assertTrue($this->user->canTransition('create'));
4728
$this->assertFalse($this->user->canTransition('block'));
4829
}
4930

50-
/**
51-
* Test invalid transition.
52-
*
53-
* @test
54-
*
55-
* @throws \ReflectionException
56-
*/
57-
public function invalid_transition_throws_exception()
31+
public function test_invalid_transition_throws_exception()
5832
{
5933
$expectedExceptionClass = class_exists(NotEnabledTransitionException::class)
6034
? NotEnabledTransitionException::class
@@ -64,14 +38,7 @@ public function invalid_transition_throws_exception()
6438
$this->user->applyTransition('block');
6539
}
6640

67-
/**
68-
* Change Model states by applying transitions.
69-
*
70-
* @test
71-
*
72-
* @throws \ReflectionException
73-
*/
74-
public function apply_transitions()
41+
public function test_apply_transitions()
7542
{
7643
$this->user->applyTransition('create');
7744
$this->user = $this->user->refresh();

tests/WorkflowSubscriberTest.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
*/
99
class WorkflowSubscriberTest extends TestCase
1010
{
11-
/**
12-
* @test
13-
*
14-
* @throws \ReflectionException
15-
*/
16-
public function if_workflow_subscriber_emit_events()
11+
public function test_if_workflow_subscriber_emit_events()
1712
{
1813
global $events;
1914
$events = [];

0 commit comments

Comments
 (0)