Skip to content

Commit

Permalink
Add support for autowiring ResetPasswordRequestRepositoryInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
mbabker committed Mar 6, 2024
1 parent 598fc74 commit 0771472
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
Expand All @@ -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']);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* This file is part of the SymfonyCasts ResetPasswordBundle package.
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
* 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)
{
}
}

0 comments on commit 0771472

Please sign in to comment.