WebsiteTest.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Store\Test\Unit\Model\Resolver;
  8. use \Magento\Store\Model\Resolver\Website;
  9. /**
  10. * Test class for \Magento\Store\Model\Resolver\Website
  11. */
  12. class WebsiteTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @var Website
  16. */
  17. protected $_model;
  18. /**
  19. * @var \PHPUnit_Framework_MockObject_MockObject
  20. */
  21. protected $_storeManagerMock;
  22. protected function setUp()
  23. {
  24. $this->_storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
  25. $this->_model = new Website($this->_storeManagerMock);
  26. }
  27. protected function tearDown()
  28. {
  29. unset($this->_storeManagerMock);
  30. }
  31. public function testGetScope()
  32. {
  33. $scopeMock = $this->createMock(\Magento\Framework\App\ScopeInterface::class);
  34. $this->_storeManagerMock
  35. ->expects($this->once())
  36. ->method('getWebsite')
  37. ->with(0)
  38. ->will($this->returnValue($scopeMock));
  39. $this->assertEquals($scopeMock, $this->_model->getScope());
  40. }
  41. /**
  42. * @expectedException \Magento\Framework\Exception\State\InitException
  43. */
  44. public function testGetScopeWithInvalidScope()
  45. {
  46. $scopeMock = new \StdClass();
  47. $this->_storeManagerMock
  48. ->expects($this->once())
  49. ->method('getWebsite')
  50. ->with(0)
  51. ->will($this->returnValue($scopeMock));
  52. $this->assertEquals($scopeMock, $this->_model->getScope());
  53. }
  54. }