Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ProcessorTest.php
Go to the documentation of this file.
1 <?php
7 
11 
12 class ProcessorTest extends \PHPUnit\Framework\TestCase
13 {
17  protected $processor;
18 
22  protected $assetRepository;
23 
27  protected $fallbackContext;
28 
29  public function setUp()
30  {
31  $this->assetRepository = $this->getMockBuilder(Repository::class)
32  ->disableOriginalConstructor()
33  ->getMock();
34  $this->fallbackContext = $this->getMockBuilder(FallbackContext::class)
35  ->disableOriginalConstructor()
36  ->getMock();
37 
38  $this->processor = new Processor($this->assetRepository);
39  }
40 
41  public function testProcess()
42  {
43  $url = 'http://magento.local/pub/static/';
44  $locale = 'en_US';
45  $css = '@import url("{{base_url_path}}frontend/_view/{{locale}}/css/email.css");';
46  $expectedCss = '@import url("' . $url . 'frontend/_view/' . $locale . '/css/email.css");';
47 
48  $this->assetRepository->expects($this->exactly(2))
49  ->method('getStaticViewFileContext')
50  ->willReturn($this->fallbackContext);
51  $this->fallbackContext->expects($this->once())
52  ->method('getBaseUrl')
53  ->willReturn($url);
54  $this->fallbackContext->expects($this->once())
55  ->method('getLocale')
56  ->willReturn($locale);
57  $this->assertEquals($expectedCss, $this->processor->process($css));
58  }
59 }