I have a function which does 2-3 things, one of the activity is to save the configuration.

function processProps($data) {
  $config = $this->configFactory->getEditable('mymodule.settings');
    ->set('some_setting', 'some value')
    ->set('another_setting', 'another value')
  return TRUE;

The test code as follows

public function testSspProcessProperties() {
    $data = $this->getTestData();

    $immutable_config_object = $this->prophesize(ImmutableConfig::class);

    $config_object = $this->prophesize(Config::class);
        'key' => 'value',




This test gives error Error: Call to a member function set() on null. When I debug found that $config object is loaded properly. So not able to understand why I say null :(

I checked ConfigEntityStorageTest for the reference.

  • One question - your test asserts that the method returns true, but the code provided looks like it will always return true regardless. I assume there is some redacted code there that has return false? – Kevin Jan 10 at 14:25
  • 1
    @Kevin It's probably the ..., but it would be clearer if the OP included the code in the post. – user72672 Jan 10 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.