-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for autowiring ResetPasswordRequestRepositoryInterface
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]> | ||
|
@@ -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']); | ||
|
44 changes: 44 additions & 0 deletions
44
tests/IntegrationTests/ResetPasswordRequestRepositoryInterfaceAutowireTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
} | ||
} |