Skip to content

Commit d540035

Browse files
committed
Fixing tests
1 parent 72336f8 commit d540035

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

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

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,11 @@ public function testDownloadPackagesDownloadsEverythingWithNoInstalled()
5959
['foo' => $entry1, 'bar.js/file' => $entry2, 'baz' => $entry3],
6060
$progressCallback
6161
)
62-
->willReturn(['foo' => 'foo content', 'bar.js/file' => 'bar content', 'baz' => 'baz content']);
62+
->willReturn([
63+
'foo' => ['content' => 'foo content', 'dependencies' => []],
64+
'bar.js/file' => ['content' => 'bar content', 'dependencies' => []],
65+
'baz' => ['content' => 'baz content', 'dependencies' => []],
66+
]);
6367

6468
$downloader = new RemotePackageDownloader(
6569
$configReader,
@@ -78,9 +82,9 @@ public function testDownloadPackagesDownloadsEverythingWithNoInstalled()
7882
$installed = require self::$writableRoot.'/assets/vendor/installed.php';
7983
$this->assertEquals(
8084
[
81-
'foo' => ['path' => 'foo.js', 'version' => '1.0.0'],
82-
'bar.js/file' => ['path' => 'bar.js/file.js', 'version' => '1.0.0'],
83-
'baz' => ['path' => 'baz.css', 'version' => '1.0.0'],
85+
'foo' => ['path' => 'foo.js', 'version' => '1.0.0', 'dependencies' => []],
86+
'bar.js/file' => ['path' => 'bar.js/file.js', 'version' => '1.0.0', 'dependencies' => []],
87+
'baz' => ['path' => 'baz.css', 'version' => '1.0.0', 'dependencies' => []],
8488
],
8589
$installed
8690
);
@@ -90,9 +94,9 @@ public function testPackagesWithCorrectInstalledVersionSkipped()
9094
{
9195
$this->filesystem->mkdir(self::$writableRoot.'/assets/vendor');
9296
$installed = [
93-
'foo' => ['path' => 'foo.js', 'version' => '1.0.0'],
94-
'bar.js/file' => ['path' => 'bar.js/file.js', 'version' => '1.0.0'],
95-
'baz' => ['path' => 'baz.css', 'version' => '1.0.0'],
97+
'foo' => ['path' => 'foo.js', 'version' => '1.0.0', 'dependencies' => []],
98+
'bar.js/file' => ['path' => 'bar.js/file.js', 'version' => '1.0.0', 'dependencies' => []],
99+
'baz' => ['path' => 'baz.css', 'version' => '1.0.0', 'dependencies' => []],
96100
];
97101
file_put_contents(
98102
self::$writableRoot.'/assets/vendor/installed.php',
@@ -118,7 +122,10 @@ public function testPackagesWithCorrectInstalledVersionSkipped()
118122

119123
$packageResolver->expects($this->once())
120124
->method('downloadPackages')
121-
->willReturn(['bar.js/file' => 'new bar content', 'baz' => 'new baz content']);
125+
->willReturn([
126+
'bar.js/file' => ['content' => 'new bar content', 'dependencies' => []],
127+
'baz' => ['content' => 'new baz content', 'dependencies' => []],
128+
]);
122129

123130
$downloader = new RemotePackageDownloader(
124131
$configReader,
@@ -137,9 +144,9 @@ public function testPackagesWithCorrectInstalledVersionSkipped()
137144
$installed = require self::$writableRoot.'/assets/vendor/installed.php';
138145
$this->assertEquals(
139146
[
140-
'foo' => ['path' => 'foo.js', 'version' => '1.0.0'],
141-
'bar.js/file' => ['path' => 'bar.js/file.js', 'version' => '1.0.0'],
142-
'baz' => ['path' => 'baz.css', 'version' => '1.1.0'],
147+
'foo' => ['path' => 'foo.js', 'version' => '1.0.0', 'dependencies' => []],
148+
'bar.js/file' => ['path' => 'bar.js/file.js', 'version' => '1.0.0', 'dependencies' => []],
149+
'baz' => ['path' => 'baz.css', 'version' => '1.1.0', 'dependencies' => []],
143150
],
144151
$installed
145152
);
@@ -149,7 +156,7 @@ public function testGetDownloadedPath()
149156
{
150157
$this->filesystem->mkdir(self::$writableRoot.'/assets/vendor');
151158
$installed = [
152-
'foo' => ['path' => 'foo-path.js', 'version' => '1.0.0'],
159+
'foo' => ['path' => 'foo-path.js', 'version' => '1.0.0', 'dependencies' => []],
153160
];
154161
file_put_contents(
155162
self::$writableRoot.'/assets/vendor/installed.php',

src/Symfony/Component/AssetMapper/Tests/ImportMap/Resolver/JsDelivrEsmResolverTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,14 @@ public function testDownloadPackages(array $importMapEntries, array $expectedReq
283283
$httpClient = new MockHttpClient($responses);
284284

285285
$provider = new JsDelivrEsmResolver($httpClient);
286-
$actualContents = $provider->downloadPackages($importMapEntries);
287-
$this->assertCount(\count($expectedContents), $actualContents);
288-
$actualContents = array_map('trim', $actualContents);
286+
$actualReturn = $provider->downloadPackages($importMapEntries);
287+
$this->assertCount(\count($expectedContents), $actualReturn);
288+
289+
$actualContents = [];
290+
foreach ($actualReturn as $package => $data) {
291+
$actualContents[$package] = trim($data['content']);
292+
}
293+
289294
$this->assertSame($expectedContents, $actualContents);
290295
$this->assertSame(\count($expectedRequests), $httpClient->getRequestsCount());
291296
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php return array (
2-
'@hotwired/stimulus' =>
2+
'@hotwired/stimulus' =>
33
array (
44
'version' => '3.2.1',
55
'path' => 'stimulus.js',
6+
'dependencies' => array(),
67
),
7-
'lodash' =>
8+
'lodash' =>
89
array (
910
'version' => '4.17.21',
1011
'path' => 'lodash.js',
12+
'dependencies' => array(),
1113
),
12-
);
14+
);

0 commit comments

Comments
 (0)