createPartialMock(\Magento\Config\Model\Config\Factory::class, ['create']); $responseMock = $this->createMock(\Magento\Framework\App\Console\Response::class); $configMock = $this->createMock(\Magento\Config\Model\Config::class); $key = 'key'; $value = 'value'; $request = [$key => $value]; $model = new \Magento\Backend\App\UserConfig($factoryMock, $responseMock, $request); $factoryMock->expects($this->once())->method('create')->will($this->returnValue($configMock)); $configMock->expects($this->once())->method('setDataByPath')->with($key, $value); $configMock->expects($this->once())->method('save'); $model->launch(); } }