Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 93b831b

Browse files
committed
minor #17497 [SecurityBundle] Optimize dependency injection tests (paradajozsef)
This PR was squashed before being merged into the 2.3 branch (closes #17497). Discussion ---------- [SecurityBundle] Optimize dependency injection tests | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17366 | License | MIT | Doc PR | - Tests building the same container multiple times. The same solution can be applied as here: #17399. This time I ran comparison tests only on 2.3. (my laptop is really slow) **2.3 before** ```go Time: 14.79 seconds, Memory: 48.25Mb OK (77 tests, 227 assertions) OK src/Symfony/Bundle/SecurityBundle/ ``` **2.3 after** ```go Time: 9.78 seconds, Memory: 48.75Mb OK (77 tests, 227 assertions) OK src/Symfony/Bundle/SecurityBundle/ ``` Commits ------- bf56d2f [SecurityBundle] Optimize dependency injection tests
2 parents 9a90cde + bf56d2f commit 93b831b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919

2020
abstract class CompleteConfigurationTest extends \PHPUnit_Framework_TestCase
2121
{
22+
private static $containerCache = array();
23+
2224
abstract protected function loadFromFile(ContainerBuilder $container, $file);
2325

2426
public function testRolesHierarchy()
@@ -182,6 +184,9 @@ public function testCustomAclProvider()
182184

183185
protected function getContainer($file)
184186
{
187+
if (isset(self::$containerCache[$file])) {
188+
return self::$containerCache[$file];
189+
}
185190
$container = new ContainerBuilder();
186191
$security = new SecurityExtension();
187192
$container->registerExtension($security);
@@ -194,6 +199,6 @@ protected function getContainer($file)
194199
$container->getCompilerPassConfig()->setRemovingPasses(array());
195200
$container->compile();
196201

197-
return $container;
202+
return self::$containerCache[$file] = $container;
198203
}
199204
}

0 commit comments

Comments
 (0)