Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TypeResolverTest.php
Go to the documentation of this file.
1 <?php
7 
8 class TypeResolverTest extends \PHPUnit\Framework\TestCase
9 {
13  private $objectManager;
14 
18  private $resolver;
19 
23  private $metadataPoolMock;
24 
25  public function setUp()
26  {
27  $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
28  $this->metadataPoolMock =
29  $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
30  $this->resolver = new \Magento\Framework\EntityManager\TypeResolver($this->metadataPoolMock);
31  }
32 
38  public function testResolve($dataObject, $interfaceName)
39  {
40  $customerDataObject = $this->objectManager->getObject($dataObject);
41  $this->metadataPoolMock->expects($this->any())
42  ->method('hasConfiguration')
43  ->willReturnMap(
44  [
45  [$interfaceName, true]
46  ]
47  );
48  $this->assertEquals($interfaceName, $this->resolver->resolve($customerDataObject));
49  }
50 
54  public function resolveDataProvider()
55  {
56  return [
57  [
58  \Magento\Customer\Model\Data\Customer::class,
59  \Magento\Customer\Api\Data\CustomerInterface::class
60  ],
61  [
62  \Magento\Catalog\Model\Category::class,
63  \Magento\Catalog\Api\Data\CategoryInterface::class,
64  ]
65  ];
66  }
67 }