+ */
+ private function searchAssets(?string $name, ?string $extension, ?bool $vendor): array
+ {
$rows = [];
- foreach ($allAssets as $asset) {
+ foreach ($this->assetMapper->allAssets() as $asset) {
+ if ($extension && $extension !== $asset->publicExtension) {
+ continue;
+ }
+ if (null !== $vendor && $vendor !== $asset->isVendor) {
+ continue;
+ }
+ if ($name && !str_contains($asset->logicalPath, $name) && !str_contains($asset->sourcePath, $name)) {
+ continue;
+ }
+
$logicalPath = $asset->logicalPath;
$sourcePath = $this->relativizePath($asset->sourcePath);
- if (!$input->getOption('full')) {
- $logicalPath = $this->shortenPath($logicalPath);
- $sourcePath = $this->shortenPath($sourcePath);
- }
-
$rows[] = [
$logicalPath,
$sourcePath,
];
}
- $io->section('Mapped Assets');
- $io->table(['Logical Path', 'Filesystem Path'], $rows);
-
- if ($this->didShortenPaths) {
- $io->note('To see the full paths, re-run with the --full option.');
- }
- return 0;
+ return $rows;
}
private function relativizePath(string $path): string
diff --git a/src/Symfony/Component/AssetMapper/Tests/Command/DebugAssetsMapperCommandTest.php b/src/Symfony/Component/AssetMapper/Tests/Command/DebugAssetsMapperCommandTest.php
index 5d2530004096c..03fe35450a085 100644
--- a/src/Symfony/Component/AssetMapper/Tests/Command/DebugAssetsMapperCommandTest.php
+++ b/src/Symfony/Component/AssetMapper/Tests/Command/DebugAssetsMapperCommandTest.php
@@ -31,4 +31,57 @@ public function testCommandDumpsInformation()
$this->assertStringContainsString('subdir/file6.js', $tester->getDisplay());
$this->assertStringContainsString('dir2'.\DIRECTORY_SEPARATOR.'subdir'.\DIRECTORY_SEPARATOR.'file6.js', $tester->getDisplay());
}
+
+ public function testCommandFiltersName()
+ {
+ $application = new Application(new AssetMapperTestAppKernel('test', true));
+ $command = $application->find('debug:asset-map');
+ $tester = new CommandTester($command);
+ $res = $tester->execute(['name' => 'stimulus']);
+
+ $this->assertSame(0, $res);
+ $this->assertStringContainsString('stimulus', $tester->getDisplay());
+ $this->assertStringNotContainsString('lodash', $tester->getDisplay());
+
+ $res = $tester->execute(['name' => 'lodash']);
+ $this->assertSame(0, $res);
+ $this->assertStringNotContainsString('stimulus', $tester->getDisplay());
+ $this->assertStringContainsString('lodash', $tester->getDisplay());
+ }
+
+ public function testCommandFiltersExtension()
+ {
+ $application = new Application(new AssetMapperTestAppKernel('test', true));
+ $command = $application->find('debug:asset-map');
+ $tester = new CommandTester($command);
+ $res = $tester->execute(['--ext' => 'css']);
+
+ $this->assertSame(0, $res);
+ $this->assertStringNotContainsString('.js', $tester->getDisplay());
+
+ $this->assertStringContainsString('file1.css', $tester->getDisplay());
+ $this->assertStringContainsString('file3.css', $tester->getDisplay());
+ }
+
+ public function testCommandFiltersVendor()
+ {
+ $application = new Application(new AssetMapperTestAppKernel('test', true));
+ $command = $application->find('debug:asset-map');
+
+ $tester = new CommandTester($command);
+ $res = $tester->execute(['--vendor' => true]);
+
+ $this->assertSame(0, $res);
+ $this->assertStringContainsString('vendor/lodash/', $tester->getDisplay());
+ $this->assertStringContainsString('@hotwired/stimulus', $tester->getDisplay());
+ $this->assertStringNotContainsString('dir2'.\DIRECTORY_SEPARATOR, $tester->getDisplay());
+
+ $tester = new CommandTester($command);
+ $res = $tester->execute(['--no-vendor' => true]);
+
+ $this->assertSame(0, $res);
+ $this->assertStringNotContainsString('vendor/lodash/', $tester->getDisplay());
+ $this->assertStringNotContainsString('@hotwired/stimulus', $tester->getDisplay());
+ $this->assertStringContainsString('dir2'.\DIRECTORY_SEPARATOR, $tester->getDisplay());
+ }
}
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