RuntimeTest.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\ObjectManager\Test\Unit\Relations;
  7. require_once __DIR__ . '/../_files/Child.php';
  8. class RuntimeTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var \Magento\Framework\ObjectManager\Relations\Runtime
  12. */
  13. private $model;
  14. protected function setUp()
  15. {
  16. $this->model = new \Magento\Framework\ObjectManager\Relations\Runtime();
  17. }
  18. /**
  19. * @param $type
  20. * @param $parents
  21. * @dataProvider getParentsDataProvider
  22. */
  23. public function testGetParents($type, $parents)
  24. {
  25. $this->assertEquals($parents, $this->model->getParents($type));
  26. }
  27. /**
  28. * @return array
  29. */
  30. public function getParentsDataProvider()
  31. {
  32. return [
  33. [\Magento\Test\Di\DiInterface::class, []],
  34. [\Magento\Test\Di\DiParent::class, [null, \Magento\Test\Di\DiInterface::class]],
  35. [\Magento\Test\Di\Child::class, [\Magento\Test\Di\DiParent::class, \Magento\Test\Di\ChildInterface::class]]
  36. ];
  37. }
  38. /**
  39. * @param $entity
  40. */
  41. public function testHasIfNonExists()
  42. {
  43. $this->assertFalse($this->model->has(\NonexistentClass::class));
  44. }
  45. }