Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 88c7ef6

Browse filesBrowse files
committed
Functional test for pipeline dev server
1 parent f64e5d3 commit 88c7ef6
Copy full SHA for 88c7ef6
Expand file treeCollapse file tree

12 files changed

+88
-11
lines changed

‎src/Symfony/Component/Asset/Pipeline/AssetPipelineDevServerSubscriber.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Pipeline/AssetPipelineDevServerSubscriber.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function onKernelRequest(RequestEvent $event): void
4242
throw new NotFoundHttpException(sprintf('Asset "%s" not found.', $assetPath));
4343
}
4444

45-
if ($this->assetPipeline->getDigest($asset->getLogicalPath()) === $digest) {
45+
if ($this->assetPipeline->getDigest($asset->getLogicalPath()) !== $digest) {
4646
throw new NotFoundHttpException(sprintf('Asset "%s" was found but the digest does not match.', $assetPath));
4747
}
4848

@@ -75,6 +75,10 @@ private function extractAssetPathAndDigest(string $fullPath): array
7575
$fullPath = substr($fullPath, \strlen($this->assetPipeline->getPublicPrefix()));
7676
preg_match('/-([0-9a-zA-Z]{7,128}(?:\.digested)?)\.[^.]+\z/', $fullPath, $matches);
7777
$digest = $matches[1] ?? null;
78+
// check for pre-digested assets
79+
if (str_ends_with($digest, '.digested')) {
80+
$digest = null;
81+
}
7882
$path = $digest ? str_replace("-{$digest}", '', $fullPath) : $fullPath;
7983

8084
return [$path, $digest];

‎src/Symfony/Component/Asset/Tests/Pipeline/AssetPipelineCompilerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/AssetPipelineCompilerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline;
12+
namespace Symfony\Component\Asset\Tests\Pipeline;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Pipeline\AssetCompilerInterface;
+72Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
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 Pipeline;
13+
14+
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
15+
use Symfony\Component\Asset\Tests\fixtures\pipeline\PipelineTestAppKernel;
16+
17+
class AssetPipelineDevServerSubscriberFunctionalTest extends WebTestCase
18+
{
19+
public function testGettingAssetWorks(): void
20+
{
21+
$client = static::createClient();
22+
23+
$client->request('GET', '/assets/file1-b3445cb7a86a0795a7af7f2004498aef.css');
24+
$response = $client->getResponse();
25+
$this->assertSame(200, $response->getStatusCode());
26+
$this->assertSame(<<<EOF
27+
/* file1.css */
28+
body {}
29+
30+
EOF, $response->getContent());
31+
$this->assertSame('"b3445cb7a86a0795a7af7f2004498aef"', $response->headers->get('ETag'));
32+
$this->assertSame('immutable, public, s-maxage=604800', $response->headers->get('Cache-Control'));
33+
}
34+
35+
public function test404OnUnknownAsset(): void
36+
{
37+
$client = static::createClient();
38+
39+
$client->request('GET', '/assets/unknown.css');
40+
$response = $client->getResponse();
41+
$this->assertSame(404, $response->getStatusCode());
42+
}
43+
44+
public function test404OnInvalidDigest(): void
45+
{
46+
$client = static::createClient();
47+
48+
$client->request('GET', '/assets/file1-fakedigest.css');
49+
$response = $client->getResponse();
50+
$this->assertSame(404, $response->getStatusCode());
51+
$this->assertStringContainsString('Asset &quot;file1.css&quot; was found but the digest does not match.', $response->getContent());
52+
}
53+
54+
public function testPreDigestedAssetIsReturned(): void
55+
{
56+
$client = static::createClient();
57+
58+
$client->request('GET', '/assets/already-abcdefVWXYZ0123456789.digested.css');
59+
$response = $client->getResponse();
60+
$this->assertSame(200, $response->getStatusCode());
61+
$this->assertSame(<<<EOF
62+
/* already-abcdefVWXYZ0123456789.digested.css */
63+
body {}
64+
65+
EOF, $response->getContent());
66+
}
67+
68+
protected static function getKernelClass(): string
69+
{
70+
return PipelineTestAppKernel::class;
71+
}
72+
}

‎src/Symfony/Component/Asset/Tests/Pipeline/AssetPipelineRepositoryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/AssetPipelineRepositoryTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline;
12+
namespace Symfony\Component\Asset\Tests\Pipeline;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Pipeline\AssetPipelineRepository;

‎src/Symfony/Component/Asset/Tests/Pipeline/AssetPipelineTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/AssetPipelineTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Pipeline;
3+
namespace Symfony\Component\Asset\Tests\Pipeline;
44

55
use Symfony\Bundle\TwigBundle\Tests\TestCase;
66
use Symfony\Component\Asset\Pipeline\AssetCompilerInterface;

‎src/Symfony/Component/Asset/Tests/Pipeline/Compiler/AssetCompilerPathResolverTraitTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/Compiler/AssetCompilerPathResolverTraitTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline\Compiler;
12+
namespace Symfony\Component\Asset\Tests\Pipeline\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Exception\RuntimeException;

‎src/Symfony/Component/Asset/Tests/Pipeline/Compiler/JavaScriptImportPathCompilerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/Compiler/JavaScriptImportPathCompilerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline\Compiler;
12+
namespace Symfony\Component\Asset\Tests\Pipeline\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Exception\RuntimeException;

‎src/Symfony/Component/Asset/Tests/Pipeline/Compiler/SourceMappingUrlsCompilerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/Compiler/SourceMappingUrlsCompilerTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline\Compiler;
12+
namespace Symfony\Component\Asset\Tests\Pipeline\Compiler;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Pipeline\AssetPipeline;

‎src/Symfony/Component/Asset/Tests/Pipeline/PipelineAwareAssetPackageIntegrationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/PipelineAwareAssetPackageIntegrationTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Pipeline;
3+
namespace Symfony\Component\Asset\Tests\Pipeline;
44

55
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
66
use Symfony\Component\Asset\Packages;

‎src/Symfony/Component/Asset/Tests/Pipeline/PipelineAwareAssetPackageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/PipelineAwareAssetPackageTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline;
12+
namespace Symfony\Component\Asset\Tests\Pipeline;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\PackageInterface;

‎src/Symfony/Component/Asset/Tests/Pipeline/PipelinedAssetTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/Pipeline/PipelinedAssetTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Pipeline;
12+
namespace Symfony\Component\Asset\Tests\Pipeline;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Asset\Pipeline\PipelinedAsset;

‎src/Symfony/Component/Asset/Tests/fixtures/pipeline/PipelineTestAppKernel.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Asset/Tests/fixtures/pipeline/PipelineTestAppKernel.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
3131
'pipeline' => [
3232
'paths' => ['dir1', 'dir2'],
3333
]
34-
]
34+
],
35+
'test' => true,
3536
]);
3637

3738
$container->setAlias('public.assets.packages', new Alias('assets.packages', true));

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.