BundleCRUDTest.php in Entity Construction Kit (ECK) 8
File
tests/src/Functional/BundleCRUDTest.php
View source
<?php
namespace Drupal\Tests\eck\Functional;
class BundleCRUDTest extends FunctionalTestBase {
public function singleBundleCreation() {
$entityTypeInfo = $this
->createEntityType([], 'TestType');
$this
->createEntityBundle($entityTypeInfo['id'], 'TestBundle');
}
public function singleBundleCreationWithOverrides() {
$entityTypeInfo = $this
->createEntityType();
$title_overrides = [];
foreach ($this
->getConfigurableBaseFields() as $field) {
$title_overrides[$field] = $this
->randomMachineName(16);
}
$this
->createEntityBundle($entityTypeInfo['id'], '', $title_overrides);
}
public function singleBundleEditWithOverrides() {
$entityTypeInfo = $this
->createEntityType();
$title_overrides = [];
foreach ($this
->getConfigurableBaseFields() as $field) {
$title_overrides[$field] = $this
->randomMachineName(16);
}
$bundle_info = $this
->createEntityBundle($entityTypeInfo['id'], '', $title_overrides);
$new_title_overrides = [];
foreach ($this
->getConfigurableBaseFields() as $field) {
$new_title_overrides[$field] = $this
->randomMachineName(16);
}
$this
->editEntityBundle($entityTypeInfo['id'], $bundle_info['type'], $this
->randomMachineName(16), $new_title_overrides);
}
public function multipleBundleCreation() {
$entityTypeInfo = $this
->createEntityType([], 'TestType');
$this
->createEntityBundle($entityTypeInfo['id'], 'TestBundle1');
$this
->createEntityBundle($entityTypeInfo['id'], 'TestBundle2');
}
public function identicallyNamedBundleCreation() {
$entityTypeInfo1 = $this
->createEntityType([], 'TestType1');
$entityTypeInfo2 = $this
->createEntityType([], 'TestType2');
$this
->createEntityBundle($entityTypeInfo1['id'], 'TheBundle');
$this
->createEntityBundle($entityTypeInfo2['id'], 'TheBundle');
}
}