ScopeResolverPoolTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\App\Test\Unit;
  7. class ScopeResolverPoolTest extends \PHPUnit\Framework\TestCase
  8. {
  9. /**
  10. * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager
  11. */
  12. protected $_helper;
  13. protected function setUp()
  14. {
  15. $this->_helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  16. }
  17. public function testGet()
  18. {
  19. $scope = $this->createMock(\Magento\Framework\App\ScopeResolverInterface::class);
  20. $scopeResolver = $this->_helper->getObject(
  21. \Magento\Framework\App\ScopeResolverPool::class,
  22. [
  23. 'scopeResolvers' => ['test' => $scope]
  24. ]
  25. );
  26. $this->assertSame($scope, $scopeResolver->get('test'));
  27. }
  28. /**
  29. * @param string $scope
  30. *
  31. * @covers \Magento\Framework\App\ScopeResolverPool::get()
  32. * @expectedException \InvalidArgumentException
  33. * @expectedExceptionMessage Invalid scope type
  34. * @dataProvider testGetExceptionDataProvider
  35. */
  36. public function testGetException($scope)
  37. {
  38. $scopeResolver = $this->_helper->getObject(
  39. \Magento\Framework\App\ScopeResolverPool::class,
  40. [
  41. 'scopeResolvers' => ['test' => new \Magento\Framework\DataObject()]
  42. ]
  43. );
  44. $scopeResolver->get($scope);
  45. }
  46. /**
  47. * @return array
  48. */
  49. public function testGetExceptionDataProvider()
  50. {
  51. return [
  52. ['undefined'],
  53. ['test'],
  54. ];
  55. }
  56. }