You are here

public function FeaturesManagerTest::testInitPackageWithExistingPackage in Features 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Unit/FeaturesManagerTest.php \Drupal\Tests\features\Unit\FeaturesManagerTest::testInitPackageWithExistingPackage()

@covers ::getFeaturesInfo @covers ::getFeaturesModules

File

tests/src/Unit/FeaturesManagerTest.php, line 854

Class

FeaturesManagerTest
@coversDefaultClass Drupal\features\FeaturesManager @group features

Namespace

Drupal\Tests\features\Unit

Code

public function testInitPackageWithExistingPackage() {
  $bundle = new FeaturesBundle([
    'machine_name' => 'test',
  ], 'features_bundle');
  $features_manager = new TestFeaturesManager('vfs://drupal', $this->entityTypeManager, $this->configFactory, $this->configStorage, $this->configManager, $this->moduleHandler, $this->configReverter, $this->moduleExtensionList);
  $this
    ->setupVfsWithTestFeature();
  $extension = new Extension('vfs://drupal', 'module', 'modules/test_feature/test_feature.info.yml');
  $features_manager
    ->setAllModules([
    'test_feature' => $extension,
  ]);
  $this->moduleHandler
    ->expects($this
    ->any())
    ->method('moduleExists')
    ->with('test_feature')
    ->willReturn(TRUE);
  $package = $features_manager
    ->initPackage('test_feature', 'test name', 'test description', 'module', $bundle);
  $this
    ->assertEquals([
    'bundle' => 'test',
    'excluded' => [
      0 => 'system.theme',
    ],
    'required' => TRUE,
  ], $features_manager
    ->getFeaturesInfo($extension));
  $this
    ->assertEquals([
    'test_feature' => $extension,
  ], $features_manager
    ->getFeaturesModules($bundle));
  $this
    ->assertInstanceOf(Package::class, $package);
  $this
    ->assertEquals([
    'bundle' => 'test',
    'excluded' => [
      0 => 'system.theme',
    ],
    'required' => TRUE,
  ], $package
    ->getFeaturesInfo());
  $this
    ->assertEquals('test', $package
    ->getBundle());
  $this
    ->assertEquals(TRUE, $package
    ->getRequired());
  $this
    ->assertEquals([
    'system.theme',
  ], $package
    ->getExcluded());
}