@@ -164,6 +164,20 @@ public function testGetUrls(array $routes, array $expectedResult): void
164
164
$ this ->assertEquals ($ expectedResult , $ this ->manager ->getUrls ());
165
165
}
166
166
167
+ /**
168
+ * @param array $routes
169
+ * @param array $expectedResult
170
+ * @dataProvider getPrimaryUrlsDataProvider
171
+ */
172
+ public function testGetPrimaryUrls (array $ routes , array $ expectedResult ): void
173
+ {
174
+ $ this ->environmentMock ->expects ($ this ->once ())
175
+ ->method ('getRoutes ' )
176
+ ->willReturn ($ routes );
177
+
178
+ $ this ->assertEquals ($ expectedResult , $ this ->manager ->getUrls ());
179
+ }
180
+
167
181
public function testGetUrlsException (): void
168
182
{
169
183
$ this ->expectException (\RuntimeException::class);
@@ -295,6 +309,10 @@ private function unsecureUrlExample(): array
295
309
];
296
310
}
297
311
312
+ /**
313
+ * DataProvider for testGetUrls
314
+ * @return array
315
+ */
298
316
public function getUrlsDataProvider (): array
299
317
{
300
318
return [
@@ -386,6 +404,103 @@ public function getUrlsDataProvider(): array
386
404
];
387
405
}
388
406
407
+ /**
408
+ * DataProvider for testGetPrimaryUrls
409
+ * @return array
410
+ */
411
+ public function getPrimaryUrlsDataProvider (): array
412
+ {
413
+ return [
414
+ 'with unsecure primary ' => [
415
+ 'routes ' => [
416
+ 'http://example.com/ ' => [
417
+ 'original_url ' => 'http://{default}/ ' ,
418
+ 'type ' => 'upstream ' ,
419
+ 'primary ' => false ,
420
+ ],
421
+ 'http://www.custom.example.com/ ' => [
422
+ 'original_url ' => 'http://{all}/ ' ,
423
+ 'type ' => 'upstream ' ,
424
+ 'primary ' => false ,
425
+ ],
426
+ 'http://custom.example.com/ ' => [
427
+ 'original_url ' => 'http://{default}/ ' ,
428
+ 'type ' => 'upstream ' ,
429
+ 'primary ' => true ,
430
+ ],
431
+ 'https://french.example.com/ ' => [
432
+ 'original_url ' => 'https://french.{default}/ ' ,
433
+ 'type ' => 'upstream ' ,
434
+ 'primary ' => false ,
435
+ ],
436
+ ],
437
+ 'expectedResult ' => [
438
+ 'secure ' => [
439
+ '' => 'https://custom.example.com/ ' ,
440
+ ],
441
+ 'unsecure ' => [
442
+ '' => 'http://custom.example.com/ ' ,
443
+ ],
444
+ ],
445
+ ],
446
+ 'secure primary ' => [
447
+ 'routes ' => [
448
+ 'http://example.com/ ' => [
449
+ 'original_url ' => 'http://{default}/ ' ,
450
+ 'type ' => 'upstream ' ,
451
+ 'primary ' => false ,
452
+ ],
453
+ 'http://www.example.com/ ' => [
454
+ 'original_url ' => 'http://{all}/ ' ,
455
+ 'type ' => 'upstream ' ,
456
+ 'primary ' => false ,
457
+ ],
458
+ 'https://custom.example.com/ ' => [
459
+ 'original_url ' => 'http://{default}/ ' ,
460
+ 'type ' => 'upstream ' ,
461
+ 'primary ' => true ,
462
+ ],
463
+ ],
464
+ 'expectedResult ' => [
465
+ 'secure ' => [
466
+ '' => 'https://custom.example.com/ ' ,
467
+ ],
468
+ 'unsecure ' => [
469
+ '' => 'https://custom.example.com/ ' ,
470
+ ],
471
+ ],
472
+ ],
473
+ 'all primary false and one secure ' => [
474
+ 'routes ' => [
475
+ 'http://example.com/ ' => [
476
+ 'original_url ' => 'http://{default}/ ' ,
477
+ 'type ' => 'upstream ' ,
478
+ 'primary ' => false ,
479
+ ],
480
+ 'http://www.example.com/ ' => [
481
+ 'original_url ' => 'http://{all}/ ' ,
482
+ 'type ' => 'upstream ' ,
483
+ 'primary ' => false ,
484
+ ],
485
+ 'https://www.example.com/ ' => [
486
+ 'original_url ' => 'http://{all}/ ' ,
487
+ 'type ' => 'upstream ' ,
488
+ 'primary ' => false ,
489
+ ],
490
+ ],
491
+ 'expectedResult ' => [
492
+ 'secure ' => [
493
+ '{all} ' => 'https://www.example.com/ ' ,
494
+ ],
495
+ 'unsecure ' => [
496
+ '' => 'http://example.com/ ' ,
497
+ '{all} ' => 'http://www.example.com/ ' ,
498
+ ],
499
+ ],
500
+ ],
501
+ ];
502
+ }
503
+
389
504
public function testGetBaseUrl (): void
390
505
{
391
506
$ processMock = $ this ->getMockForAbstractClass (ProcessInterface::class);
0 commit comments