protected function ProfileRevisionTest::setUp in Profile 8
@inheritDoc
Overrides ProfileTestBase::setUp
File
- tests/
src/ Functional/ ProfileRevisionTest.php, line 28
Class
- ProfileRevisionTest
- Tests using revisions with profiles.
Namespace
Drupal\Tests\profile\FunctionalCode
protected function setUp() {
parent::setUp();
$use_revisions_type = ProfileType::create([
'id' => $this
->randomMachineName(),
'label' => $this
->randomMachineName(),
'allow_revisions' => TRUE,
'new_revision' => TRUE,
]);
$use_revisions_type
->save();
$this->useRevisionsType = $use_revisions_type;
$use_revisions_fullname_field = FieldConfig::create([
'field_storage' => $this->field
->getFieldStorageDefinition(),
'bundle' => $this->useRevisionsType
->id(),
'label' => 'Full name',
]);
$use_revisions_fullname_field
->save();
// Configure the default display.
$use_revisions_display = EntityViewDisplay::load("profile.{$this->useRevisionsType->id()}.default");
if (!$use_revisions_display) {
$use_revisions_display = EntityViewDisplay::create([
'targetEntityType' => 'profile',
'bundle' => $this->useRevisionsType
->id(),
'mode' => 'default',
'status' => TRUE,
]);
$use_revisions_display
->save();
}
$use_revisions_display
->setComponent($this->field
->getName(), [
'type' => 'string',
])
->save();
// Configure the default form.
$use_revisions_form = EntityFormDisplay::load("profile.{$this->useRevisionsType->id()}.default");
if (!$use_revisions_form) {
$use_revisions_form = EntityFormDisplay::create([
'targetEntityType' => 'profile',
'bundle' => $this->useRevisionsType
->id(),
'mode' => 'default',
'status' => TRUE,
]);
$this->form
->save();
}
$use_revisions_form
->setComponent($this->field
->getName(), [
'type' => 'string_textfield',
])
->save();
}