mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-15 16:07:55 +03:00
Clean-up tests and use PHPStan max level for tests
This commit is contained in:
@@ -8,24 +8,26 @@ use Ramsey\Uuid\Codec\StringCodec;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\UuidInterface;
|
||||
|
||||
/**
|
||||
* Class StringCodecTest
|
||||
* @package Ramsey\Uuid\Test\Codec
|
||||
* @covers Ramsey\Uuid\Codec\StringCodec
|
||||
*/
|
||||
class StringCodecTest extends TestCase
|
||||
{
|
||||
|
||||
/** @var UuidBuilderInterface&MockObject */
|
||||
/**
|
||||
* @var UuidBuilderInterface & MockObject
|
||||
*/
|
||||
private $builder;
|
||||
|
||||
/** @var UuidInterface&MockObject */
|
||||
/**
|
||||
* @var UuidInterface & MockObject
|
||||
*/
|
||||
private $uuid;
|
||||
|
||||
/** @var array */
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $fields;
|
||||
|
||||
/** @var string */
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $uuidString = '12345678-1234-abcd-abef-1234abcd4321';
|
||||
|
||||
protected function setUp(): void
|
||||
@@ -47,7 +49,7 @@ class StringCodecTest extends TestCase
|
||||
unset($this->builder, $this->uuid, $this->fields);
|
||||
}
|
||||
|
||||
public function testEncodeUsesFieldsArray()
|
||||
public function testEncodeUsesFieldsArray(): void
|
||||
{
|
||||
$this->uuid->expects($this->once())
|
||||
->method('getFieldsHex')
|
||||
@@ -56,7 +58,7 @@ class StringCodecTest extends TestCase
|
||||
$codec->encode($this->uuid);
|
||||
}
|
||||
|
||||
public function testEncodeReturnsFormattedString()
|
||||
public function testEncodeReturnsFormattedString(): void
|
||||
{
|
||||
$this->uuid->method('getFieldsHex')
|
||||
->willReturn($this->fields);
|
||||
@@ -65,7 +67,7 @@ class StringCodecTest extends TestCase
|
||||
$this->assertEquals($this->uuidString, $result);
|
||||
}
|
||||
|
||||
public function testEncodeBinaryUsesHexadecimalValue()
|
||||
public function testEncodeBinaryUsesHexadecimalValue(): void
|
||||
{
|
||||
$this->uuid->expects($this->once())
|
||||
->method('getHex')
|
||||
@@ -74,7 +76,7 @@ class StringCodecTest extends TestCase
|
||||
$codec->encodeBinary($this->uuid);
|
||||
}
|
||||
|
||||
public function testEncodeBinaryReturnsBinaryString()
|
||||
public function testEncodeBinaryReturnsBinaryString(): void
|
||||
{
|
||||
$expected = hex2bin('123456781234abcdabef1234abcd4321');
|
||||
$this->uuid->method('getHex')
|
||||
@@ -84,7 +86,7 @@ class StringCodecTest extends TestCase
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testDecodeUsesBuilderOnFields()
|
||||
public function testDecodeUsesBuilderOnFields(): void
|
||||
{
|
||||
$string = 'uuid:12345678-1234-abcd-abef-1234abcd4321';
|
||||
$this->builder->expects($this->once())
|
||||
@@ -94,7 +96,7 @@ class StringCodecTest extends TestCase
|
||||
$codec->decode($string);
|
||||
}
|
||||
|
||||
public function testDecodeThrowsExceptionOnInvalidUuid()
|
||||
public function testDecodeThrowsExceptionOnInvalidUuid(): void
|
||||
{
|
||||
$string = 'invalid-uuid';
|
||||
$codec = new StringCodec($this->builder);
|
||||
@@ -103,7 +105,7 @@ class StringCodecTest extends TestCase
|
||||
$codec->decode($string);
|
||||
}
|
||||
|
||||
public function testDecodeReturnsUuidFromBuilder()
|
||||
public function testDecodeReturnsUuidFromBuilder(): void
|
||||
{
|
||||
$string = 'uuid:12345678-1234-abcd-abef-1234abcd4321';
|
||||
$this->builder->method('build')
|
||||
@@ -113,7 +115,7 @@ class StringCodecTest extends TestCase
|
||||
$this->assertEquals($this->uuid, $result);
|
||||
}
|
||||
|
||||
public function testDecodeBytesThrowsExceptionWhenBytesStringNotSixteenCharacters()
|
||||
public function testDecodeBytesThrowsExceptionWhenBytesStringNotSixteenCharacters(): void
|
||||
{
|
||||
$string = '61';
|
||||
$bytes = pack('H*', $string);
|
||||
@@ -124,7 +126,7 @@ class StringCodecTest extends TestCase
|
||||
$codec->decodeBytes($bytes);
|
||||
}
|
||||
|
||||
public function testDecodeBytesReturnsUuid()
|
||||
public function testDecodeBytesReturnsUuid(): void
|
||||
{
|
||||
$string = '123456781234abcdabef1234abcd4321';
|
||||
$bytes = pack('H*', $string);
|
||||
|
||||
Reference in New Issue
Block a user