diff --git a/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php b/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php index 34c86c79..7a2d327d 100644 --- a/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php +++ b/src/DependencyInjection/SymfonyCastsResetPasswordExtension.php @@ -14,6 +14,7 @@ use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\DependencyInjection\Reference; +use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface; /** * @author Jesse Rushlow @@ -33,6 +34,8 @@ public function load(array $configs, ContainerBuilder $container): void $config = $this->processConfiguration($configuration, $configs); + $container->setAlias(ResetPasswordRequestRepositoryInterface::class, $config['request_password_repository']); + $helperDefinition = $container->getDefinition('symfonycasts.reset_password.helper'); $helperDefinition->replaceArgument(2, new Reference($config['request_password_repository'])); $helperDefinition->replaceArgument(3, $config['lifetime']); diff --git a/tests/IntegrationTests/ResetPasswordRequestRepositoryInterfaceAutowireTest.php b/tests/IntegrationTests/ResetPasswordRequestRepositoryInterfaceAutowireTest.php new file mode 100644 index 00000000..6f9227e1 --- /dev/null +++ b/tests/IntegrationTests/ResetPasswordRequestRepositoryInterfaceAutowireTest.php @@ -0,0 +1,44 @@ + + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace SymfonyCasts\Bundle\ResetPassword\Tests\IntegrationTests; + +use PHPUnit\Framework\TestCase; +use Symfony\Component\DependencyInjection\ContainerBuilder; +use SymfonyCasts\Bundle\ResetPassword\Persistence\ResetPasswordRequestRepositoryInterface; +use SymfonyCasts\Bundle\ResetPassword\Tests\ResetPasswordTestKernel; + +final class ResetPasswordRequestRepositoryInterfaceAutowireTest extends TestCase +{ + public function testResetPasswordRequestRepositoryInterfaceIsAutowiredByContainer(): void + { + $builder = new ContainerBuilder(); + $builder->autowire(ResetPasswordRequestRepositoryAutowireTest::class) + ->setPublic(true) + ; + + $kernel = new ResetPasswordTestKernel($builder); + $kernel->boot(); + + $container = $kernel->getContainer(); + $container->get(ResetPasswordRequestRepositoryAutowireTest::class); + + $this->expectNotToPerformAssertions(); + } +} + +/** + * @internal + */ +final class ResetPasswordRequestRepositoryAutowireTest +{ + public function __construct(ResetPasswordRequestRepositoryInterface $repository) + { + } +}