Skip to content
Snippets Groups Projects
Commit 325baac2 authored by Marcus Johansson's avatar Marcus Johansson
Browse files

Issue #3489690: Add an event that triggers on chat iterator consumption

parent 38b04148
No related branches found
No related tags found
1 merge request!295Resolve #3489690 "Add an event"
......@@ -11,20 +11,6 @@ use Drupal\ai\OperationType\Chat\StreamedChatMessageIteratorInterface;
*/
class MockStreamedChatIterator extends StreamedChatMessageIterator implements StreamedChatMessageIteratorInterface {
/**
* The iterator.
*
* @var \IteratorAggregate
*/
private $iterator;
/**
* {@inheritdoc}
*/
public function __construct(\IteratorAggregate $iterator) {
$this->iterator = $iterator;
}
/**
* Get the iterator.
*
......
......@@ -114,6 +114,14 @@ class PostGenerateResponseEventTest extends TestCase {
$this->assertEquals('It is not!', $event->getOutput());
}
/**
* Test get event id.
*/
public function testEventId(): void {
$event = $this->getEvent();
$this->assertEquals('unique_id', $event->getEventId());
}
/**
* Helper function to get the events.
*
......@@ -121,7 +129,7 @@ class PostGenerateResponseEventTest extends TestCase {
* The event.
*/
public function getEvent(): PostGenerateResponseEvent {
return new PostGenerateResponseEvent('test', 'chat', [
return new PostGenerateResponseEvent('unique_id', 'test', 'chat', [
'test' => 'testing',
],
'This is a test',
......
......@@ -97,6 +97,14 @@ class PreGenerateResponseEventTest extends TestCase {
], $event->getConfiguration());
}
/**
* Test get event id.
*/
public function testEventId(): void {
$event = $this->getEvent();
$this->assertEquals('unique_id', $event->getEventId());
}
/**
* Helper function to get the events.
*
......@@ -105,6 +113,7 @@ class PreGenerateResponseEventTest extends TestCase {
*/
public function getEvent(): PreGenerateResponseEvent {
return new PreGenerateResponseEvent(
'unique_id',
'test',
'chat',
[
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment