Skip to content

Commit

Permalink
feat: Symfony 7.0 support (#134)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent <407859+vincentchalamon@users.noreply.github.com>
  • Loading branch information
grosmanal and vincentchalamon committed Jan 14, 2024
1 parent ad2d782 commit 29c24cc
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 103 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/ci.yml
Expand Up @@ -31,13 +31,22 @@ jobs:
symfony:
# Only Symfony supported versions: https://symfony.com/releases
# API Platform 3.* only supports Symfony >= 6.1
- '6.3.*'
- '6.4.*'
- '7.0.*'
include:
# Ensure the bundle is bootable
- php: '8.3'
symfony: '6.3.*'
symfony: '6.4.*'
bootable: true
quality: true
- php: '8.3'
symfony: '7.0.*'
bootable: true
quality: true
exclude:
# Symfony 7 requires php 8.2
- php: '8.1'
symfony: '7.0.*'
fail-fast: false
steps:
- name: Checkout
Expand Down
41 changes: 20 additions & 21 deletions composer.json
Expand Up @@ -16,40 +16,39 @@
}
],
"require": {
"php": ">=7.4",
"php": ">=8.1",
"ircmaxell/random-lib": "^1.2",
"symfony/config": "^5.1 || ^6.0",
"symfony/dependency-injection": "^5.1 || ^6.0",
"symfony/event-dispatcher": "^5.1 || ^6.0",
"symfony/http-foundation": "^5.1 || ^6.0",
"symfony/http-kernel": "^5.1.5 || ^6.0",
"symfony/serializer": "^5.1 || ^6.0"
"symfony/config": "^5.1 || ^6.0 || ^7.0",
"symfony/dependency-injection": "^5.1 || ^6.0 || ^7.0",
"symfony/event-dispatcher": "^5.1 || ^6.0 || ^7.0",
"symfony/http-foundation": "^5.1 || ^6.0 || ^7.0",
"symfony/http-kernel": "^5.1.5 || ^6.0 || ^7.0",
"symfony/serializer": "^5.1 || ^6.0 || ^7.0"
},
"require-dev": {
"ext-json": "*",
"api-platform/core": "^3.0",
"behat/behat": "^3.1",
"dg/bypass-finals": "^1.1",
"doctrine/data-fixtures": "^1.2",
"doctrine/doctrine-bundle": "^1.7.2 || <2.7.1",
"doctrine/doctrine-bundle": "^2.11",
"doctrine/orm": "^2.6.3",
"egulias/email-validator": "^2.1.10",
"friends-of-behat/symfony-extension": "^2.0.11 || ^2.1.0",
"jms/serializer-bundle": "^1.4 || ^2.3 || ^3.0 || ^4.0",
"jms/serializer-bundle": "^1.4 || ^2.3 || ^3.0 || ^4.0 || ^5.0",
"laminas/laminas-code": "^3.4 || ^4.0",
"ocramius/proxy-manager": "^2.0.4",
"sebastian/comparator": "^3.0",
"symfony/asset": "^5.1 || ^6.0",
"symfony/browser-kit": "^5.1 || ^6.0",
"symfony/framework-bundle": "^5.1 || ^6.0",
"symfony/mailer": "^5.1 || ^6.0",
"symfony/phpunit-bridge": "^5.1 || ^6.0",
"symfony/property-access": "^5.1 || ^6.0",
"symfony/security-bundle": "^5.1 || ^6.0",
"symfony/stopwatch": "^5.1 || ^6.0",
"symfony/templating": "^5.1 || ^6.0",
"symfony/twig-bundle": "^5.1 || ^6.0",
"symfony/var-dumper": "^5.1 || ^6.0"
"symfony/asset": "^5.1 || ^6.0 || ^7.0",
"symfony/browser-kit": "^5.1 || ^6.0 || ^7.0",
"symfony/framework-bundle": "^5.1 || ^6.0 || ^7.0",
"symfony/mailer": "^5.1 || ^6.0 || ^7.0",
"symfony/phpunit-bridge": "^5.1 || ^6.0 || ^7.0",
"symfony/property-access": "^5.1 || ^6.0 || ^7.0",
"symfony/security-bundle": "^5.1 || ^6.0 || ^7.0",
"symfony/stopwatch": "^5.1 || ^6.0 || ^7.0",
"symfony/templating": "^5.1 || ^6.0 || ^7.0",
"symfony/twig-bundle": "^5.1 || ^6.0 || ^7.0",
"symfony/var-dumper": "^5.1 || ^6.0 || ^7.0"
},
"suggest": {
"doctrine/doctrine-bundle": "To connect with Doctrine in Symfony project",
Expand Down
6 changes: 3 additions & 3 deletions features/app/AppKernel.php
Expand Up @@ -103,7 +103,7 @@ protected function configureContainer($container, LoaderInterface $loader): void
new Reference('twig'),
new Reference('doctrine'),
])->tag('kernel.event_subscriber');
$container->services()->set(\FeatureContext::class, \FeatureContext::class)->args([
$container->services()->set(FeatureContext::class, FeatureContext::class)->args([
new Reference('test.client'),
new Reference('doctrine'),
new Reference('coop_tilleuls_forgot_password.manager.password_token'),
Expand All @@ -116,7 +116,7 @@ protected function configureContainer($container, LoaderInterface $loader): void
new Reference('twig'),
new Reference('doctrine'),
]))->addTag('kernel.event_subscriber'));
$container->setDefinition(\FeatureContext::class, (new Definition(\FeatureContext::class, [
$container->setDefinition(FeatureContext::class, (new Definition(FeatureContext::class, [
new Reference('test.client'),
new Reference('doctrine'),
new Reference('coop_tilleuls_forgot_password.manager.password_token'),
Expand Down Expand Up @@ -175,7 +175,7 @@ protected function configureContainer($container, LoaderInterface $loader): void
'mappings' => [
'App' => [
'is_bundle' => false,
'type' => 'annotation',
'type' => 'attribute',
'dir' => $this->getProjectDir().'/src/Entity',
'prefix' => 'App\Entity',
'alias' => 'App',
Expand Down
22 changes: 7 additions & 15 deletions features/app/src/Entity/Admin.php
Expand Up @@ -16,41 +16,33 @@
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @ORM\Entity
*/
#[ORM\Entity]
final class Admin implements UserInterface
{
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;

/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: 'string')]
private $email;

/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: 'string')]
private $username;

/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: 'string')]
private $password;

/**
Expand Down
19 changes: 6 additions & 13 deletions features/app/src/Entity/PasswordAdminToken.php
Expand Up @@ -16,29 +16,22 @@
use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*/
#[ORM\Entity]
final class PasswordAdminToken extends AbstractPasswordToken
{
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;

/**
* @var Admin
*
* @ORM\ManyToOne(targetEntity=Admin::class)
*
* @ORM\JoinColumn(nullable=false, name="user_id")
*/
#[ORM\ManyToOne(targetEntity: Admin::class)]
#[ORM\JoinColumn(nullable: false, name: 'user_id')]
private $admin;

/**
Expand Down
21 changes: 6 additions & 15 deletions features/app/src/Entity/PasswordToken.php
Expand Up @@ -16,31 +16,22 @@
use CoopTilleuls\ForgotPasswordBundle\Entity\AbstractPasswordToken;
use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\Entity
*
* @author Vincent CHALAMON <vincent@les-tilleuls.coop>
*/
#[ORM\Entity]
final class PasswordToken extends AbstractPasswordToken
{
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;

/**
* @var User
*
* @ORM\ManyToOne(targetEntity="User")
*
* @ORM\JoinColumn(nullable=false, name="user_id")
*/
#[ORM\ManyToOne(targetEntity: 'User')]
#[ORM\JoinColumn(nullable: false, name: 'user_id')]
private $user;

/**
Expand Down
24 changes: 7 additions & 17 deletions features/app/src/Entity/User.php
Expand Up @@ -16,43 +16,33 @@
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;

/**
* @ORM\Entity
*
* @author Vincent CHALAMON <vincent@les-tilleuls.coop>
*/
#[ORM\Entity]
final class User implements UserInterface
{
/**
* @var int
*
* @ORM\Id
*
* @ORM\Column(type="integer")
*
* @ORM\GeneratedValue(strategy="AUTO")
*/
#[ORM\Id]
#[ORM\Column(type: 'integer')]
#[ORM\GeneratedValue(strategy: 'AUTO')]
private $id;

/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: 'string')]
private $email;

/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: 'string')]
private $username;

/**
* @var string
*
* @ORM\Column(type="string")
*/
#[ORM\Column(type: 'string')]
private $password;

/**
Expand Down
22 changes: 11 additions & 11 deletions features/bootstrap/FeatureContext.php
Expand Up @@ -84,7 +84,7 @@ public function resetDatabase(): void
$purger->setPurgeMode(ORMPurger::PURGE_MODE_TRUNCATE);
try {
$purger->purge();
} catch (\Exception $e) {
} catch (Exception $e) {
$schemaTool = new SchemaTool($this->doctrine->getManager());
$schemaTool->createSchema($this->doctrine->getManager()->getMetadataFactory()->getAllMetadata());
}
Expand All @@ -95,15 +95,15 @@ public function resetDatabase(): void
*/
public function iHaveAValidToken(): void
{
$this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day'));
$this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day'));
}

/**
* @Given I have an expired token
*/
public function iHaveAnExpiredToken(): void
{
$this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('-1 minute'));
$this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('-1 minute'));
}

/**
Expand Down Expand Up @@ -151,7 +151,7 @@ public function iShouldReceiveAnEmail($value = 'john.doe@example.com'): void
$messages = $mailCollector->getEvents()->getMessages();
Assert::assertCount(1, $messages, 'No email has been sent');

/** @var \Symfony\Component\Mime\Email $message */
/** @var Symfony\Component\Mime\Email $message */
$message = $messages[0];
Assert::assertInstanceOf(RawMessage::class, $message);
Assert::assertEquals('Réinitialisation de votre mot de passe', $message->getSubject());
Expand Down Expand Up @@ -237,7 +237,7 @@ public function iResetMyPasswordUsingNoParameter(): void
*/
public function iUpdateMyPassword(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day'));
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day'));

$this->client->request(
'POST',
Expand Down Expand Up @@ -270,7 +270,7 @@ public function thePasswordShouldHaveBeenUpdated(): void
*/
public function iUpdateMyPasswordUsingNoPassword(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day'));
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day'));

$this->client->request('POST', sprintf('/api/forgot-password/%s', $token->getToken()));
}
Expand Down Expand Up @@ -299,7 +299,7 @@ public function iUpdateMyPasswordUsingAnInvalidToken(): void
*/
public function iUpdateMyPasswordUsingWrongProvider(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new \DateTime('+1 day'), $this->providerChain->get('admin'));
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new DateTime('+1 day'), $this->providerChain->get('admin'));

$this->client->request(
'POST',
Expand All @@ -320,7 +320,7 @@ public function iUpdateMyPasswordUsingWrongProvider(): void
*/
public function iUpdateMyPasswordUsingAValidProviderButAnInvalidPasswordField(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new \DateTime('+1 day'), $this->providerChain->get('admin'));
$token = $this->passwordTokenManager->createPasswordToken($this->createAdmin(), new DateTime('+1 day'), $this->providerChain->get('admin'));

$this->client->request(
'POST',
Expand All @@ -341,7 +341,7 @@ public function iUpdateMyPasswordUsingAValidProviderButAnInvalidPasswordField():
*/
public function iUpdateMyPasswordUsingAnExpiredToken(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('-1 minute'));
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('-1 minute'));

$this->client->request(
'POST',
Expand All @@ -362,7 +362,7 @@ public function iUpdateMyPasswordUsingAnExpiredToken(): void
*/
public function iGetAPasswordToken(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('+1 day'));
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('+1 day'));
$token->setToken('d7xtQlJVyN61TzWtrY6xy37zOxB66BqMSDXEbXBbo2Mw4Jjt9C');
$this->doctrine->getManager()->persist($token);
$this->doctrine->getManager()->flush();
Expand All @@ -387,7 +387,7 @@ public function iShouldGetAPasswordToken(): void
*/
public function iGetAPasswordTokenUsingAnExpiredToken(): void
{
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new \DateTime('-1 minute'));
$token = $this->passwordTokenManager->createPasswordToken($this->createUser(), new DateTime('-1 minute'));

$this->client->request('GET', sprintf('/api/forgot-password/%s', $token->getToken()));
}
Expand Down

0 comments on commit 29c24cc

Please sign in to comment.