Skip to content

Commit b7b69d5

Browse files
Merge branch '4.4' into 5.2
* 4.4: [Console] ProgressBar clears too many lines on update [FrameworkBundle] Exclude unreadable files when executing About command [Bridge\Twig] Add 'form-control-range' for range input type Be explicit about transparent background color of links in toolbar [Translation] fix test case name [Cache] Fix wrong namespace in test [DependencyInjection] Fix return type
2 parents d9fea1c + beefe46 commit b7b69d5

File tree

4 files changed

+134
-2
lines changed

4 files changed

+134
-2
lines changed

Command/AboutCommand.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ private static function formatFileSize(string $path): string
113113
} else {
114114
$size = 0;
115115
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \RecursiveDirectoryIterator::SKIP_DOTS | \RecursiveDirectoryIterator::FOLLOW_SYMLINKS)) as $file) {
116-
$size += $file->getSize();
116+
if ($file->isReadable()) {
117+
$size += $file->getSize();
118+
}
117119
}
118120
}
119121

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\AboutCommand;
13+
14+
use Symfony\Bundle\FrameworkBundle\Command\AboutCommand;
15+
use Symfony\Bundle\FrameworkBundle\Console\Application;
16+
use Symfony\Bundle\FrameworkBundle\Tests\Command\AboutCommand\Fixture\TestAppKernel;
17+
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
18+
use Symfony\Component\Console\Tester\CommandTester;
19+
use Symfony\Component\Filesystem\Exception\IOException;
20+
use Symfony\Component\Filesystem\Filesystem;
21+
22+
class AboutCommandTest extends TestCase
23+
{
24+
/** @var Filesystem */
25+
private $fs;
26+
27+
protected function setUp(): void
28+
{
29+
$this->fs = new Filesystem();
30+
}
31+
32+
public function testAboutWithReadableFiles()
33+
{
34+
$kernel = new TestAppKernel('test', true);
35+
$this->fs->mkdir($kernel->getProjectDir());
36+
37+
$this->fs->dumpFile($kernel->getCacheDir().'/readable_file', 'The file content.');
38+
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0777);
39+
40+
$tester = $this->createCommandTester($kernel);
41+
$ret = $tester->execute([]);
42+
43+
$this->assertSame(0, $ret);
44+
$this->assertStringContainsString('Cache directory', $tester->getDisplay());
45+
$this->assertStringContainsString('Log directory', $tester->getDisplay());
46+
47+
$this->fs->chmod($kernel->getCacheDir().'/readable_file', 0777);
48+
49+
try {
50+
$this->fs->remove($kernel->getProjectDir());
51+
} catch (IOException $e) {
52+
}
53+
}
54+
55+
public function testAboutWithUnreadableFiles()
56+
{
57+
$kernel = new TestAppKernel('test', true);
58+
$this->fs->mkdir($kernel->getProjectDir());
59+
60+
// skip test on Windows; PHP can't easily set file as unreadable on Windows
61+
if ('\\' === \DIRECTORY_SEPARATOR) {
62+
$this->markTestSkipped('This test cannot run on Windows.');
63+
}
64+
65+
$this->fs->dumpFile($kernel->getCacheDir().'/unreadable_file', 'The file content.');
66+
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0222);
67+
68+
$tester = $this->createCommandTester($kernel);
69+
$ret = $tester->execute([]);
70+
71+
$this->assertSame(0, $ret);
72+
$this->assertStringContainsString('Cache directory', $tester->getDisplay());
73+
$this->assertStringContainsString('Log directory', $tester->getDisplay());
74+
75+
$this->fs->chmod($kernel->getCacheDir().'/unreadable_file', 0777);
76+
77+
try {
78+
$this->fs->remove($kernel->getProjectDir());
79+
} catch (IOException $e) {
80+
}
81+
}
82+
83+
private function createCommandTester(TestAppKernel $kernel): CommandTester
84+
{
85+
$application = new Application($kernel);
86+
$application->add(new AboutCommand());
87+
88+
return new CommandTester($application->find('about'));
89+
}
90+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\AboutCommand\Fixture;
13+
14+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
15+
use Symfony\Component\Config\Loader\LoaderInterface;
16+
use Symfony\Component\DependencyInjection\ContainerBuilder;
17+
use Symfony\Component\HttpKernel\Kernel;
18+
19+
class TestAppKernel extends Kernel
20+
{
21+
public function registerBundles(): iterable
22+
{
23+
return [
24+
new FrameworkBundle(),
25+
];
26+
}
27+
28+
public function getProjectDir(): string
29+
{
30+
return __DIR__.'/test';
31+
}
32+
33+
public function registerContainerConfiguration(LoaderInterface $loader)
34+
{
35+
}
36+
37+
protected function build(ContainerBuilder $container)
38+
{
39+
}
40+
}

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1696,7 +1696,7 @@ protected function createContainerFromFile($file, $data = [], $resetCompilerPass
16961696
$container->getCompilerPassConfig()->setAfterRemovingPasses([]);
16971697
}
16981698
$container->getCompilerPassConfig()->setBeforeOptimizationPasses([new LoggerPass()]);
1699-
$container->getCompilerPassConfig()->setBeforeRemovingPasses([new AddConstraintValidatorsPass(), new TranslatorPass('translator.default', 'translation.reader')]);
1699+
$container->getCompilerPassConfig()->setBeforeRemovingPasses([new AddConstraintValidatorsPass(), new TranslatorPass()]);
17001700
$container->getCompilerPassConfig()->setAfterRemovingPasses([new AddAnnotationsCachedReaderPass()]);
17011701

17021702
if (!$compile) {

0 commit comments

Comments
 (0)