How to test a code where the config is involved as parameter?
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.
}
}