public function RadioactivityProcessorTest::testProcessIncidents in Radioactivity 8.3
Same name and namespace in other branches
- 4.0.x tests/src/Unit/RadioactivityProcessorTest.php \Drupal\Tests\radioactivity\Unit\RadioactivityProcessorTest::testProcessIncidents()
@covers ::processIncidents
File
- tests/
src/ Unit/ RadioactivityProcessorTest.php, line 286
Class
- RadioactivityProcessorTest
- @coversDefaultClass \Drupal\radioactivity\RadioactivityProcessor @group radioactivity
Namespace
Drupal\Tests\radioactivity\UnitCode
public function testProcessIncidents() {
$incidentsByType['entity_type_a'] = [
'incidentA1',
'incidentA2',
'incidentA3',
];
$incidentsByType['entity_type_b'] = [
'incidentB1',
'incidentB2',
'incidentB3',
'incidentB4',
'incidentB5',
'incidentB6',
'incidentB7',
'incidentB8',
'incidentB9',
'incidentB10',
'incidentB11',
'incidentB12',
];
$this->incidentStorage
->getIncidentsByType()
->willReturn($incidentsByType);
$this->incidentStorage
->clearIncidents()
->shouldBeCalled();
$queue = $this
->prophesize(QueueInterface::class);
$this->queueFactory
->get(RadioactivityProcessorInterface::QUEUE_WORKER_INCIDENTS)
->willReturn($queue
->reveal());
$queue
->createItem([
'entity_type' => 'entity_type_a',
'incidents' => [
0 => 'incidentA1',
1 => 'incidentA2',
2 => 'incidentA3',
],
])
->shouldBeCalledTimes(1);
$queue
->createItem([
'entity_type' => 'entity_type_b',
'incidents' => [
0 => 'incidentB1',
1 => 'incidentB2',
2 => 'incidentB3',
3 => 'incidentB4',
4 => 'incidentB5',
5 => 'incidentB6',
6 => 'incidentB7',
7 => 'incidentB8',
8 => 'incidentB9',
9 => 'incidentB10',
],
])
->shouldBeCalledTimes(1);
$queue
->createItem([
'entity_type' => 'entity_type_b',
'incidents' => [
10 => 'incidentB11',
11 => 'incidentB12',
],
])
->shouldBeCalledTimes(1);
$this->loggerChannel
->notice('Processed @count radioactivity incidents.', [
'@count' => 15,
])
->shouldBeCalled();
$this->sut
->processIncidents();
}