Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SetupFactoryTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class SetupFactoryTest extends \PHPUnit\Framework\TestCase
11 {
12  public function testCreate()
13  {
14  $objectManager = $this->getMockForAbstractClass(
15  \Magento\Framework\ObjectManagerInterface::class,
16  [],
17  '',
18  false
19  );
20  $objectManager->expects($this->once())
21  ->method('get')
22  ->with(\Magento\Framework\App\ResourceConnection::class)
23  ->willReturn($this->createMock(\Magento\Framework\App\ResourceConnection::class));
24  $objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
25  $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
26  $factory = new SetupFactory($objectManagerProvider);
27  $this->assertInstanceOf(\Magento\Setup\Module\Setup::class, $factory->create());
28  }
29 
30  public function testCreateWithParam()
31  {
32  $objectManager = $this->getMockForAbstractClass(
33  \Magento\Framework\ObjectManagerInterface::class,
34  [],
35  '',
36  false
37  );
38  $objectManager->expects($this->never())->method('get');
39  $resource = $this->createMock(\Magento\Framework\App\ResourceConnection::class);
40  $objectManagerProvider = $this->createMock(\Magento\Setup\Model\ObjectManagerProvider::class);
41  $objectManagerProvider->expects($this->once())->method('get')->willReturn($objectManager);
42  $factory = new SetupFactory($objectManagerProvider);
43  $this->assertInstanceOf(\Magento\Setup\Module\Setup::class, $factory->create($resource));
44  }
45 }
$objectManager
Definition: bootstrap.php:17
$resource
Definition: bulk.php:12