How to test a code where the config is involved as parameter? I'm new to OOP concepts, also PHPUnit Testing is new for me. I want to get the configuration in my testcase.

XYZFormResult.php

namespace Drupal\xyz\XYZFormResult;

use Drupal\Core\Config\ConfigFactory;
use Drupal\webform\Entity\WebformSubmission;

/**
* Class XYZFormResult.
*
* @package Drupal\xyz\formgroup
*/
class XYZFormResult {

    /**
    * Defines the immutable configuration object.
    *
    * @var \Drupal\Core\Config\Config|\Drupal\Core\Config\ImmutableConfig
    */
    private $config;

    /**
    * XYZFormResult constructor.
    *
    * @param \Drupal\Core\Config\ConfigFactory $config
    *   Inject ConfigFactory.
    */
    public function __construct(ConfigFactory $config) {
        $this-&gt;config = $config-&gt;getEditable('xyz.settings');
    }
}


XYZFormTest.php

namespace Drupal\Tests\xyz\Unit\XYZFormTest;

//use Drupal\Core\Config\ConfigFactory;
use Drupal\Tests\UnitTestCase;
use Drupal\xyz\formgroup\FormsGroupResult;
use Drupal\xyz\formgroup\XYZFormResult;
use Drupal\webform\Entity\WebformSubmission;


/**
* @coversDefaultClass \Drupal\xyz\formgroup\FormsGroupResult
* @group xyz
*/
class XYZFormTest extends UnitTestCase {
    /**
    *
    * @var \Drupal\Core\Config\ConfigFactory|\PHPUnit_Framework_MockObject_MockBuilder
    */
    protected $config;

    public function testxyz() {
        $this-&gt;XYZresult = new XYZFormResult($config);
    }
}


When I execute this XYZFormTest testcase, I need to pass a parameter for XYZFormResult(), how to pass config parameter?

If I pass any string in XYZFormResult(), I'm getting error this error:

__construct() must be an instance of Drupal\Core\Config\ConfigFactory, string given error
On a unit test, you can use getConfigFactoryStub():

namespace Drupal\Tests\my_module\Unit;

use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;

class MyModuleTest extends UnitTestCase {
  public function setUp() {
    parent::setUp();

    $config_map = [
      'my_module.settings' =&gt; [
        'setting_1' =&gt; 'value_1',
      ],
    ];

    // Get a stub for the config.factory service.
    $this-&gt;my_config_factory = $this-&gt;getConfigFactoryStub($config_map);

    $container = new ContainerBuilder();
    // Set the config.factory in the container also.
    $container-&gt;set('config.factory', $this-&gt;my_config_factory);

    \Drupal::setContainer($container);
  }

  public function testSomething() {
    $obj = new Something($this-&gt;my_config_factory);
    // ... asserts, etc.
}
}