function ComposerInspectorTest::testConfigUndefinedKey

@covers ::getConfig

File

core/modules/package_manager/tests/src/Kernel/ComposerInspectorTest.php, line 79

Class

ComposerInspectorTest
@coversDefaultClass \Drupal\package_manager\ComposerInspector[[api-linebreak]]

Namespace

Drupal\Tests\package_manager\Kernel

Code

public function testConfigUndefinedKey() : void {
  $project_root = $this->container
    ->get(PathLocator::class)
    ->getProjectRoot();
  $inspector = $this->container
    ->get(ComposerInspector::class);
  // Overwrite the composer.json file and treat it as a
  $file = new JsonFile($project_root . '/composer.json');
  $this->assertTrue($file->exists());
  $data = $file->read();
  // Ensure that none of the special keys are defined, to test the fallback
  // behavior.
  unset($data['minimum-stability'], $data['extra']);
  $file->write($data);
  $path = $file->getPath();
  $this->assertSame('stable', $inspector->getConfig('minimum-stability', $path));
  $this->assertSame([], Json::decode($inspector->getConfig('extra', $path)));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.