Skip to content
This repository was archived by the owner on Feb 23, 2020. It is now read-only.

EventType::getIdentityTypeEntityFormMode() should return a form mode string #153

Open
wants to merge 2 commits into
base: 8.x-1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Entity/EventType.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function setIdentityTypeCreate($entity_type, $bundle, $enabled) {
*/
public function getIdentityTypeEntityFormMode($entity_type, $bundle) {
$key = $this->getIdentityTypeKey($entity_type, $bundle);
return !empty($this->people_types[$key]['entity_form_mode']);
return !empty($this->people_types[$key]['entity_form_mode']) ? $this->people_types[$key]['entity_form_mode'] : 'default';
}

/**
Expand Down
35 changes: 35 additions & 0 deletions tests/src/Kernel/RngEventTypeEntityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,41 @@
*/
class RngEventTypeEntityTest extends RngKernelTestBase {

/**
* Tests getting a single identity type form mode.
*
* @covers ::getIdentityTypeEntityFormMode
*/
public function testGetIdentityTypeEntityFormMode() {
$people_type = [
'entity_type' => $this->randomMachineName(),
'bundle' => $this->randomMachineName(),
'entity_form_mode' => $this->randomMachineName(),
];
$values['people_types'][] = $people_type;
$event_type = $this->createEventTypeBase($values);

$result = $event_type->getIdentityTypeEntityFormMode($people_type['entity_type'], $people_type['bundle']);
$this->assertEquals($people_type['entity_form_mode'], $result);
}

/**
* Tests getting a single identity type form mode when no defaults set.
*
* @covers ::getIdentityTypeEntityFormMode
*/
public function testGetIdentityTypeEntityFormModeNoDefaults() {
$people_type = [
'entity_type' => $this->randomMachineName(),
'bundle' => $this->randomMachineName(),
];
$values['people_types'][] = $people_type;
$event_type = $this->createEventTypeBase($values);

$result = $event_type->getIdentityTypeEntityFormMode($people_type['entity_type'], $people_type['bundle']);
$this->assertEquals('default', $result);
}

/**
* Test getting all identity type form modes.
*
Expand Down