Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OperationFactoryTest.php
Go to the documentation of this file.
1 <?php
8 
11 
12 class OperationFactoryTest extends \PHPUnit\Framework\TestCase
13 {
17  private $factory;
18 
22  private $objectManagerMock;
23 
24  protected function setUp()
25  {
26  $this->objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
27  ->setMethods([])
28  ->getMock();
29  $objectManagerProviderMock = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
30  $objectManagerProviderMock->expects($this->once())->method('get')->willReturn($this->objectManagerMock);
31  $this->factory = new OperationFactory(
32  $objectManagerProviderMock
33  );
34  }
35 
41  public function testCreateSuccess($alias, $arguments, $instanceName)
42  {
43  $operationInstance = $this->getMockBuilder(\Magento\Setup\Module\Di\App\Task\OperationInterface::class)
44  ->getMock();
45 
46  $this->objectManagerMock->expects($this->once())
47  ->method('create')
48  ->with($instanceName, ['data' => $arguments])
49  ->willReturn($operationInstance);
50 
51  $this->assertSame($operationInstance, $this->factory->create($alias, $arguments));
52  }
53 
54  public function testCreateException()
55  {
56  $notRegisteredOperation = 'coffee';
57  $this->expectException(\Magento\Setup\Module\Di\App\Task\OperationException::class);
58  $this->expectExceptionMessage(
59  sprintf('Unrecognized operation "%s"', $notRegisteredOperation),
61  );
62  $this->factory->create($notRegisteredOperation);
63  }
64 
68  public function aliasesDataProvider()
69  {
70  return [
71  [OperationFactory::AREA_CONFIG_GENERATOR, [], \Magento\Setup\Module\Di\App\Task\Operation\Area::class],
72  [OperationFactory::INTERCEPTION, null, \Magento\Setup\Module\Di\App\Task\Operation\Interception::class],
73  [
75  1,
76  \Magento\Setup\Module\Di\App\Task\Operation\InterceptionCache::class
77  ],
78  ];
79  }
80 }
$arguments
if(!trim($html)) $alias
Definition: details.phtml:20