Initial commit
This commit is contained in:
70
tests/ResponseBufferTest.php
Normal file
70
tests/ResponseBufferTest.php
Normal 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());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user