@@ -486,6 +486,66 @@ public function testGetBaseUrlWithEmptyStoreUrls()
486
486
);
487
487
}
488
488
489
+ /**
490
+ * @param array $routes
491
+ * @param string $expectedUrl
492
+ * @dataProvider getBaseUrlDataProvider
493
+ */
494
+ public function testGetBaseUrlWithErrorFromDefaultUrlCommand (array $ routes , string $ expectedUrl )
495
+ {
496
+ $ processMock = $ this ->getMockForAbstractClass (ProcessInterface::class);
497
+ $ processMock ->expects ($ this ->never ())
498
+ ->method ('getOutput ' );
499
+ $ this ->magentoShellMock ->expects ($ this ->once ())
500
+ ->method ('execute ' )
501
+ ->with ('config:show:default-url ' )
502
+ ->willThrowException (new ShellException ('some error ' ));
503
+ $ this ->environmentMock ->expects ($ this ->once ())
504
+ ->method ('getRoutes ' )
505
+ ->willReturn ($ routes );
506
+
507
+ $ this ->assertEquals ($ expectedUrl , $ this ->manager ->getBaseUrl ());
508
+ }
509
+
510
+ /**
511
+ * @return array
512
+ */
513
+ public function getBaseUrlDataProvider (): array
514
+ {
515
+ return [
516
+ [
517
+ [
518
+ 'http://unsecure.com/ ' => ['original_url ' => 'https://{all} ' , 'type ' => 'upstream ' ]
519
+ ],
520
+ 'https://unsecure.com/ '
521
+ ],
522
+ [
523
+ [
524
+ 'http://unsecure.com/ ' => ['original_url ' => 'https://{all} ' , 'type ' => 'upstream ' ],
525
+ 'http://unsecure-default.com/ ' => ['original_url ' => 'https://{default} ' , 'type ' => 'upstream ' ],
526
+ ],
527
+ 'https://unsecure-default.com/ '
528
+ ],
529
+ [
530
+ [
531
+ 'https://secure.com/ ' => ['original_url ' => 'https://{all} ' , 'type ' => 'upstream ' ],
532
+ 'http://unsecure.com/ ' => ['original_url ' => 'https://{all} ' , 'type ' => 'upstream ' ],
533
+ 'http://unsecure-default.com/ ' => ['original_url ' => 'https://{default} ' , 'type ' => 'upstream ' ],
534
+ ],
535
+ 'https://secure.com/ '
536
+ ],
537
+ [
538
+ [
539
+ 'https://secure.com/ ' => ['original_url ' => 'https://{all} ' , 'type ' => 'upstream ' ],
540
+ 'https://secure-default.com/ ' => ['original_url ' => 'https://{default} ' , 'type ' => 'upstream ' ],
541
+ 'http://unsecure.com/ ' => ['original_url ' => 'https://{all} ' , 'type ' => 'upstream ' ],
542
+ 'http://unsecure-default.com/ ' => ['original_url ' => 'https://{default} ' , 'type ' => 'upstream ' ],
543
+ ],
544
+ 'https://secure-default.com/ '
545
+ ],
546
+ ];
547
+ }
548
+
489
549
public function testGetBaseUrls ()
490
550
{
491
551
$ processMock = $ this ->getMockForAbstractClass (ProcessInterface::class);
0 commit comments