Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Latest
* [#119](https://github.com/cleverage/ui-process-bundle/issues/119) Launch form: a context row without key is left out of the context (reported by its `NotBlank` constraint): it gave a 500 when the process has constraints on the context, and a PHP 8.5 deprecation (`null` array offset). Add tests.
* [#121](https://github.com/cleverage/ui-process-bundle/issues/121) `ListAction` / `LaunchAction`: accessed directly (`/process/list`, `/process/launch`), redirected to the dashboard (`/process?routeName=...`) instead of a 500. Add tests.
* [#123](https://github.com/cleverage/ui-process-bundle/issues/123) HTTP API: the parameters of the query string are also read without body, and `queue` is read from the query string (the form data takes precedence). Add tests.
* [#125](https://github.com/cleverage/ui-process-bundle/issues/125) `ProcessSchedule::getContext()` decodes a JSON string as an array; `User::getRoles()` no longer duplicates `ROLE_USER`; `symfony/expression-language` declared (used by `Assert\When`); the `underscore_number_aware` Doctrine naming strategy prerequisite is documented. Add tests.

v3.0.2
------
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
"symfony/doctrine-messenger": "^6.4 || ^7.4 || ^8",
"symfony/dotenv": "^6.4 || ^7.4 || ^8",
"symfony/event-dispatcher": "^6.4 || ^7.4 || ^8",
"symfony/expression-language": "^6.4 || ^7.4 || ^8",
"symfony/filesystem": "^6.4 || ^7.4 || ^8",
"symfony/finder": "^6.4 || ^7.4 || ^8",
"symfony/form": "^6.4 || ^7.4 || ^8",
Expand Down
10 changes: 10 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ See [users & security](reference/03-users_and_security.md).

Supported databases: **MySQL / MariaDB** and **PostgreSQL** (maintained versions).

The entities of the bundle expect the `underscore_number_aware` Doctrine naming strategy (that of the Symfony recipe):
their indexes reference `snake_case` column names (e.g. `start_date`).

```yaml
# config/packages/doctrine.yaml
doctrine:
orm:
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
```

The bundle registers its own Doctrine migrations (`CleverAge\UiProcessBundle\Migrations`). Run them, then create a
first user:

Expand Down
2 changes: 1 addition & 1 deletion src/Entity/ProcessSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function setProcess(string $process): static
*/
public function getContext(): array
{
return \is_array($this->context) ? $this->context : json_decode($this->context);
return \is_array($this->context) ? $this->context : json_decode($this->context, true);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function setLocale(?string $locale): self

public function getRoles(): array
{
return array_merge(['ROLE_USER'], $this->roles);
return array_values(array_unique(array_merge(['ROLE_USER'], $this->roles)));
}

/**
Expand Down
4 changes: 4 additions & 0 deletions tests/Entity/ProcessScheduleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function testGetContextDecodesJsonString(): void
(new \ReflectionProperty(ProcessSchedule::class, 'context'))->setValue($schedule, '["a","b"]');

self::assertSame(['a', 'b'], $schedule->getContext());

// A JSON object is decoded as an array (it gave a stdClass: TypeError on the return type)
(new \ReflectionProperty(ProcessSchedule::class, 'context'))->setValue($schedule, '{"key":"value"}');
self::assertSame(['key' => 'value'], $schedule->getContext());
}

/**
Expand Down
8 changes: 8 additions & 0 deletions tests/Entity/UserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ public function testGettersAndSetters(): void
self::assertNull($user->getToken());
}

public function testRoleUserIsNotDuplicated(): void
{
// As stored by UserCreateCommand
$user = (new User())->setRoles(['ROLE_USER', 'ROLE_ADMIN']);

self::assertSame(['ROLE_USER', 'ROLE_ADMIN'], $user->getRoles());
}

public function testUserIdentifierRequiresAnEmail(): void
{
$user = (new User())->setEmail('');
Expand Down
Loading