Skip to content

Commit ac127ca

Browse files
committed
Merge branch '4.4' into 5.2
* 4.4: skip intl dependent tests if the extension is missing make DateCaster tests timezone-agnostic error if the input string couldn't be parsed as a date IntegerType: Always use en for IntegerToLocalizedStringTransformer Fixes #40456 Uses the correct assignment action for console options depending if they are short or long [HttpKernel] ConfigDataCollector to return known data without the need of a Kernel [HttpClient] fix using stream_copy_to_stream() with responses cast to php streams FIx Trying to clone an uncloneable object of class
2 parents 84d3b1a + cf71f2a commit ac127ca

File tree

2 files changed

+43
-9
lines changed

2 files changed

+43
-9
lines changed

DataCollector/ConfigDataCollector.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,17 @@ public function setKernel(KernelInterface $kernel = null)
4242
*/
4343
public function collect(Request $request, Response $response, \Throwable $exception = null)
4444
{
45+
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
46+
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
47+
4548
$this->data = [
4649
'token' => $response->headers->get('X-Debug-Token'),
4750
'symfony_version' => Kernel::VERSION,
48-
'symfony_state' => 'unknown',
51+
'symfony_minor_version' => sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION),
52+
'symfony_lts' => 4 === Kernel::MINOR_VERSION,
53+
'symfony_state' => $this->determineSymfonyState(),
54+
'symfony_eom' => $eom->format('F Y'),
55+
'symfony_eol' => $eol->format('F Y'),
4956
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
5057
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
5158
'php_version' => \PHP_VERSION,
@@ -63,14 +70,6 @@ public function collect(Request $request, Response $response, \Throwable $except
6370
foreach ($this->kernel->getBundles() as $name => $bundle) {
6471
$this->data['bundles'][$name] = new ClassStub(\get_class($bundle));
6572
}
66-
67-
$this->data['symfony_state'] = $this->determineSymfonyState();
68-
$this->data['symfony_minor_version'] = sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION);
69-
$this->data['symfony_lts'] = 4 === Kernel::MINOR_VERSION;
70-
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
71-
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
72-
$this->data['symfony_eom'] = $eom->format('F Y');
73-
$this->data['symfony_eol'] = $eol->format('F Y');
7473
}
7574

7675
if (preg_match('~^(\d+(?:\.\d+)*)(.+)?$~', $this->data['php_version'], $matches) && isset($matches[2])) {

Tests/DataCollector/ConfigDataCollectorTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,41 @@ public function testCollect()
4141
$this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
4242
$this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache());
4343
$this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu());
44+
$this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion());
45+
$this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']);
46+
47+
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y');
48+
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->format('F Y');
49+
$this->assertSame($eom, $c->getSymfonyEom());
50+
$this->assertSame($eol, $c->getSymfonyEol());
51+
}
52+
53+
public function testCollectWithoutKernel()
54+
{
55+
$c = new ConfigDataCollector();
56+
$c->collect(new Request(), new Response());
57+
58+
$this->assertSame('n/a', $c->getEnv());
59+
$this->assertSame('n/a', $c->isDebug());
60+
$this->assertSame('config', $c->getName());
61+
$this->assertMatchesRegularExpression('~^'.preg_quote($c->getPhpVersion(), '~').'~', \PHP_VERSION);
62+
$this->assertMatchesRegularExpression('~'.preg_quote((string) $c->getPhpVersionExtra(), '~').'$~', \PHP_VERSION);
63+
$this->assertSame(\PHP_INT_SIZE * 8, $c->getPhpArchitecture());
64+
$this->assertSame(class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a', $c->getPhpIntlLocale());
65+
$this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());
66+
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
67+
$this->assertSame(4 === Kernel::MINOR_VERSION, $c->isSymfonyLts());
68+
$this->assertNull($c->getToken());
69+
$this->assertSame(\extension_loaded('xdebug'), $c->hasXDebug());
70+
$this->assertSame(\extension_loaded('Zend OPcache') && filter_var(ini_get('opcache.enable'), \FILTER_VALIDATE_BOOLEAN), $c->hasZendOpcache());
71+
$this->assertSame(\extension_loaded('apcu') && filter_var(ini_get('apc.enabled'), \FILTER_VALIDATE_BOOLEAN), $c->hasApcu());
72+
$this->assertSame(sprintf('%s.%s', Kernel::MAJOR_VERSION, Kernel::MINOR_VERSION), $c->getSymfonyMinorVersion());
73+
$this->assertContains($c->getSymfonyState(), ['eol', 'eom', 'dev', 'stable']);
74+
75+
$eom = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE)->format('F Y');
76+
$eol = \DateTime::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE)->format('F Y');
77+
$this->assertSame($eom, $c->getSymfonyEom());
78+
$this->assertSame($eol, $c->getSymfonyEol());
4479
}
4580
}
4681

0 commit comments

Comments
 (0)