Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HandlerFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory;
9 
10 class HandlerFactoryTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $_model;
16 
21 
22  protected function setUp()
23  {
24  $this->_objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
25  $this->_model = new HandlerFactory($this->_objectManagerMock);
26  }
27 
28  public function testCreateWithInvalidType()
29  {
30  $this->expectException('\InvalidArgumentException');
31  $this->expectExceptionMessage(\Magento\Framework\DataObject::class . ' does not implement ' .
32  \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class);
33  $this->_objectManagerMock->expects($this->never())->method('create');
34  $this->_model->create(\Magento\Framework\DataObject::class);
35  }
36 
37  public function testCreateWithValidType()
38  {
39  $this->_objectManagerMock->expects(
40  $this->once()
41  )->method(
42  'create'
43  )->with(
44  \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite::class
45  )->will(
46  $this->returnValue('object')
47  );
48  $this->assertEquals(
49  'object',
50  $this->_model->create(
51  \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\Plugin\Handler\Composite::class
52  )
53  );
54  }
55 }