public function FeaturesManagerTest::testAssignInterPackageDependenciesWithoutBundle in Features 8.3
Same name and namespace in other branches
- 8.4 tests/src/Unit/FeaturesManagerTest.php \Drupal\Tests\features\Unit\FeaturesManagerTest::testAssignInterPackageDependenciesWithoutBundle()
@covers ::assignInterPackageDependencies
File
- tests/
src/ Unit/ FeaturesManagerTest.php, line 363
Class
- FeaturesManagerTest
- @coversDefaultClass Drupal\features\FeaturesManager @group features
Namespace
Drupal\Tests\features\UnitCode
public function testAssignInterPackageDependenciesWithoutBundle() {
$assigner = $this
->prophesize(FeaturesAssignerInterface::class);
$bundle = $this
->prophesize(FeaturesBundleInterface::class);
// Provide a bundle without any prefix.
$bundle
->getFullName('package')
->willReturn('package');
$bundle
->getFullName('package2')
->willReturn('package2');
$bundle
->getFullName('package3')
->willReturn('package3');
$bundle
->getFullName('package4')
->willReturn('package4');
$bundle
->isDefault()
->willReturn(TRUE);
$assigner
->getBundle()
->willReturn($bundle
->reveal());
// Use the wrapper because we need ::drupalGetProfile().
$features_manager = new TestFeaturesManager($this->root, $this->entityTypeManager, $this->configFactory, $this->configStorage, $this->configManager, $this->moduleHandler, $this->configReverter, $this->moduleExtensionList);
$features_manager
->setAssigner($assigner
->reveal());
$features_manager
->setConfigCollection($this
->getAssignInterPackageDependenciesConfigCollection());
$packages = [
'package' => new Package('package', [
'config' => [
'example.config',
'example.config3',
],
'dependencies' => [],
'bundle' => '',
]),
'package2' => new Package('package2', [
'config' => [
'example.config2',
],
'dependencies' => [],
'bundle' => '',
]),
'package3' => new Package('package3', [
'config' => [
'example.config5',
],
'dependencies' => [],
'bundle' => '',
]),
'package4' => new Package('package4', [
'config' => [
'example.config7',
],
'dependencies' => [],
'bundle' => '',
]),
];
$features_manager
->setPackages($packages);
// Dependencies require the full package names.
$package_names = array_keys($packages);
$features_manager
->setPackageBundleNames($bundle
->reveal(), $package_names);
$packages = $features_manager
->getPackages();
$features_manager
->assignInterPackageDependencies($bundle
->reveal(), $packages);
// example.config3 has a providing_feature but no assigned package.
// my_package2 provides configuration required by configuration in
// my_package.
// Because package assignments take precedence over providing_feature ones,
// package2 should have been assigned rather than my_feature.
// Because it is assigned to the InstallStorage::CONFIG_OPTIONAL_DIRECTORY
// subdirectory, example.config5 does not create a dependency on its
// providing feature, package3.
// Because it's provided by an uninstalled module, example.config6 doesn't
// create a dependency on my_uninstalled_feature.
// Because it's provided by an uninstalled module, example.config7 doesn't
// create a dependency on package4.
$this
->assertEquals([
'my_other_feature',
'package2',
], $packages['package']
->getDependencies());
$this
->assertEquals([], $packages['package2']
->getDependencies());
}