@@ -200,6 +200,78 @@ public function testAppendPackage4(): void
200
200
self ::assertSame ($ object , $ return );
201
201
}
202
202
203
+ /**
204
+ * @throws InvalidArgumentException
205
+ * @throws BadMethodCallException
206
+ */
207
+ public function testAppendPackage5 (): void
208
+ {
209
+ $ package = 'test-package ' ;
210
+
211
+ $ minify = $ this ->createMock (MinifyInterface::class);
212
+ $ minify
213
+ ->expects (self ::once ())
214
+ ->method ('getPackageFiles ' )
215
+ ->with ($ package )
216
+ ->willReturn (['files ' => ['abc.txt ' , '' , 'bcd.txt ' ]]);
217
+ $ minify
218
+ ->expects (self ::never ())
219
+ ->method ('isItemOkToAddRevision ' );
220
+ $ minify
221
+ ->expects (self ::never ())
222
+ ->method ('addRevision ' );
223
+
224
+ $ headLink = $ this ->createMock (AbstractStandalone::class);
225
+ $ headLink
226
+ ->expects (self ::once ())
227
+ ->method ('__call ' )
228
+ ->with ('appendStylesheet ' , ['https://www.test.de/abc_42.txt ' , 'screen ' , '!IE ' , []]);
229
+
230
+ $ renderer = $ this ->createMock (PhpRenderer::class);
231
+ $ matcher = self ::exactly (4 );
232
+ $ renderer
233
+ ->expects ($ matcher )
234
+ ->method ('__call ' )
235
+ ->willReturnCallback (
236
+ static function (string $ method , array $ argv ) use ($ matcher , $ headLink ): string | AbstractStandalone {
237
+ match ($ matcher ->numberOfInvocations ()) {
238
+ 3 => self ::assertSame ('serverUrl ' , $ method ),
239
+ 2 => self ::assertSame ('headLink ' , $ method ),
240
+ default => self ::assertSame ('baseUrl ' , $ method ),
241
+ };
242
+
243
+ match ($ matcher ->numberOfInvocations ()) {
244
+ 1 => self ::assertSame (['abc.txt ' , false , false ], $ argv ),
245
+ 2 => self ::assertSame ([], $ argv ),
246
+ 3 => self ::assertSame (['/abc.txt ' ], $ argv ),
247
+ default => self ::assertSame (['bcd.txt ' , false , false ], $ argv ),
248
+ };
249
+
250
+ return match ($ matcher ->numberOfInvocations ()) {
251
+ 1 => '/abc.txt ' ,
252
+ 2 => $ headLink ,
253
+ 3 => 'https://www.test.de/abc_42.txt ' ,
254
+ default => '' ,
255
+ };
256
+ },
257
+ );
258
+ $ renderer
259
+ ->expects (self ::never ())
260
+ ->method ('plugin ' );
261
+
262
+ $ object = new RevisionHeadLink ($ minify , $ renderer );
263
+
264
+ $ return = $ object ->appendPackage (
265
+ $ package ,
266
+ 'screen ' ,
267
+ '!IE ' ,
268
+ ['rel ' => 'prev ' ],
269
+ addRevision: false ,
270
+ );
271
+
272
+ self ::assertSame ($ object , $ return );
273
+ }
274
+
203
275
/**
204
276
* @throws InvalidArgumentException
205
277
* @throws BadMethodCallException
@@ -474,6 +546,72 @@ public function testPrependPackage4(): void
474
546
self ::assertSame ($ object , $ return );
475
547
}
476
548
549
+ /**
550
+ * @throws InvalidArgumentException
551
+ * @throws BadMethodCallException
552
+ */
553
+ public function testPrependPackage5 (): void
554
+ {
555
+ $ package = 'test-package ' ;
556
+
557
+ $ minify = $ this ->createMock (MinifyInterface::class);
558
+ $ minify
559
+ ->expects (self ::once ())
560
+ ->method ('getPackageFiles ' )
561
+ ->with ($ package )
562
+ ->willReturn (['files ' => ['abc.txt ' , '' , 'bcd.txt ' ]]);
563
+ $ minify
564
+ ->expects (self ::never ())
565
+ ->method ('isItemOkToAddRevision ' );
566
+ $ minify
567
+ ->expects (self ::never ())
568
+ ->method ('addRevision ' );
569
+
570
+ $ headLink = $ this ->createMock (AbstractStandalone::class);
571
+ $ headLink
572
+ ->expects (self ::once ())
573
+ ->method ('__call ' )
574
+ ->with ('prependStylesheet ' , ['https://www.test.de/abc_42.txt ' , 'screen ' , false , []]);
575
+
576
+ $ renderer = $ this ->createMock (PhpRenderer::class);
577
+ $ matcher = self ::exactly (4 );
578
+ $ renderer
579
+ ->expects ($ matcher )
580
+ ->method ('__call ' )
581
+ ->willReturnCallback (
582
+ static function (string $ method , array $ argv ) use ($ matcher , $ headLink ): string | AbstractStandalone {
583
+ match ($ matcher ->numberOfInvocations ()) {
584
+ 2 => self ::assertSame ('headLink ' , $ method ),
585
+ 3 => self ::assertSame ('serverUrl ' , $ method ),
586
+ default => self ::assertSame ('baseUrl ' , $ method ),
587
+ };
588
+
589
+ match ($ matcher ->numberOfInvocations ()) {
590
+ 1 => self ::assertSame (['bcd.txt ' , false , false ], $ argv ),
591
+ 2 => self ::assertSame ([], $ argv ),
592
+ 3 => self ::assertSame (['/abc.txt ' ], $ argv ),
593
+ default => self ::assertSame (['abc.txt ' , false , false ], $ argv ),
594
+ };
595
+
596
+ return match ($ matcher ->numberOfInvocations ()) {
597
+ 1 => '/abc.txt ' ,
598
+ 2 => $ headLink ,
599
+ 3 => 'https://www.test.de/abc_42.txt ' ,
600
+ default => '' ,
601
+ };
602
+ },
603
+ );
604
+ $ renderer
605
+ ->expects (self ::never ())
606
+ ->method ('plugin ' );
607
+
608
+ $ object = new RevisionHeadLink ($ minify , $ renderer );
609
+
610
+ $ return = $ object ->prependPackage ($ package , addRevision: false );
611
+
612
+ self ::assertSame ($ object , $ return );
613
+ }
614
+
477
615
/**
478
616
* @throws InvalidArgumentException
479
617
* @throws BadMethodCallException
0 commit comments