Skip to content

Commit 71fffd9

Browse files
committed
Merge branch '7.3' into 7.4
* 7.3: fix merge do not use PHPUnit mock objects without configured expectations fix low deps test with Console component < 6.4 [FrameworkBundle] Check for console package before register `CommandDataCollector` do not use PHPUnit mock objects without configured expectations [FrameworkBundle] Ensure a fresh container is used after cache warmup in KernelTestCase do not use PHPUnit mock objects without configured expectations do not use PHPUnit mock objects without configured expectations [Finder] Fix `Finder::append()` breaking generic typing contract
2 parents b98c66e + b6cfc86 commit 71fffd9

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,7 +1082,7 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
10821082
$container->removeDefinition('console_profiler_listener');
10831083
}
10841084

1085-
if (!class_exists(CommandDataCollector::class)) {
1085+
if (!$this->hasConsole() || !class_exists(CommandDataCollector::class)) {
10861086
$container->removeDefinition('.data_collector.command');
10871087
}
10881088
}

Test/KernelTestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ protected static function bootKernel(array $options = []): KernelInterface
7676
static::$kernel = $kernel;
7777
static::$booted = true;
7878

79+
// If the cache warmer is registered, it means that the cache has been
80+
// warmed up, so the current container is not fresh anymore. Let's
81+
// reboot a fresh one.
82+
if (self::getContainer()->initialized('cache_warmer')) {
83+
static::ensureKernelShutdown();
84+
85+
$kernel = static::createKernel($options);
86+
$kernel->boot();
87+
static::$kernel = $kernel;
88+
static::$booted = true;
89+
}
90+
7991
return static::$kernel;
8092
}
8193

Tests/DependencyInjection/FrameworkExtensionTestCase.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ public function testEnabledProfiler()
301301

302302
$this->assertTrue($container->hasDefinition('profiler'), '->registerProfilerConfiguration() loads profiling.xml');
303303
$this->assertTrue($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() loads collectors.xml');
304+
$this->assertTrue($container->hasDefinition('.data_collector.command'));
304305
}
305306

306307
public function testDisabledProfiler()
@@ -311,6 +312,26 @@ public function testDisabledProfiler()
311312
$this->assertFalse($container->hasDefinition('data_collector.config'), '->registerProfilerConfiguration() does not load collectors.xml');
312313
}
313314

315+
public function testProfilerWithoutConsole()
316+
{
317+
$extension = new class extends FrameworkExtension {
318+
protected function hasConsole(): bool
319+
{
320+
return false;
321+
}
322+
323+
public function getAlias(): string
324+
{
325+
return 'framework';
326+
}
327+
};
328+
329+
$container = $this->createContainerFromFile('profiler', [], true, false, $extension);
330+
$container->compile();
331+
332+
$this->assertFalse($container->hasDefinition('.data_collector.command'));
333+
}
334+
314335
public function testProfilerCollectSerializerDataEnabled()
315336
{
316337
$container = $this->createContainerFromFile('profiler');

Tests/Functional/TestServiceContainerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@ class TestServiceContainerTest extends AbstractWebTestCase
2424
{
2525
public function testLogicExceptionIfTestConfigIsDisabled()
2626
{
27-
static::bootKernel(['test_case' => 'TestServiceContainer', 'root_config' => 'test_disabled.yml', 'environment' => 'test_disabled']);
28-
2927
$this->expectException(\LogicException::class);
3028

31-
static::getContainer();
29+
static::bootKernel(['test_case' => 'TestServiceContainer', 'root_config' => 'test_disabled.yml', 'environment' => 'test_disabled']);
3230
}
3331

3432
public function testThatPrivateServicesAreAvailableIfTestConfigIsEnabled()

0 commit comments

Comments
 (0)