Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UrlBuilderTest.php
Go to the documentation of this file.
1 <?php
8 
10 
15 class UrlBuilderTest extends \PHPUnit\Framework\TestCase
16 {
20  protected $urlBuilder;
21 
25  protected $urlInterface;
26 
31 
32  protected function setUp()
33  {
34  $this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class);
35  $this->scopeConfigInterface = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
36 
37  $objectManagerHelper = new ObjectManagerHelper($this);
38  $this->urlBuilder = $objectManagerHelper->getObject(
39  \Magento\Rss\Model\UrlBuilder::class,
40  [
41  'urlBuilder' => $this->urlInterface,
42  'scopeConfig' => $this->scopeConfigInterface
43  ]
44  );
45  }
46 
47  public function testGetUrlEmpty()
48  {
49  $this->scopeConfigInterface->expects($this->once())->method('getValue')
50  ->with('rss/config/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
51  ->will($this->returnValue(false));
52  $this->assertEquals('', $this->urlBuilder->getUrl());
53  }
54 
55  public function testGetUrl()
56  {
57  $this->scopeConfigInterface->expects($this->once())->method('getValue')
58  ->with('rss/config/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
59  ->will($this->returnValue(true));
60  $this->urlInterface->expects($this->once())->method('getUrl')
61  ->with('rss/feed/index', ['type' => 'rss_feed'])
62  ->will($this->returnValue('http://magento.com/rss/feed/index/type/rss_feed'));
63  $this->assertEquals(
64  'http://magento.com/rss/feed/index/type/rss_feed',
65  $this->urlBuilder->getUrl(['type' => 'rss_feed'])
66  );
67  }
68 }