/
FilterTest.php
36 lines (31 loc) · 1.54 KB
/
FilterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Widget\Test\Unit\Model\Template;
use Magento\Store\Model\StoreManagerInterface;
class FilterTest extends \PHPUnit_Framework_TestCase
{
public function testMediaDirective()
{
$image = 'wysiwyg/VB.png';
$construction = ['{{media url="' . $image . '"}}', 'media', ' url="' . $image . '"'];
$baseUrl = 'http://localhost/pub/media/';
/** @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject $storeMock */
$storeMock = $this->getMock('Magento\Store\Model\Store', [], [], '', false);
$storeMock->expects($this->once())->method('getBaseUrl')->with(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA)
->willReturn($baseUrl);
/** @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject $storeManagerMock */
$storeManagerMock = $this->getMock('Magento\Store\Model\StoreManagerInterface', [], [], '', false);
$storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($storeMock));
/** @var \Magento\Widget\Model\Template\Filter $filter */
$filter = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))
->getObject(
'Magento\Widget\Model\Template\Filter',
['storeManager' => $storeManagerMock]
);
$result = $filter->mediaDirective($construction);
$this->assertEquals($baseUrl . $image, $result);
}
}