GroupTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Group;
  9. use Magento\Store\Model\StoreManagerInterface;
  10. /**
  11. * Test class for \Magento\Store\Model\Resolver\Store
  12. */
  13. class GroupTest extends \PHPUnit\Framework\TestCase
  14. {
  15. /**
  16. * @var Group
  17. */
  18. protected $model;
  19. /**
  20. * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
  21. */
  22. protected $storeManagerMock;
  23. protected function setUp()
  24. {
  25. $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
  26. $this->model = new Group($this->storeManagerMock);
  27. }
  28. protected function tearDown()
  29. {
  30. unset($this->storeManagerMock);
  31. }
  32. public function testGetScope()
  33. {
  34. $scopeMock = $this->createMock(\Magento\Framework\App\ScopeInterface::class);
  35. $this->storeManagerMock
  36. ->expects($this->once())
  37. ->method('getGroup')
  38. ->with(0)
  39. ->will($this->returnValue($scopeMock));
  40. $this->assertEquals($scopeMock, $this->model->getScope());
  41. }
  42. /**
  43. * @expectedException \Magento\Framework\Exception\State\InitException
  44. */
  45. public function testGetScopeWithInvalidScope()
  46. {
  47. $scopeMock = new \StdClass();
  48. $this->storeManagerMock
  49. ->expects($this->once())
  50. ->method('getGroup')
  51. ->with(0)
  52. ->will($this->returnValue($scopeMock));
  53. $this->assertEquals($scopeMock, $this->model->getScope());
  54. }
  55. }