Initial commit

This commit is contained in:
2024-09-13 14:11:34 +02:00
commit a14f7077bb
31 changed files with 1901 additions and 0 deletions

View File

@ -0,0 +1,70 @@
<?php
use Pdahal\Xmpp\Buffers\Response;
use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
class ResponseBufferTest extends TestCase
{
public Response $buffer;
protected function setUp(): void
{
$this->buffer = new Response();
}
public function testWriteString(): void
{
$this->buffer->write('test');
$this->assertEquals(['test'], $this->buffer->getCurrentBufferData());
}
public function testWriteNumber(): void
{
$this->buffer->write(123);
$this->assertEquals(['123'], $this->buffer->getCurrentBufferData());
}
public function testWriteEmpty(): void
{
$this->buffer->write('');
$this->assertEquals([], $this->buffer->getCurrentBufferData());
}
public function testWriteNull(): void
{
$this->buffer->write(null);
$this->assertEquals([], $this->buffer->getCurrentBufferData());
}
public function testRead(): void
{
$this->buffer->write('test');
$response = $this->buffer->read();
$this->assertEquals('test', $response);
}
public function testReadNullInput(): void
{
$this->buffer->write(null);
$response = $this->buffer->read();
$this->assertEquals('', $response);
}
public function testFlushWithInput(): void
{
$this->buffer->write('test');
$this->buffer->read();
$this->assertEquals([], $this->buffer->getCurrentBufferData());
}
public function testFlushWithoutInput(): void
{
$this->buffer->read();
$this->assertEquals([], $this->buffer->getCurrentBufferData());
}
}