/** * @covers ::initPackageFromExtension * @covers ::getPackageObject */ public function testInitPackageFromInstalledExtension() { $extension = new Extension($this->root, 'module', 'modules/test_module/test_module.info.yml'); $info_parser = $this->prophesize(InfoParserInterface::class); $info_parser->parse($this->root . '/modules/test_module/test_module.info.yml')->willReturn(['name' => 'Test module', 'description' => 'test description', 'type' => 'module']); \Drupal::getContainer()->set('info_parser', $info_parser->reveal()); $bundle = $this->prophesize(FeaturesBundle::class); $bundle->getShortName('test_module')->willReturn('test_module'); $bundle->isDefault()->willReturn(TRUE); $assigner = $this->prophesize(FeaturesAssignerInterface::class); $assigner->findBundle(Argument::cetera())->willReturn($bundle->reveal()); $this->featuresManager->setAssigner($assigner->reveal()); $this->moduleHandler->expects($this->any())->method('moduleExists')->with('test_module')->willReturn(TRUE); $result = $this->featuresManager->initPackageFromExtension($extension); $this->assertEquals(FeaturesManagerInterface::STATUS_INSTALLED, $result->getStatus()); }
/** * @covers ::assignInterPackageDependencies */ public function testAssignInterPackageDependenciesWithBundle() { $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'); $assigner->getBundle('giraffe')->willReturn($bundle->reveal()); $this->featuresManager->setAssigner($assigner->reveal()); $this->featuresManager->setConfigCollection($this->getAssignInterPackageDependenciesConfigCollection()); $packages = ['package' => ['machine_name' => 'package', 'config' => ['example.config', 'example.config3'], 'dependencies' => [], 'bundle' => 'giraffe'], 'package2' => ['machine_name' => 'package2', 'config' => ['example.config2'], 'dependencies' => [], 'bundle' => 'giraffe']]; $expected = $packages; // example.config3 has a providing_feature but no assigned package. $expected['package']['dependencies'][] = 'my_other_feature'; // 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. $expected['package']['dependencies'][] = 'package2'; $this->featuresManager->setPackages($packages); $this->featuresManager->assignInterPackageDependencies($packages); $this->assertEquals($expected, $packages); }
/** * Initializes the injected features manager with the assigner. * * This should be called right after instantiating the assigner to make it * available to the features manager without introducing a circular * dependency. */ public function initFeaturesManager() { $this->featuresManager->setAssigner($this); }