RngEventTypeEntityTest.php in RNG - Events and Registrations 8.2
File
tests/src/Kernel/RngEventTypeEntityTest.php
View source
<?php
namespace Drupal\Tests\rng\Kernel;
use Drupal\rng\Entity\RngEventType;
class RngEventTypeEntityTest extends RngKernelTestBase {
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);
}
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);
}
public function testGetIdentityTypeEntityFormModes() {
$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
->getIdentityTypeEntityFormModes();
$this
->assertEquals($people_type['entity_form_mode'], $result[$people_type['entity_type']][$people_type['bundle']]);
}
public function testGetIdentityTypeEntityFormModesNoDefaults() {
$values['people_types'][] = [
'entity_type' => $this
->randomMachineName(),
'bundle' => $this
->randomMachineName(),
];
$event_type = $this
->createEventTypeBase($values);
$result = $event_type
->getIdentityTypeEntityFormModes();
$this
->assertEquals([], $result);
}
public function testGetDefaultRegistrantType() {
$event_type = $this
->createEventTypeBase();
$registrant_type = $this
->randomMachineName();
$event_type
->setDefaultRegistrantType($registrant_type);
$this
->assertEquals($registrant_type, $event_type
->getDefaultRegistrantType());
}
public function testGetDefaultRegistrantTypeDefault() {
$event_type = $this
->createEventTypeBase();
$result = $event_type
->getDefaultRegistrantType();
$this
->assertNull($result);
}
protected function createEventTypeBase($values = []) {
$event_type = RngEventType::create($values + [
'id' => $this
->randomMachineName(),
'label' => $this
->randomMachineName(),
'entity_type' => 'entity_test',
'bundle' => 'entity_test',
]);
return $event_type;
}
}