objectManager = new Helper\ObjectManager($this); $this->objectManagerMock = $this->getMockBuilder('Magento\Framework\ObjectManagerInterface') ->disableOriginalConstructor() ->getMock(); $this->factory = $this->objectManager->getObject( $this->factoryClassName, ['objectManager' => $this->objectManagerMock] ); } public function testCreate() { $instanceMock = $this->getMockBuilder($this->instanceClassName) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->once()) ->method('create') ->will($this->returnValue($instanceMock)); $this->assertSame($instanceMock, $this->factory->create()); } }