Skip to content

Commit 8a4e118

Browse files
authored
Merge pull request #79 from jrushlow/fix/fake-repo-ns
fixed incorrect fake repo namespace
2 parents 54ce2b1 + b4c0410 commit 8a4e118

File tree

2 files changed

+83
-1
lines changed

2 files changed

+83
-1
lines changed

src/Resources/config/reset_password_services.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
66

77
<services>
8-
<service id="symfonycasts.reset_password.fake_request_repository" class="SymfonyCasts\Bundle\ResetPassword\Persistence\FakeInternalRepository" public="false"/>
8+
<service id="symfonycasts.reset_password.fake_request_repository" class="SymfonyCasts\Bundle\ResetPassword\Persistence\Fake\FakeResetPasswordInternalRepository" public="false"/>
99
<service id="symfonycasts.reset_password.cleaner" class="SymfonyCasts\Bundle\ResetPassword\Util\ResetPasswordCleaner" public="false">
1010
<argument /> <!-- reset password request persister -->
1111
<argument /> <!-- reset password request enable_garbage_collection -->
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the SymfonyCasts ResetPasswordBundle package.
5+
* Copyright (c) SymfonyCasts <https://symfonycasts.com/>
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
10+
namespace SymfonyCasts\Bundle\ResetPassword\Tests\IntegrationTests;
11+
12+
use PHPUnit\Framework\TestCase;
13+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
14+
use Symfony\Component\DependencyInjection\ContainerBuilder;
15+
use SymfonyCasts\Bundle\ResetPassword\Tests\Fixtures\AbstractResetPasswordTestKernel;
16+
17+
/**
18+
* @author Jesse Rushlow <[email protected]>
19+
* @author Ryan Weaver <[email protected]>
20+
*/
21+
final class ResetPasswordServiceDefinitionTest extends TestCase
22+
{
23+
public function bundleServiceDefinitionDataProvider(): \Generator
24+
{
25+
$prefix = 'symfonycasts.reset_password.';
26+
27+
yield [$prefix.'fake_request_repository'];
28+
yield [$prefix.'cleaner'];
29+
yield [$prefix.'random_generator'];
30+
yield [$prefix.'token_generator'];
31+
yield [$prefix.'helper'];
32+
yield ['SymfonyCasts\Bundle\ResetPassword\Command\ResetPasswordRemoveExpiredCommand'];
33+
}
34+
35+
/**
36+
* @dataProvider bundleServiceDefinitionDataProvider
37+
*/
38+
public function testBundleServiceDefinitions(string $definition): void
39+
{
40+
// Make private reset-password-bundle services public
41+
$pass = new DefinitionPublicCompilerPass();
42+
$pass->definition = $definition;
43+
44+
$kernel = new ResetPasswordDefinitionTestKernel();
45+
$kernel->compilerPass = $pass;
46+
$kernel->boot();
47+
48+
$container = $kernel->getContainer();
49+
$container->get($definition);
50+
51+
// If a service is not correctly defined, i.e. wrong class namespace, an exception will be thrown.
52+
$this->expectNotToPerformAssertions();
53+
}
54+
}
55+
56+
/**
57+
* @internal
58+
*/
59+
final class DefinitionPublicCompilerPass implements CompilerPassInterface
60+
{
61+
public $definition;
62+
63+
public function process(ContainerBuilder $container)
64+
{
65+
$container->getDefinition($this->definition)
66+
->setPublic(true)
67+
;
68+
}
69+
}
70+
71+
/**
72+
* @internal
73+
*/
74+
final class ResetPasswordDefinitionTestKernel extends AbstractResetPasswordTestKernel
75+
{
76+
public $compilerPass;
77+
78+
protected function build(ContainerBuilder $container)
79+
{
80+
$container->addCompilerPass($this->compilerPass);
81+
}
82+
}

0 commit comments

Comments
 (0)