|
8 | 8 |
|
9 | 9 | namespace Magento\Email\Test\Unit\Model\Template;
|
10 | 10 |
|
| 11 | +use Magento\Backend\Model\Url as BackendModelUrl; |
11 | 12 | use Magento\Backend\Model\UrlInterface;
|
12 | 13 | use Magento\Email\Model\Template\Css\Processor;
|
13 | 14 | use Magento\Email\Model\Template\Filter;
|
@@ -576,35 +577,47 @@ public function testProtocolDirectiveWithInvalidSchema()
|
576 | 577 | }
|
577 | 578 |
|
578 | 579 | /**
|
579 |
| - * @dataProvider dataProviderCompanyRedirect |
| 580 | + * @dataProvider dataProviderUrlModelCompanyRedirect |
580 | 581 | */
|
581 |
| - public function testStoreDirectiveForCompanyRedirect($construction, $expected, $code) |
| 582 | + public function testStoreDirectiveForCompanyRedirect($className, $backendModelClass) |
582 | 583 | {
|
583 | 584 | $this->storeManager->expects($this->any())
|
584 | 585 | ->method('getStore')
|
585 | 586 | ->willReturn($this->store);
|
586 |
| - $this->store->expects($this->any())->method('getCode')->willReturn($code); |
| 587 | + $this->store->expects($this->any())->method('getCode')->willReturn('frvw'); |
| 588 | + |
| 589 | + $this->backendUrlBuilder = $this->getMockBuilder($className) |
| 590 | + ->onlyMethods(['setScope','getUrl']) |
| 591 | + ->disableOriginalConstructor() |
| 592 | + ->getMockForAbstractClass(); |
587 | 593 |
|
588 | 594 | $this->backendUrlBuilder->expects($this->once())
|
589 | 595 | ->method('getUrl')
|
590 |
| - ->willReturn($expected); |
| 596 | + ->willReturn('http://m246ceeeb2b.test/frvw/'); |
591 | 597 |
|
592 |
| - $result = $this->getModel()->storeDirective($construction); |
593 |
| - $this->assertEquals($expected, $result); |
| 598 | + if ($backendModelClass) { |
| 599 | + $this->backendUrlBuilder->expects($this->never())->method('setScope'); |
| 600 | + } else { |
| 601 | + $this->backendUrlBuilder->expects($this->once())->method('setScope')->willReturnSelf(); |
| 602 | + } |
| 603 | + $this->assertInstanceOf($className, $this->backendUrlBuilder); |
| 604 | + $result = $this->getModel()->storeDirective(["{{store url=''}}",'store',"url=''"]); |
| 605 | + $this->assertEquals('http://m246ceeeb2b.test/frvw/', $result); |
594 | 606 | }
|
595 | 607 |
|
596 |
| - public function dataProviderCompanyRedirect() |
| 608 | + /** |
| 609 | + * @return array[] |
| 610 | + */ |
| 611 | + public function dataProviderUrlModelCompanyRedirect(): array |
597 | 612 | {
|
598 | 613 | return [
|
599 | 614 | [
|
600 |
| - ["{{store url=''}}",'store',"url=''"], |
601 |
| - 'http://m246ceeeb2b.french.test/frvw/', |
602 |
| - 'frvw' |
| 615 | + UrlInterface::class, |
| 616 | + 0 |
603 | 617 | ],
|
604 | 618 | [
|
605 |
| - ["{{store url=''}}",'store_invalid',"url=''"], |
606 |
| - 'http://m246ceeeb2b.test/default/', |
607 |
| - 'default' |
| 619 | + BackendModelUrl::class, |
| 620 | + 1 |
608 | 621 | ]
|
609 | 622 | ];
|
610 | 623 | }
|
|
0 commit comments