ScopeTest.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Config\Test\Unit;
  7. use \Magento\Framework\Config\Scope;
  8. class ScopeTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Framework\Config\Scope
  12. */
  13. protected $model;
  14. /**
  15. * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\App\AreaList
  16. */
  17. protected $areaListMock;
  18. protected function setUp()
  19. {
  20. $this->areaListMock = $this->createPartialMock(\Magento\Framework\App\AreaList::class, ['getCodes']);
  21. $this->model = new Scope($this->areaListMock);
  22. }
  23. public function testScopeSetGet()
  24. {
  25. $scopeName = 'test_scope';
  26. $this->model->setCurrentScope($scopeName);
  27. $this->assertEquals($scopeName, $this->model->getCurrentScope());
  28. }
  29. public function testGetAllScopes()
  30. {
  31. $expectedBalances = ['primary', 'test_scope'];
  32. $this->areaListMock->expects($this->once())
  33. ->method('getCodes')
  34. ->will($this->returnValue(['test_scope']));
  35. $this->assertEquals($expectedBalances, $this->model->getAllScopes());
  36. }
  37. }