InformationTest.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Developer\Test\Unit\Model\Di;
  7. use Magento\Framework\ObjectManager\ConfigInterface;
  8. use Magento\Framework\ObjectManager\DefinitionInterface;
  9. use Magento\Developer\Model\Di\PluginList;
  10. use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
  11. use Magento\Developer\Model\Di\Information;
  12. class InformationTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @var \Magento\Developer\Model\Di\Information
  16. */
  17. private $object;
  18. /**
  19. * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\ObjectManager\ConfigInterface
  20. */
  21. private $objectManagerConfig;
  22. /**
  23. * @var \Magento\Framework\ObjectManager\DefinitionInterface
  24. */
  25. private $definitions;
  26. /**
  27. * @var \Magento\Developer\Model\Di\PluginList
  28. */
  29. private $pluginList;
  30. protected function setUp()
  31. {
  32. $this->objectManagerConfig = $this->getMockBuilder(ConfigInterface::class)
  33. ->disableOriginalConstructor()
  34. ->getMock();
  35. $this->definitions = $this->getMockBuilder(DefinitionInterface::class)
  36. ->disableOriginalConstructor()
  37. ->getMock();
  38. $this->pluginList = $this->getMockBuilder(PluginList::class)
  39. ->disableOriginalConstructor()
  40. ->getMock();
  41. $this->object = (new ObjectManager($this))->getObject(Information::class, [
  42. 'objectManagerConfig' => $this->objectManagerConfig,
  43. 'definitions' => $this->definitions,
  44. 'pluginList' => $this->pluginList,
  45. ]);
  46. }
  47. public function testGetPreference()
  48. {
  49. $this->objectManagerConfig->expects($this->any())
  50. ->method('getPreference')
  51. ->with(Information::class)
  52. ->willReturn(Information::class);
  53. $this->assertEquals(Information::class, $this->object->getPreference(Information::class));
  54. }
  55. public function testGetParameters()
  56. {
  57. $this->definitions->expects($this->any())
  58. ->method('getParameters')
  59. ->with(Information::class)
  60. ->willReturn([['information', Information::class, false, null]]);
  61. $this->objectManagerConfig->expects($this->any())
  62. ->method('getPreference')
  63. ->with(Information::class)
  64. ->willReturn(Information::class);
  65. $this->assertEquals(
  66. [['information', Information::class, null]],
  67. $this->object->getParameters(Information::class)
  68. );
  69. }
  70. }