MediaTest.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\ProductVideo\Test\Unit\Helper;
  7. use Magento\ProductVideo\Helper\Media;
  8. class MediaTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /** @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject */
  11. protected $scopeConfigMock;
  12. /**
  13. * @var \Magento\ProductVideo\Helper\Media|\PHPUnit_Framework_MockObject_MockObject
  14. */
  15. protected $helper;
  16. /**
  17. * @var \Magento\Framework\App\Helper\Context|\PHPUnit_Framework_MockObject_MockObject
  18. */
  19. protected $contextMock;
  20. /**
  21. * Create mock objects
  22. */
  23. protected function setUp()
  24. {
  25. $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
  26. ->getMock();
  27. $this->contextMock = $this->createMock(\Magento\Framework\App\Helper\Context::class);
  28. $this->contextMock->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfigMock);
  29. $this->helper = new \Magento\ProductVideo\Helper\Media(
  30. $this->contextMock
  31. );
  32. }
  33. /**
  34. * Test for method getPlayIfBaseAttribute
  35. */
  36. public function testGetPlayIfBaseAttribute()
  37. {
  38. $return = 'some_value';
  39. $this->scopeConfigMock->expects($this->once())->method('getValue')
  40. ->with(Media::XML_PATH_PLAY_IF_BASE)
  41. ->will($this->returnValue($return));
  42. $this->assertEquals(
  43. $return,
  44. $this->helper->getPlayIfBaseAttribute()
  45. );
  46. }
  47. /**
  48. * Test for method getShowRelatedAttribute
  49. */
  50. public function testGetShowRelatedAttribute()
  51. {
  52. $return = 'some_value';
  53. $this->scopeConfigMock->expects($this->once())->method('getValue')
  54. ->with(Media::XML_PATH_SHOW_RELATED)
  55. ->will($this->returnValue($return));
  56. $this->assertEquals(
  57. $return,
  58. $this->helper->getShowRelatedAttribute()
  59. );
  60. }
  61. /**
  62. * Test for method getVideoAutoRestartAttribute
  63. */
  64. public function testGetVideoAutoRestartAttribute()
  65. {
  66. $return = 'some_value';
  67. $this->scopeConfigMock->expects($this->once())->method('getValue')
  68. ->with(Media::XML_PATH_VIDEO_AUTO_RESTART)
  69. ->will($this->returnValue($return));
  70. $this->assertEquals(
  71. $return,
  72. $this->helper->getVideoAutoRestartAttribute()
  73. );
  74. }
  75. /**
  76. * Test for method getYouTubeApiKey
  77. */
  78. public function testGetYouTubeApiKey()
  79. {
  80. $return = 'some_value';
  81. $this->scopeConfigMock->expects($this->once())->method('getValue')
  82. ->with(Media::XML_PATH_YOUTUBE_API_KEY)
  83. ->will($this->returnValue($return));
  84. $this->assertEquals(
  85. $return,
  86. $this->helper->getYouTubeApiKey()
  87. );
  88. }
  89. }