UrlBuilderTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Rss\Test\Unit\Model;
  7. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
  8. /**
  9. * Class UrlBuilderTest
  10. * @package Magento\Rss\Model
  11. */
  12. class UrlBuilderTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @var \Magento\Rss\Model\UrlBuilder
  16. */
  17. protected $urlBuilder;
  18. /**
  19. * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $urlInterface;
  22. /**
  23. * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
  24. */
  25. protected $scopeConfigInterface;
  26. protected function setUp()
  27. {
  28. $this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class);
  29. $this->scopeConfigInterface = $this->createMock(\Magento\Framework\App\Config\ScopeConfigInterface::class);
  30. $objectManagerHelper = new ObjectManagerHelper($this);
  31. $this->urlBuilder = $objectManagerHelper->getObject(
  32. \Magento\Rss\Model\UrlBuilder::class,
  33. [
  34. 'urlBuilder' => $this->urlInterface,
  35. 'scopeConfig' => $this->scopeConfigInterface
  36. ]
  37. );
  38. }
  39. public function testGetUrlEmpty()
  40. {
  41. $this->scopeConfigInterface->expects($this->once())->method('getValue')
  42. ->with('rss/config/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
  43. ->will($this->returnValue(false));
  44. $this->assertEquals('', $this->urlBuilder->getUrl());
  45. }
  46. public function testGetUrl()
  47. {
  48. $this->scopeConfigInterface->expects($this->once())->method('getValue')
  49. ->with('rss/config/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE)
  50. ->will($this->returnValue(true));
  51. $this->urlInterface->expects($this->once())->method('getUrl')
  52. ->with('rss/feed/index', ['type' => 'rss_feed'])
  53. ->will($this->returnValue('http://magento.com/rss/feed/index/type/rss_feed'));
  54. $this->assertEquals(
  55. 'http://magento.com/rss/feed/index/type/rss_feed',
  56. $this->urlBuilder->getUrl(['type' => 'rss_feed'])
  57. );
  58. }
  59. }