objectManagerMock = $this->getMockBuilder(ObjectManagerInterface::class) ->getMockForAbstractClass(); $this->model = new CommandList( $this->objectManagerMock ); } public function testGetCommands() { $configImportCommand = $this->getMockBuilder(ConfigImportCommand::class) ->disableOriginalConstructor() ->getMock(); $this->objectManagerMock->expects($this->once()) ->method('get') ->willReturnMap([ [ConfigImportCommand::class, $configImportCommand], ]); $this->assertSame( [$configImportCommand], $this->model->getCommands() ); } }