public function RngMessageRules::testRngRegistrationUpdateMessages in RNG - Events and Registrations 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/RngMessageRules.php \Drupal\Tests\rng\Kernel\RngMessageRules::testRngRegistrationUpdateMessages()
- 3.x tests/src/Kernel/RngMessageRules.php \Drupal\Tests\rng\Kernel\RngMessageRules::testRngRegistrationUpdateMessages()
Test messages are sent on registration update.
File
- tests/
src/ Kernel/ RngMessageRules.php, line 138
Class
- RngMessageRules
- Tests RNG message rules are executed.
Namespace
Drupal\Tests\rng\KernelCode
public function testRngRegistrationUpdateMessages() {
$this->rule
->set('trigger_id', 'entity:registration:update');
$this->rule
->save();
/** @var \Drupal\rng\RngEntityModelInterface $rngEntityModel */
$rngEntityModel = $this->container
->get('rng.entity.model');
$event = $this->eventMeta
->getEvent();
$this
->assertEquals(0, count($rngEntityModel
->getOperationRecords()), 'There are zero entity operations recorded.');
$identity = $this
->createUser();
$registration = Registration::create([
'type' => $this->registrationType
->id(),
]);
$registration
->setEvent($event)
->addIdentity($identity)
->save();
$this
->terminateRequest();
$this
->assertEquals(1, count($rngEntityModel
->getOperationRecords()), 'There is one entity operation recorded.');
$this
->assertEquals(0, $this
->countMessagesInQueue(), 'There are zero messages in queue.');
$registration
->save();
$this
->terminateRequest();
// Two operations, insert and update.
$this
->assertEquals(2, count($rngEntityModel
->getOperationRecords()), 'There is two entity operations recorded.');
$this
->assertEquals(1, $this
->countMessagesInQueue(), 'There is one message in queue.');
}