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

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

parent ba502d5a
No related branches found
No related tags found
1 merge request!295Resolve #3489690 "Add an event"
<?php
namespace Drupal\Tests\ai\Unit\Event;
use Drupal\ai\Event\PostStreamingResponseEvent;
use PHPUnit\Framework\TestCase;
/**
* Tests that the event function works.
*
* @group ai
* @covers \Drupal\ai\Event\PostStreamingResponseEvent
*/
class PostStreamingResponseEventTest extends TestCase {
/**
* Test get event id.
*/
public function testEventId(): void {
$event = $this->getEvent();
$this->assertEquals('unique_id', $event->getRequestThreadId());
}
/**
* Test get response.
*/
public function testResponse(): void {
$event = $this->getEvent();
$this->assertEquals('test', $event->getOutput());
}
/**
* Helper function to get the events.
*
* @return \Drupal\ai\Event\PostStreamingResponseEvent|\PHPUnit\Framework\MockObject\MockObject
* The event.
*/
public function getEvent(): PostStreamingResponseEvent {
return new PostStreamingResponseEvent('unique_id', 'test', [
'test' => 'test',
]);
}
}
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