Skip to content

Commit 0521e0b

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: fix merge [AssetMapper] Split test dirs in tests Fix typo Change incorrect check for the `stateless` request attribute [Validator] add setGroupProvider to AttributeLoader use copy() instead of rename() on Windows test: kebab-case to snake_case [PropertyInfo] Handle collection in PhpStan same as PhpDoc [Messenger] Passing to `WorkerMessageRetriedEvent` envelope with actual stamps after sent
2 parents 96070c0 + f9f194c commit 0521e0b

27 files changed

+179
-63
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/SecretsDecryptToLocalCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function configure(): void
4444
4545
<info>%command.full_name%</info>
4646
47-
When the option <info>--force</info> is provided, secrets that already exist in the local vault are overriden.
47+
When the <info>--force</info> option is provided, secrets that already exist in the local vault are overridden.
4848
4949
<info>%command.full_name% --force</info>
5050
EOF

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public function searchBarAction(Request $request): Response
174174
$this->cspHandler?->disableCsp();
175175

176176
$session = null;
177-
if ($request->attributes->getBoolean('_stateless') && $request->hasSession()) {
177+
if (!$request->attributes->getBoolean('_stateless') && $request->hasSession()) {
178178
$session = $request->getSession();
179179
}
180180

src/Symfony/Component/AssetMapper/Tests/CompiledAssetMapperConfigReaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ class CompiledAssetMapperConfigReaderTest extends TestCase
2323
protected function setUp(): void
2424
{
2525
$this->filesystem = new Filesystem();
26-
$this->writableRoot = __DIR__.'/../Fixtures/importmaps_for_writing';
27-
if (!file_exists(__DIR__.'/../Fixtures/importmaps_for_writing')) {
26+
$this->writableRoot = __DIR__.'/../Fixtures/compiled_asset_mapper_config_reader';
27+
if (!file_exists(__DIR__.'/../Fixtures/compiled_asset_mapper_config_reader')) {
2828
$this->filesystem->mkdir($this->writableRoot);
2929
}
3030
// realpath to help path comparisons in the tests

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapConfigReaderTest.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,14 @@ class ImportMapConfigReaderTest extends TestCase
2929
protected function setUp(): void
3030
{
3131
$this->filesystem = new Filesystem();
32-
if (!file_exists(__DIR__.'/../Fixtures/importmaps_for_writing')) {
33-
$this->filesystem->mkdir(__DIR__.'/../Fixtures/importmaps_for_writing');
34-
}
35-
if (!file_exists(__DIR__.'/../Fixtures/importmaps_for_writing/assets')) {
36-
$this->filesystem->mkdir(__DIR__.'/../Fixtures/importmaps_for_writing/assets');
32+
if (!file_exists(__DIR__.'/../Fixtures/importmap_config_reader/assets')) {
33+
$this->filesystem->mkdir(__DIR__.'/../Fixtures/importmap_config_reader/assets');
3734
}
3835
}
3936

4037
protected function tearDown(): void
4138
{
42-
$this->filesystem->remove(__DIR__.'/../Fixtures/importmaps_for_writing');
39+
$this->filesystem->remove(__DIR__.'/../Fixtures/importmap_config_reader');
4340
}
4441

4542
public function testGetEntriesAndWriteEntries()
@@ -66,7 +63,7 @@ public function testGetEntriesAndWriteEntries()
6663
],
6764
];
6865
EOF;
69-
file_put_contents(__DIR__.'/../Fixtures/importmaps_for_writing/importmap.php', $importMap);
66+
file_put_contents(__DIR__.'/../Fixtures/importmap_config_reader/importmap.php', $importMap);
7067

7168
$remotePackageStorage = $this->createMock(RemotePackageStorage::class);
7269
$remotePackageStorage->expects($this->any())
@@ -75,7 +72,7 @@ public function testGetEntriesAndWriteEntries()
7572
return '/path/to/vendor/'.$packageModuleSpecifier.'.'.$type->value;
7673
});
7774
$reader = new ImportMapConfigReader(
78-
__DIR__.'/../Fixtures/importmaps_for_writing/importmap.php',
75+
__DIR__.'/../Fixtures/importmap_config_reader/importmap.php',
7976
$remotePackageStorage,
8077
);
8178
$entries = $reader->getEntries();
@@ -103,11 +100,11 @@ public function testGetEntriesAndWriteEntries()
103100
$this->assertSame('package/with_file.js', $packageWithFileEntry->packageModuleSpecifier);
104101

105102
// now save the original raw data from importmap.php and delete the file
106-
$originalImportMapData = (static fn () => include __DIR__.'/../Fixtures/importmaps_for_writing/importmap.php')();
107-
unlink(__DIR__.'/../Fixtures/importmaps_for_writing/importmap.php');
103+
$originalImportMapData = (static fn () => eval('?>'.file_get_contents(__DIR__.'/../Fixtures/importmap_config_reader/importmap.php')))();
104+
unlink(__DIR__.'/../Fixtures/importmap_config_reader/importmap.php');
108105
// dump the entries back to the file
109106
$reader->writeEntries($entries);
110-
$newImportMapData = (static fn () => include __DIR__.'/../Fixtures/importmaps_for_writing/importmap.php')();
107+
$newImportMapData = (static fn () => eval('?>'.file_get_contents(__DIR__.'/../Fixtures/importmap_config_reader/importmap.php')))();
111108

112109
$this->assertSame($originalImportMapData, $newImportMapData);
113110
}

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapGeneratorTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ class ImportMapGeneratorTest extends TestCase
3030
private AssetMapperInterface&MockObject $assetMapper;
3131
private CompiledAssetMapperConfigReader&MockObject $compiledConfigReader;
3232
private ImportMapConfigReader&MockObject $configReader;
33-
private ImportMapGenerator $importMapGenerator;
3433

3534
private Filesystem $filesystem;
36-
private static string $writableRoot = __DIR__.'/../Fixtures/importmaps_for_writing';
35+
private static string $writableRoot = __DIR__.'/../Fixtures/importmap_generator';
3736

3837
protected function setUp(): void
3938
{
@@ -725,7 +724,7 @@ private function createImportMapGenerator(): ImportMapGenerator
725724
return ImportMapEntry::createRemote($importName, $type, $path, $version, $packageModuleSpecifier, $isEntrypoint);
726725
});
727726

728-
return $this->importMapGenerator = new ImportMapGenerator(
727+
return new ImportMapGenerator(
729728
$this->assetMapper,
730729
$this->compiledConfigReader,
731730
$this->configReader,

src/Symfony/Component/AssetMapper/Tests/ImportMap/ImportMapManagerTest.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,14 @@ class ImportMapManagerTest extends TestCase
3232
private PackageResolverInterface&MockObject $packageResolver;
3333
private ImportMapConfigReader&MockObject $configReader;
3434
private RemotePackageDownloader&MockObject $remotePackageDownloader;
35-
private ImportMapManager $importMapManager;
3635

3736
private Filesystem $filesystem;
38-
private static string $writableRoot = __DIR__.'/../Fixtures/importmaps_for_writing';
37+
private static string $writableRoot = __DIR__.'/../Fixtures/importmap_manager';
3938

4039
protected function setUp(): void
4140
{
4241
$this->filesystem = new Filesystem();
43-
if (!file_exists(__DIR__.'/../Fixtures/importmaps_for_writing')) {
44-
$this->filesystem->mkdir(self::$writableRoot);
45-
}
46-
if (!file_exists(__DIR__.'/../Fixtures/importmaps_for_writing/assets')) {
42+
if (!file_exists(__DIR__.'/../Fixtures/importmap_manager/assets')) {
4743
$this->filesystem->mkdir(self::$writableRoot.'/assets');
4844
}
4945
}
@@ -386,7 +382,7 @@ private function createImportMapManager(): ImportMapManager
386382
return ImportMapEntry::createRemote($importName, $type, $path, $version, $packageModuleSpecifier, $isEntrypoint);
387383
});
388384

389-
return $this->importMapManager = new ImportMapManager(
385+
return new ImportMapManager(
390386
$this->assetMapper,
391387
$this->configReader,
392388
$this->remotePackageDownloader,

src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageDownloaderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class RemotePackageDownloaderTest extends TestCase
2525
{
2626
private Filesystem $filesystem;
27-
private static string $writableRoot = __DIR__.'/../Fixtures/importmaps_for_writing';
27+
private static string $writableRoot = __DIR__.'/../Fixtures/remote_package_downloader';
2828

2929
protected function setUp(): void
3030
{

src/Symfony/Component/AssetMapper/Tests/ImportMap/RemotePackageStorageTest.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
class RemotePackageStorageTest extends TestCase
2121
{
2222
private Filesystem $filesystem;
23-
private static string $writableRoot = __DIR__.'/../Fixtures/importmaps_for_writing';
23+
private static string $writableRoot;
24+
private static int $writableRootIndex = 0;
2425

2526
protected function setUp(): void
2627
{
28+
self::$writableRoot = sys_get_temp_dir().'/remote_package_storage'.++self::$writableRootIndex;
2729
$this->filesystem = new Filesystem();
28-
if (!$this->filesystem->exists(self::$writableRoot)) {
29-
$this->filesystem->mkdir(self::$writableRoot);
30-
}
30+
$this->filesystem->mkdir(self::$writableRoot);
3131
}
3232

3333
protected function tearDown(): void
@@ -41,19 +41,24 @@ public function testGetStorageDir()
4141
$this->assertSame(realpath(self::$writableRoot.'/assets/vendor'), realpath($storage->getStorageDir()));
4242
}
4343

44-
public function testSaveThrowsWhenVendorDirectoryIsNotWritable()
44+
public function testSaveThrowsWhenFailing()
4545
{
46-
$this->filesystem->mkdir($vendorDir = self::$writableRoot.'/assets/acme/vendor');
47-
$this->filesystem->chmod($vendorDir, 0555);
46+
$vendorDir = self::$writableRoot.'/assets/acme/vendor';
47+
$this->filesystem->mkdir($vendorDir.'/module_specifier');
48+
$this->filesystem->touch($vendorDir.'/module_specifier/module_specifier.index.js');
49+
$this->filesystem->chmod($vendorDir.'/module_specifier/module_specifier.index.js', 0555);
4850

4951
$storage = new RemotePackageStorage($vendorDir);
5052
$entry = ImportMapEntry::createRemote('foo', ImportMapType::JS, '/does/not/matter', '1.0.0', 'module_specifier', false);
5153

5254
$this->expectException(\RuntimeException::class);
53-
$this->expectExceptionMessage('file_put_contents('.$vendorDir.'/module_specifier/module_specifier.index.js): Failed to open stream: No such file or directory');
54-
$storage->save($entry, 'any content');
55+
$this->expectExceptionMessage('file_put_contents('.$vendorDir.'/module_specifier/module_specifier.index.js): Failed to open stream: Permission denied');
5556

56-
$this->filesystem->remove($vendorDir);
57+
try {
58+
$storage->save($entry, 'any content');
59+
} finally {
60+
$this->filesystem->chmod($vendorDir.'/module_specifier/module_specifier.index.js', 0777);
61+
}
5762
}
5863

5964
public function testIsDownloaded()
@@ -106,33 +111,33 @@ public function testSaveExtraFile()
106111
public function testGetDownloadedPath(string $packageModuleSpecifier, ImportMapType $importMapType, string $expectedPath)
107112
{
108113
$storage = new RemotePackageStorage(self::$writableRoot.'/assets/vendor');
109-
$this->assertSame($expectedPath, $storage->getDownloadPath($packageModuleSpecifier, $importMapType));
114+
$this->assertSame(self::$writableRoot.$expectedPath, $storage->getDownloadPath($packageModuleSpecifier, $importMapType));
110115
}
111116

112117
public static function getDownloadPathTests(): iterable
113118
{
114119
yield 'javascript bare package' => [
115120
'packageModuleSpecifier' => 'foo',
116121
'importMapType' => ImportMapType::JS,
117-
'expectedPath' => self::$writableRoot.'/assets/vendor/foo/foo.index.js',
122+
'expectedPath' => '/assets/vendor/foo/foo.index.js',
118123
];
119124

120125
yield 'javascript package with path' => [
121126
'packageModuleSpecifier' => 'foo/bar',
122127
'importMapType' => ImportMapType::JS,
123-
'expectedPath' => self::$writableRoot.'/assets/vendor/foo/bar.js',
128+
'expectedPath' => '/assets/vendor/foo/bar.js',
124129
];
125130

126131
yield 'javascript package with path and extension' => [
127132
'packageModuleSpecifier' => 'foo/bar.js',
128133
'importMapType' => ImportMapType::JS,
129-
'expectedPath' => self::$writableRoot.'/assets/vendor/foo/bar.js',
134+
'expectedPath' => '/assets/vendor/foo/bar.js',
130135
];
131136

132137
yield 'CSS package with path' => [
133138
'packageModuleSpecifier' => 'foo/bar',
134139
'importMapType' => ImportMapType::CSS,
135-
'expectedPath' => self::$writableRoot.'/assets/vendor/foo/bar.css',
140+
'expectedPath' => '/assets/vendor/foo/bar.css',
136141
];
137142
}
138143
}

src/Symfony/Component/AssetMapper/Tests/MapperAwareAssetPackageIntegrationTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,31 @@
1111

1212
namespace Symfony\Component\AssetMapper\Tests;
1313

14-
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
14+
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Packages;
1616
use Symfony\Component\AssetMapper\Tests\Fixtures\AssetMapperTestAppKernel;
17+
use Symfony\Component\Filesystem\Filesystem;
1718

18-
class MapperAwareAssetPackageIntegrationTest extends KernelTestCase
19+
class MapperAwareAssetPackageIntegrationTest extends TestCase
1920
{
20-
public function testDefaultAssetPackageIsDecorated()
21+
private AssetMapperTestAppKernel $kernel;
22+
private Filesystem $filesystem;
23+
24+
protected function setUp(): void
25+
{
26+
$this->filesystem = new Filesystem();
27+
$this->kernel = new AssetMapperTestAppKernel('test', true);
28+
$this->kernel->boot();
29+
}
30+
31+
protected function tearDown(): void
2132
{
22-
$kernel = new AssetMapperTestAppKernel('test', true);
23-
$kernel->boot();
33+
$this->filesystem->remove($this->kernel->getProjectDir().'/var');
34+
}
2435

25-
$packages = $kernel->getContainer()->get('public.assets.packages');
36+
public function testDefaultAssetPackageIsDecorated()
37+
{
38+
$packages = $this->kernel->getContainer()->get('public.assets.packages');
2639
\assert($packages instanceof Packages);
2740
$this->assertSame('/assets/file1-b3445cb7a86a0795a7af7f2004498aef.css', $packages->getUrl('file1.css'));
2841
$this->assertSame('/non-existent.css', $packages->getUrl('non-existent.css'));

src/Symfony/Component/AssetMapper/Tests/Path/LocalPublicAssetsFilesystemTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
class LocalPublicAssetsFilesystemTest extends TestCase
1919
{
2020
private Filesystem $filesystem;
21-
private static string $writableRoot = __DIR__.'/../Fixtures/importmaps_for_writing';
21+
private static string $writableRoot = __DIR__.'/../Fixtures/local_public_assets_filesystem';
2222

2323
protected function setUp(): void
2424
{
2525
$this->filesystem = new Filesystem();
26-
if (!file_exists(__DIR__.'/../Fixtures/importmaps_for_writing')) {
26+
if (!file_exists(__DIR__.'/../Fixtures/local_public_assets_filesystem')) {
2727
$this->filesystem->mkdir(self::$writableRoot);
2828
}
2929
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy