Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CompositeTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class CompositeTest extends \PHPUnit\Framework\TestCase
11 {
12  public function testHandle()
13  {
14  $factoryMock = $this->createMock(
15  \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerFactory::class
16  );
17 
18  $constructorMock = $this->createMock(
19  \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\HandlerInterface::class
20  );
21 
22  $factoryMock->expects(
23  $this->exactly(2)
24  )->method(
25  'create'
26  )->with(
27  'handlerInstance'
28  )->will(
29  $this->returnValue($constructorMock)
30  );
31 
32  $productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
33 
34  $constructorMock->expects($this->exactly(2))->method('handle')->with($productMock);
35 
36  $model = new Composite($factoryMock, ['handlerInstance', 'handlerInstance']);
37 
38  $model->handle($productMock);
39  }
40 }