RngWebTestBase.php in RNG - Events and Registrations 3.x
File
src/Tests/RngWebTestBase.php
View source
<?php
namespace Drupal\rng\Tests;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\rng\Entity\Registration;
use Drupal\Tests\BrowserTestBase;
abstract class RngWebTestBase extends BrowserTestBase {
use RngTestTrait {
RngTestTrait::createEventType as traitCreateEventType;
}
public static $modules = [
'rng',
];
protected $eventManager;
protected function setUp() {
parent::setUp();
$this->eventManager = $this->container
->get('rng.event_manager');
}
public function createEventType($entity_type_id, $bundle, $values = []) {
$event_type = $this
->traitCreateEventType($entity_type_id, $bundle, $values);
\Drupal::service('router.builder')
->rebuildIfNeeded();
return $event_type;
}
public function createEntity(ConfigEntityInterface $entity_type, $settings = []) {
$entity = $this
->drupalCreateNode([
'type' => $entity_type
->id(),
] + $settings);
return $entity;
}
public function createRegistration(ContentEntityInterface $event, $registration_type_id) {
$registration = Registration::create([
'type' => $registration_type_id,
])
->setEvent($event);
$registration
->save();
return $registration;
}
}