Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to symfony ^6.4 || ^7.0 #733

Merged
merged 3 commits into from
Feb 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:
with:
PHP_EXTENSIONS: "mbstring, json, mongodb"
SYMFONY_KERNEL: "Nucleos\\UserBundle\\Tests\\App\\AppKernel"
SYMFONY_VERSIONS: "6.3"
SYMFONY_VERSIONS: "6.4,7.0"
secrets:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
50 changes: 25 additions & 25 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,42 +41,42 @@
"doctrine/event-manager": "^1.2 || ^2.0",
"doctrine/persistence": "^2.3 || ^3.0",
"paragonie/random_compat": "^1 || ^2 || ^9",
"symfony/config": "^6.3",
"symfony/console": "^6.3",
"symfony/dependency-injection": "^6.3",
"symfony/event-dispatcher": "^6.3",
"symfony/config": "^6.4 || ^7.0",
"symfony/console": "^6.4 || ^7.0",
"symfony/dependency-injection": "^6.4 || ^7.0",
"symfony/event-dispatcher": "^6.4 || ^7.0",
"symfony/event-dispatcher-contracts": "^2.5 || ^3.0",
"symfony/form": "^6.3",
"symfony/framework-bundle": "^6.3",
"symfony/http-foundation": "^6.3",
"symfony/http-kernel": "^6.3",
"symfony/mailer": "^6.3",
"symfony/mime": "^6.3",
"symfony/options-resolver": "^6.3",
"symfony/password-hasher": "^6.3",
"symfony/form": "^6.4 || ^7.0",
"symfony/framework-bundle": "^6.4 || ^7.0",
"symfony/http-foundation": "^6.4 || ^7.0",
"symfony/http-kernel": "^6.4 || ^7.0",
"symfony/mailer": "^6.4 || ^7.0",
"symfony/mime": "^6.4 || ^7.0",
"symfony/options-resolver": "^6.4 || ^7.0",
"symfony/password-hasher": "^6.4 || ^7.0",
"symfony/polyfill-mbstring": "^1.13",
"symfony/routing": "^6.3",
"symfony/security-bundle": "^6.3",
"symfony/security-core": "^6.3",
"symfony/security-csrf": "^6.3",
"symfony/security-http": "^6.3",
"symfony/translation": "^6.3",
"symfony/routing": "^6.4 || ^7.0",
"symfony/security-bundle": "^6.4 || ^7.0",
"symfony/security-core": "^6.4 || ^7.0",
"symfony/security-csrf": "^6.4 || ^7.0",
"symfony/security-http": "^6.4 || ^7.0",
"symfony/translation": "^6.4 || ^7.0",
"symfony/translation-contracts": "^2.5 || ^3.0",
"symfony/twig-bridge": "^6.3",
"symfony/twig-bundle": "^6.3",
"symfony/validator": "^6.3",
"symfony/twig-bridge": "^6.4 || ^7.0",
"symfony/twig-bundle": "^6.4 || ^7.0",
"symfony/validator": "^6.4 || ^7.0",
"twig/twig": "^2.14 || ^3.1"
},
"require-dev": {
"ext-mongodb": "*",
"doctrine/doctrine-bundle": "^2.4",
"doctrine/mongodb-odm": "^2.3",
"doctrine/mongodb-odm-bundle": "^4.4",
"doctrine/mongodb-odm-bundle": "^4.4 || ^5.0",
"doctrine/orm": "^2.12",
"ergebnis/composer-normalize": "^2.0.1",
"symfony/browser-kit": "^6.3",
"symfony/doctrine-bridge": "^6.3",
"symfony/yaml": "^6.3"
"symfony/browser-kit": "^6.4 || ^7.0",
"symfony/doctrine-bridge": "^6.4 || ^7.0",
"symfony/yaml": "^6.4 || ^7.0"
},
"conflict": {
"doctrine/doctrine-bundle": "<1.12",
Expand Down
2 changes: 1 addition & 1 deletion src/Action/UpdateSecurityAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Nucleos\UserBundle\Model\UserManager;
use Nucleos\UserBundle\NucleosUserEvents;
use Nucleos\UserBundle\Util\UserManipulator;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
Expand All @@ -29,7 +30,6 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;

Expand Down
6 changes: 2 additions & 4 deletions src/Command/ActivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

#[AsCommand(name: 'nucleos:user:activate', description: 'Activate a user')]
final class ActivateUserCommand extends Command
{
protected static $defaultName = 'nucleos:user:activate';

private readonly UserManipulator $userManipulator;

public function __construct(UserManipulator $userManipulator)
Expand All @@ -37,8 +37,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
->setName('nucleos:user:activate')
->setDescription('Activate a user')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
])
Expand Down
6 changes: 2 additions & 4 deletions src/Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

#[AsCommand(name: 'nucleos:user:change-password', description: 'Change the password of a user.')]
final class ChangePasswordCommand extends Command
{
protected static $defaultName = 'nucleos:user:change-password';

private readonly UserManipulator $userManipulator;

public function __construct(UserManipulator $userManipulator)
Expand All @@ -37,8 +37,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
->setName('nucleos:user:change-password')
->setDescription('Change the password of a user.')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
new InputArgument('password', InputArgument::REQUIRED, 'The password'),
Expand Down
6 changes: 2 additions & 4 deletions src/Command/CreateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

#[AsCommand(name: 'nucleos:user:create', description: 'Create a user.')]
final class CreateUserCommand extends Command
{
protected static $defaultName = 'nucleos:user:create';

private readonly UserManipulator $userManipulator;

public function __construct(UserManipulator $userManipulator)
Expand All @@ -38,8 +38,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
->setName('nucleos:user:create')
->setDescription('Create a user.')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
new InputArgument('email', InputArgument::REQUIRED, 'The email'),
Expand Down
6 changes: 2 additions & 4 deletions src/Command/DeactivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@

use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;

#[AsCommand(name: 'nucleos:user:deactivate', description: 'Deactivate a user')]
final class DeactivateUserCommand extends Command
{
protected static $defaultName = 'nucleos:user:deactivate';

private readonly UserManipulator $userManipulator;

public function __construct(UserManipulator $userManipulator)
Expand All @@ -37,8 +37,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
->setName('nucleos:user:deactivate')
->setDescription('Deactivate a user')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
])
Expand Down
6 changes: 2 additions & 4 deletions src/Command/DemoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
namespace Nucleos\UserBundle\Command;

use Nucleos\UserBundle\Util\UserManipulator;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'nucleos:user:demote', description: 'Demote a user by removing a role')]
final class DemoteUserCommand extends RoleCommand
{
protected static $defaultName = 'nucleos:user:demote';

protected function configure(): void
{
parent::configure();

$this
->setName('nucleos:user:demote')
->setDescription('Demote a user by removing a role')
->setHelp(
<<<'EOT'
The <info>nucleos:user:demote</info> command demotes a user by removing a role
Expand Down
6 changes: 2 additions & 4 deletions src/Command/PromoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
namespace Nucleos\UserBundle\Command;

use Nucleos\UserBundle\Util\UserManipulator;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(name: 'nucleos:user:promote', description: 'Promotes a user by adding a role')]
final class PromoteUserCommand extends RoleCommand
{
protected static $defaultName = 'nucleos:user:promote';

protected function configure(): void
{
parent::configure();

$this
->setName('nucleos:user:promote')
->setDescription('Promotes a user by adding a role')
->setHelp(
<<<'EOT'
The <info>nucleos:user:promote</info> command promotes a user by adding a role
Expand Down
24 changes: 6 additions & 18 deletions src/Resources/config/commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,37 @@
$container->services()

->set(ActivateUserCommand::class)
->tag('console.command', [
'command' => 'nucleos:user:activate',
])
->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])

->set(ChangePasswordCommand::class)
->tag('console.command', [
'command' => 'nucleos:user:change-password',
])
->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])

->set(CreateUserCommand::class)
->tag('console.command', [
'command' => 'nucleos:user:create',
])
->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])

->set(DeactivateUserCommand::class)
->tag('console.command', [
'command' => 'nucleos:user:deactivate',
])
->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])

->set(DemoteUserCommand::class)
->tag('console.command', [
'command' => 'nucleos:user:demote',
])
->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])

->set(PromoteUserCommand::class)
->tag('console.command', [
'command' => 'nucleos:user:promote',
])
->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])
Expand Down
3 changes: 1 addition & 2 deletions tests/App/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ protected function configureRoutes(RoutingConfigurator $routes): void

protected function configureContainer(ContainerConfigurator $container): void
{
$container->import(__DIR__.'/config/config.yaml');
$container->import(__DIR__.'/config/security.yaml');
$container->import(__DIR__.'/config/config.php');
}

private function getBaseDir(): string
Expand Down
62 changes: 62 additions & 0 deletions tests/App/config/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

/*
* This file is part of the NucleosUserBundle package.
*
* (c) Christian Gripp <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Nucleos\UserBundle\Model\UserInterface;
use Nucleos\UserBundle\Tests\App\Entity\TestGroup;
use Nucleos\UserBundle\Tests\App\Entity\TestUser;
use Symfony\Component\Security\Http\Attribute\IsGranted;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->extension('framework', ['secret' => 'secret']);

$containerConfigurator->extension('framework', ['test' => true]);

$containerConfigurator->extension('framework', ['session' => ['storage_factory_id' => 'session.storage.factory.mock_file', 'handler_id' => null]]);

$containerConfigurator->extension('twig', ['strict_variables' => true]);

$containerConfigurator->extension('twig', ['exception_controller' => null]);

$securityConfig = [
'firewalls' => ['main' => ['security' => true]],
];

// TODO: Remove if when dropping support of Symfony 5.4
if (!class_exists(IsGranted::class)) {
$securityConfig['enable_authenticator_manager'] = true;
}

$containerConfigurator->extension('security', $securityConfig);

$containerConfigurator->extension('security', [
'providers' => ['nucleos_userbundle' => ['id' => 'nucleos_user.user_provider.username']],
]);

$containerConfigurator->extension('security', ['access_control' => [['path' => '^/.*', 'role' => 'PUBLIC_ACCESS']]]);

$containerConfigurator->extension('security', ['password_hashers' => [UserInterface::class => [
'algorithm' => 'plaintext',
]]]);

$containerConfigurator->extension('nucleos_user', ['firewall_name' => 'main']);

$containerConfigurator->extension('nucleos_user', ['from_email' => 'no-reply@localhost']);

$containerConfigurator->extension('nucleos_user', ['user_class' => TestUser::class]);

$containerConfigurator->extension('nucleos_user', ['group' => ['group_class' => TestGroup::class]]);

$containerConfigurator->extension('nucleos_user', ['loggedin' => ['route' => 'home']]);
};
Loading
Loading