diff --git a/config/schema/features.schema.yml b/config/schema/features.schema.yml index 1679c2f..7917116 100644 --- a/config/schema/features.schema.yml +++ b/config/schema/features.schema.yml @@ -21,6 +21,10 @@ features.bundle.*: profile_name: type: string label: "Profile name" + weights: + type: mapping + mapping: + type: int is_profile: type: boolean label: "Is install profile" diff --git a/src/Entity/FeaturesBundle.php b/src/Entity/FeaturesBundle.php index c0c2bea..b4f95b4 100644 --- a/src/Entity/FeaturesBundle.php +++ b/src/Entity/FeaturesBundle.php @@ -96,7 +96,7 @@ class FeaturesBundle extends ConfigEntityBase implements FeaturesBundleInterface * {@inheritdoc} */ public function isDefault() { - return $this->machine_name == ''; + return $this->machine_name == 'default'; } /** diff --git a/src/FeaturesAssigner.php b/src/FeaturesAssigner.php index 3704cae..75886bf 100644 --- a/src/FeaturesAssigner.php +++ b/src/FeaturesAssigner.php @@ -8,8 +8,8 @@ namespace Drupal\features; use Drupal\Component\Plugin\PluginManagerInterface; +use Drupal\features\Entity\FeaturesBundle; use Drupal\features\FeaturesManagerInterface; -use Drupal\features\FeaturesBundle; use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Config\StorageInterface; @@ -283,7 +283,7 @@ class FeaturesAssigner implements FeaturesAssignerInterface { * {@inheritdoc} */ public function createBundle($name, $machine_name = NULL, $description = NULL, $is_profile = FALSE, $profile_name = NULL) { - $bundle = \Drupal\features\Entity\FeaturesBundle::create([]); + $bundle = FeaturesBundle::create([]); if (empty($machine_name)) { $machine_name = strtolower(str_replace(array(' ', '-'), '_', $name)); } diff --git a/tests/src/Kernel/Entity/FeaturesBundleIntegrationTest.php b/tests/src/Kernel/Entity/FeaturesBundleIntegrationTest.php new file mode 100644 index 0000000..8d0be48 --- /dev/null +++ b/tests/src/Kernel/Entity/FeaturesBundleIntegrationTest.php @@ -0,0 +1,65 @@ + 'test', + 'name' => 'Test', + ]); + $bundle->save(); + + /** @var \Drupal\features\Entity\FeaturesBundle $bundle */ + $bundle = FeaturesBundle::load('test'); + $this->assertEquals('Test', $bundle->getName()); + } + + /** + * @covers ::isDefault + */ + public function testIsDefaultWithDefaultBundle() { + $bundle = FeaturesBundle::create([ + 'machine_name' => 'default', + ]); + + $this->assertTrue($bundle->isDefault()); + } + + /** + * @covers ::isDefault + */ + public function testIsDefaultWithNonDefaultBundle() { + $bundle = FeaturesBundle::create([ + 'machine_name' => 'other', + ]); + + $this->assertFalse($bundle->isDefault()); + } + + /** + * @covers ::getFullName + */ + public function testGetFullName() { + } + + /** + * @covers ::getShortName + */ + public function testGetShortName() { + } + +}