mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
chore(deps-dev): upgrade PHPUnit to v11.5
This commit is contained in:
+1
-1
@@ -27,7 +27,7 @@
|
||||
"phpstan/phpstan": "^2.1",
|
||||
"phpstan/phpstan-mockery": "^2.0",
|
||||
"phpstan/phpstan-phpunit": "^2.0",
|
||||
"phpunit/phpunit": "^9.6",
|
||||
"phpunit/phpunit": "^11.5",
|
||||
"slevomat/coding-standard": "^8.18",
|
||||
"squizlabs/php_codesniffer": "^3.13"
|
||||
},
|
||||
|
||||
Generated
+313
-354
File diff suppressed because it is too large
Load Diff
+6
-10
@@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd"
|
||||
bootstrap="./tests/bootstrap.php"
|
||||
cacheResultFile="./build/cache/phpunit.result.cache"
|
||||
bootstrap="./vendor/autoload.php"
|
||||
colors="true"
|
||||
verbose="true">
|
||||
cacheDirectory="./build/cache/phpunit">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="unit-tests">
|
||||
@@ -12,15 +11,12 @@
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
<coverage processUncoveredFiles="true">
|
||||
<coverage/>
|
||||
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./src</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
|
||||
<php>
|
||||
<!-- E_ALL & ~E_DEPRECATED -->
|
||||
<ini name="error_reporting" value="24575"/>
|
||||
</php>
|
||||
</source>
|
||||
|
||||
</phpunit>
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\BinaryUtils;
|
||||
use Ramsey\Uuid\Rfc4122\Version;
|
||||
use Ramsey\Uuid\Variant;
|
||||
@@ -14,18 +15,14 @@ use function hex2bin;
|
||||
|
||||
class BinaryUtilsTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideVersionTestValues
|
||||
*/
|
||||
#[DataProvider('provideVersionTestValues')]
|
||||
public function testApplyVersion(int $timeHi, Version $version, int $expectedInt, string $expectedHex): void
|
||||
{
|
||||
$this->assertSame($expectedInt, BinaryUtils::applyVersion($timeHi, $version));
|
||||
$this->assertSame($expectedHex, dechex(BinaryUtils::applyVersion($timeHi, $version)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideVariantTestValues
|
||||
*/
|
||||
#[DataProvider('provideVariantTestValues')]
|
||||
public function testApplyVariant(int $clockSeq, Variant $variant, int $expectedInt, string $expectedHex): void
|
||||
{
|
||||
$this->assertSame($expectedInt, BinaryUtils::applyVariant($clockSeq, $variant));
|
||||
@@ -34,9 +31,8 @@ class BinaryUtilsTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $bytes
|
||||
*
|
||||
* @dataProvider provideVersionAndVariantTestValues
|
||||
*/
|
||||
#[DataProvider('provideVersionAndVariantTestValues')]
|
||||
public function testApplyVersionAndVariant(
|
||||
string $bytes,
|
||||
Version $version,
|
||||
@@ -48,7 +44,7 @@ class BinaryUtilsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{timeHi: int, version: Version, expectedInt: int, expectedHex: non-empty-string}>
|
||||
*/
|
||||
public function provideVersionTestValues(): array
|
||||
public static function provideVersionTestValues(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -201,7 +197,7 @@ class BinaryUtilsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{clockSeq: int, variant: Variant, expectedInt: int, expectedHex: non-empty-string}>
|
||||
*/
|
||||
public function provideVariantTestValues(): array
|
||||
public static function provideVariantTestValues(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -330,7 +326,7 @@ class BinaryUtilsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{bytes: non-empty-string, version: Version, expectedHex: non-empty-string}>
|
||||
*/
|
||||
public function provideVersionAndVariantTestValues(): array
|
||||
public static function provideVersionAndVariantTestValues(): array
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
$bytes = hex2bin('426a25b74e975e743af1700fa4e42455');
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Builder;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Builder\FallbackBuilder;
|
||||
use Ramsey\Uuid\Builder\UuidBuilderInterface;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
@@ -63,9 +64,8 @@ class FallbackBuilderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $bytes
|
||||
*
|
||||
* @dataProvider provideBytes
|
||||
*/
|
||||
#[DataProvider('provideBytes')]
|
||||
public function testSerializationOfBuilderCollection(string $bytes): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -121,7 +121,7 @@ class FallbackBuilderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{bytes: string}>
|
||||
*/
|
||||
public function provideBytes(): array
|
||||
public static function provideBytes(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Converter\Time;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Converter\Time\GenericTimeConverter;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -15,9 +16,8 @@ class GenericTimeConverterTest extends TestCase
|
||||
* @param numeric-string $seconds
|
||||
* @param numeric-string $microseconds
|
||||
* @param non-empty-string $expected
|
||||
*
|
||||
* @dataProvider provideCalculateTime
|
||||
*/
|
||||
#[DataProvider('provideCalculateTime')]
|
||||
public function testCalculateTime(string $seconds, string $microseconds, string $expected): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -31,7 +31,7 @@ class GenericTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @return array<array{seconds: numeric-string, microseconds: numeric-string, expected: non-empty-string}>
|
||||
*/
|
||||
public function provideCalculateTime(): array
|
||||
public static function provideCalculateTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -86,9 +86,8 @@ class GenericTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @param numeric-string $unixTimestamp
|
||||
* @param numeric-string $microseconds
|
||||
*
|
||||
* @dataProvider provideConvertTime
|
||||
*/
|
||||
#[DataProvider('provideConvertTime')]
|
||||
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -103,7 +102,7 @@ class GenericTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: numeric-string, microseconds: numeric-string}>
|
||||
*/
|
||||
public function provideConvertTime(): array
|
||||
public static function provideConvertTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Converter\Time;
|
||||
|
||||
use Brick\Math\BigInteger;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Converter\Time\GenericTimeConverter;
|
||||
use Ramsey\Uuid\Converter\Time\PhpTimeConverter;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
@@ -79,9 +80,8 @@ class PhpTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @param numeric-string $unixTimestamp
|
||||
* @param numeric-string $microseconds
|
||||
*
|
||||
* @dataProvider provideConvertTime
|
||||
*/
|
||||
#[DataProvider('provideConvertTime')]
|
||||
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -97,7 +97,7 @@ class PhpTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: numeric-string, microseconds: numeric-string}>
|
||||
*/
|
||||
public function provideConvertTime(): array
|
||||
public static function provideConvertTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -147,9 +147,8 @@ class PhpTimeConverterTest extends TestCase
|
||||
* @param numeric-string $seconds
|
||||
* @param numeric-string $microseconds
|
||||
* @param non-empty-string $expected
|
||||
*
|
||||
* @dataProvider provideCalculateTime
|
||||
*/
|
||||
#[DataProvider('provideCalculateTime')]
|
||||
public function testCalculateTime(string $seconds, string $microseconds, string $expected): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -164,7 +163,7 @@ class PhpTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @return array<array{seconds: numeric-string, microseconds: numeric-string, expected: non-empty-string}>
|
||||
*/
|
||||
public function provideCalculateTime(): array
|
||||
public static function provideCalculateTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Converter\Time;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Converter\Time\UnixTimeConverter;
|
||||
use Ramsey\Uuid\Math\BrickMathCalculator;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -11,9 +12,7 @@ use Ramsey\Uuid\Type\Hexadecimal;
|
||||
|
||||
class UnixTimeConverterTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideConvertTime
|
||||
*/
|
||||
#[DataProvider('provideConvertTime')]
|
||||
public function testConvertTime(Hexadecimal $uuidTimestamp, string $unixTimestamp, string $microseconds): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -28,7 +27,7 @@ class UnixTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uuidTimestamp: Hexadecimal, unixTimestamp: string, microseconds: string}>
|
||||
*/
|
||||
public function provideConvertTime(): array
|
||||
public static function provideConvertTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -106,9 +105,8 @@ class UnixTimeConverterTest extends TestCase
|
||||
* @param numeric-string $seconds
|
||||
* @param numeric-string $microseconds
|
||||
* @param non-empty-string $expected
|
||||
*
|
||||
* @dataProvider provideCalculateTime
|
||||
*/
|
||||
#[DataProvider('provideCalculateTime')]
|
||||
public function testCalculateTime(string $seconds, string $microseconds, string $expected): void
|
||||
{
|
||||
$calculator = new BrickMathCalculator();
|
||||
@@ -122,7 +120,7 @@ class UnixTimeConverterTest extends TestCase
|
||||
/**
|
||||
* @return array<array{seconds: numeric-string, microseconds: numeric-string, expected: non-empty-string}>
|
||||
*/
|
||||
public function provideCalculateTime(): array
|
||||
public static function provideCalculateTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace Ramsey\Uuid\Test;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
|
||||
use Ramsey\Uuid\Generator\CombGenerator;
|
||||
use Ramsey\Uuid\Generator\DefaultTimeGenerator;
|
||||
@@ -31,13 +35,12 @@ class ExpectedBehaviorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param mixed[] $args
|
||||
*
|
||||
* @dataProvider provideStaticCreationMethods
|
||||
*/
|
||||
#[DataProvider('provideStaticCreationMethods')]
|
||||
public function testStaticCreationMethodsAndStandardBehavior(string $method, array $args): void
|
||||
{
|
||||
/** @var UuidInterface $uuid */
|
||||
$uuid = call_user_func_array(['Ramsey\Uuid\Uuid', $method], $args);
|
||||
$uuid = Uuid::$method(...$args);
|
||||
|
||||
$this->assertIsInt($uuid->compareTo(Uuid::uuid1()));
|
||||
$this->assertNotSame(0, $uuid->compareTo(Uuid::uuid4()));
|
||||
@@ -85,7 +88,10 @@ class ExpectedBehaviorTest extends TestCase
|
||||
$this->assertSame(1, preg_match('/^\d+$/', (string) $uuid->getInteger()));
|
||||
}
|
||||
|
||||
public function provideStaticCreationMethods()
|
||||
/**
|
||||
* @return array<array{0: string, 1: mixed[]}>
|
||||
*/
|
||||
public static function provideStaticCreationMethods(): array
|
||||
{
|
||||
return [
|
||||
['uuid1', []],
|
||||
@@ -102,10 +108,10 @@ class ExpectedBehaviorTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
public function testUuidVersion1MethodBehavior()
|
||||
public function testUuidVersion1MethodBehavior(): void
|
||||
{
|
||||
/** @var UuidV1 $uuid */
|
||||
$uuid = Uuid::uuid1('00000fffffff', 0xffff);
|
||||
$uuid = Uuid::uuid1('00000fffffff', 0x3fff);
|
||||
|
||||
$this->assertInstanceOf('DateTimeInterface', $uuid->getDateTime());
|
||||
$this->assertSame('00000fffffff', $uuid->getFields()->getNode()->toString());
|
||||
@@ -113,15 +119,19 @@ class ExpectedBehaviorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideIsValid
|
||||
* @param non-empty-string $uuid
|
||||
*/
|
||||
public function testIsValid($uuid, $expected)
|
||||
#[DataProvider('provideIsValid')]
|
||||
public function testIsValid(string $uuid, bool $expected): void
|
||||
{
|
||||
$this->assertSame($expected, Uuid::isValid($uuid), "{$uuid} is not a valid UUID");
|
||||
$this->assertSame($expected, Uuid::isValid(strtoupper($uuid)), strtoupper($uuid) . ' is not a valid UUID');
|
||||
}
|
||||
|
||||
public function provideIsValid()
|
||||
/**
|
||||
* @return array<array{0: non-empty-string, 1: bool}>
|
||||
*/
|
||||
public static function provideIsValid(): array
|
||||
{
|
||||
return [
|
||||
// RFC 4122 UUIDs
|
||||
@@ -169,7 +179,7 @@ class ExpectedBehaviorTest extends TestCase
|
||||
// Invalid UUIDs
|
||||
['ffffffffffffffffffffffffffffffff', false],
|
||||
['00000000000000000000000000000000', false],
|
||||
[0, false],
|
||||
['0', false],
|
||||
['foobar', false],
|
||||
['ff6f8cb0c57d51e1bb210800200c9a66', false],
|
||||
['gf6f8cb0-c57d-51e1-bb21-0800200c9a66', false],
|
||||
@@ -177,9 +187,11 @@ class ExpectedBehaviorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFromStringInteger
|
||||
* @param non-empty-string $string
|
||||
* @param numeric-string $integer
|
||||
*/
|
||||
public function testSerialization(string $string): void
|
||||
#[DataProvider('provideFromStringInteger')]
|
||||
public function testSerialization(string $string, ?int $version, int $variant, string $integer): void
|
||||
{
|
||||
$uuid = Uuid::fromString($string);
|
||||
|
||||
@@ -194,18 +206,20 @@ class ExpectedBehaviorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFromStringInteger
|
||||
* @param non-empty-string $string
|
||||
* @param numeric-string $integer
|
||||
*/
|
||||
#[DataProvider('provideFromStringInteger')]
|
||||
public function testFromBytes(string $string, ?int $version, int $variant, string $integer): void
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
$bytes = hex2bin(str_replace('-', '', $string));
|
||||
|
||||
/** @var UuidInterface $uuid */
|
||||
$uuid = Uuid::fromBytes((string) $bytes);
|
||||
$uuid = Uuid::fromBytes($bytes);
|
||||
|
||||
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
|
||||
$this->assertSame($string, $uuid->toString());
|
||||
$this->assertSame(Version::tryFrom($version), $uuid->getFields()->getVersion());
|
||||
$this->assertSame(Version::tryFrom($version ?? 0), $uuid->getFields()->getVersion());
|
||||
$this->assertSame(Variant::from($variant), $uuid->getFields()->getVariant());
|
||||
|
||||
$components = explode('-', $string);
|
||||
@@ -224,8 +238,10 @@ class ExpectedBehaviorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFromStringInteger
|
||||
* @param non-empty-string $string
|
||||
* @param numeric-string $integer
|
||||
*/
|
||||
#[DataProvider('provideFromStringInteger')]
|
||||
public function testFromInteger(string $string, ?int $version, int $variant, string $integer): void
|
||||
{
|
||||
$bytes = hex2bin(str_replace('-', '', $string));
|
||||
@@ -233,9 +249,8 @@ class ExpectedBehaviorTest extends TestCase
|
||||
/** @var UuidInterface $uuid */
|
||||
$uuid = Uuid::fromInteger($integer);
|
||||
|
||||
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
|
||||
$this->assertSame($string, $uuid->toString());
|
||||
$this->assertSame(Version::tryFrom($version), $uuid->getFields()->getVersion());
|
||||
$this->assertSame(Version::tryFrom($version ?? 0), $uuid->getFields()->getVersion());
|
||||
$this->assertSame(Variant::from($variant), $uuid->getFields()->getVariant());
|
||||
|
||||
$components = explode('-', $string);
|
||||
@@ -254,8 +269,10 @@ class ExpectedBehaviorTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideFromStringInteger
|
||||
* @param non-empty-string $string
|
||||
* @param numeric-string $integer
|
||||
*/
|
||||
#[DataProvider('provideFromStringInteger')]
|
||||
public function testFromString(string $string, ?int $version, int $variant, string $integer): void
|
||||
{
|
||||
$bytes = hex2bin(str_replace('-', '', $string));
|
||||
@@ -263,9 +280,8 @@ class ExpectedBehaviorTest extends TestCase
|
||||
/** @var UuidInterface $uuid */
|
||||
$uuid = Uuid::fromString($string);
|
||||
|
||||
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
|
||||
$this->assertSame($string, $uuid->toString());
|
||||
$this->assertSame(Version::tryFrom($version), $uuid->getFields()->getVersion());
|
||||
$this->assertSame(Version::tryFrom($version ?? 0), $uuid->getFields()->getVersion());
|
||||
$this->assertSame(Variant::from($variant), $uuid->getFields()->getVariant());
|
||||
|
||||
$components = explode('-', $string);
|
||||
@@ -283,7 +299,10 @@ class ExpectedBehaviorTest extends TestCase
|
||||
$this->assertSame($bytes, $uuid->getBytes());
|
||||
}
|
||||
|
||||
public function provideFromStringInteger()
|
||||
/**
|
||||
* @return array<array{0: non-empty-string, 1: int | null, 2: int, 3: numeric-string}>
|
||||
*/
|
||||
public static function provideFromStringInteger(): array
|
||||
{
|
||||
return [
|
||||
['00000000-0000-0000-0000-000000000000', null, 2, '0'],
|
||||
@@ -323,29 +342,25 @@ class ExpectedBehaviorTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testGetSetFactory()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetSetFactory(): void
|
||||
{
|
||||
$this->assertInstanceOf('Ramsey\Uuid\UuidFactory', Uuid::getFactory());
|
||||
|
||||
$factory = \Mockery::mock('Ramsey\Uuid\UuidFactory');
|
||||
$factory = Mockery::mock('Ramsey\Uuid\UuidFactory');
|
||||
Uuid::setFactory($factory);
|
||||
|
||||
$this->assertSame($factory, Uuid::getFactory());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testFactoryProvidesFunctionality()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testFactoryProvidesFunctionality(): void
|
||||
{
|
||||
$uuid = \Mockery::mock('Ramsey\Uuid\UuidInterface');
|
||||
$uuid = Mockery::mock('Ramsey\Uuid\UuidInterface');
|
||||
|
||||
$factory = \Mockery::mock('Ramsey\Uuid\UuidFactoryInterface', [
|
||||
$factory = Mockery::mock('Ramsey\Uuid\UuidFactoryInterface', [
|
||||
'uuid1' => $uuid,
|
||||
'uuid3' => $uuid,
|
||||
'uuid4' => $uuid,
|
||||
@@ -357,24 +372,25 @@ class ExpectedBehaviorTest extends TestCase
|
||||
|
||||
Uuid::setFactory($factory);
|
||||
|
||||
$this->assertSame($uuid, Uuid::uuid1('ffffffffffff', 0xffff));
|
||||
/** @var non-empty-string $bytes */
|
||||
$bytes = hex2bin('ffffffffffffffffffffffffffffffff');
|
||||
|
||||
$this->assertSame($uuid, Uuid::uuid1('ffffffffffff', 0x3fff));
|
||||
$this->assertSame($uuid, Uuid::uuid3(Uuid::NAMESPACE_URL, 'https://example.com/foo'));
|
||||
$this->assertSame($uuid, Uuid::uuid4());
|
||||
$this->assertSame($uuid, Uuid::uuid5(Uuid::NAMESPACE_URL, 'https://example.com/foo'));
|
||||
$this->assertSame($uuid, Uuid::fromBytes(hex2bin('ffffffffffffffffffffffffffffffff')));
|
||||
$this->assertSame($uuid, Uuid::fromBytes($bytes));
|
||||
$this->assertSame($uuid, Uuid::fromString('ffffffff-ffff-ffff-ffff-ffffffffffff'));
|
||||
$this->assertSame($uuid, Uuid::fromInteger('340282366920938463463374607431768211455'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testUsingCustomCodec()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testUsingCustomCodec(): void
|
||||
{
|
||||
$mockUuid = \Mockery::mock('Ramsey\Uuid\UuidInterface');
|
||||
$mockUuid = Mockery::mock('Ramsey\Uuid\UuidInterface');
|
||||
|
||||
$codec = \Mockery::mock('Ramsey\Uuid\Codec\CodecInterface', [
|
||||
$codec = Mockery::mock('Ramsey\Uuid\Codec\CodecInterface', [
|
||||
'encode' => 'abcd1234',
|
||||
'encodeBinary' => hex2bin('abcd1234'),
|
||||
'decode' => $mockUuid,
|
||||
@@ -388,19 +404,20 @@ class ExpectedBehaviorTest extends TestCase
|
||||
|
||||
$uuid = Uuid::uuid4();
|
||||
|
||||
/** @var non-empty-string $bytes */
|
||||
$bytes = hex2bin('f00ba2');
|
||||
|
||||
$this->assertSame('abcd1234', $uuid->toString());
|
||||
$this->assertSame(hex2bin('abcd1234'), $uuid->getBytes());
|
||||
$this->assertSame($mockUuid, Uuid::fromString('f00ba2'));
|
||||
$this->assertSame($mockUuid, Uuid::fromBytes(hex2bin('f00ba2')));
|
||||
$this->assertSame($mockUuid, Uuid::fromBytes($bytes));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testUsingCustomRandomGenerator()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testUsingCustomRandomGenerator(): void
|
||||
{
|
||||
$generator = \Mockery::mock('Ramsey\Uuid\Generator\RandomGeneratorInterface', [
|
||||
$generator = Mockery::mock('Ramsey\Uuid\Generator\RandomGeneratorInterface', [
|
||||
'generate' => hex2bin('01234567abcd5432dcba0123456789ab'),
|
||||
]);
|
||||
|
||||
@@ -414,13 +431,11 @@ class ExpectedBehaviorTest extends TestCase
|
||||
$this->assertSame('01234567-abcd-4432-9cba-0123456789ab', $uuid->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testUsingCustomTimeGenerator()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testUsingCustomTimeGenerator(): void
|
||||
{
|
||||
$generator = \Mockery::mock('Ramsey\Uuid\Generator\TimeGeneratorInterface', [
|
||||
$generator = Mockery::mock('Ramsey\Uuid\Generator\TimeGeneratorInterface', [
|
||||
'generate' => hex2bin('01234567abcd5432dcba0123456789ab'),
|
||||
]);
|
||||
|
||||
@@ -434,24 +449,22 @@ class ExpectedBehaviorTest extends TestCase
|
||||
$this->assertSame('01234567-abcd-1432-9cba-0123456789ab', $uuid->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testUsingDefaultTimeGeneratorWithCustomProviders()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testUsingDefaultTimeGeneratorWithCustomProviders(): void
|
||||
{
|
||||
$nodeProvider = \Mockery::mock('Ramsey\Uuid\Provider\NodeProviderInterface', [
|
||||
$nodeProvider = Mockery::mock('Ramsey\Uuid\Provider\NodeProviderInterface', [
|
||||
'getNode' => new Hexadecimal('0123456789ab'),
|
||||
]);
|
||||
|
||||
$timeConverter = \Mockery::mock('Ramsey\Uuid\Converter\TimeConverterInterface');
|
||||
$timeConverter = Mockery::mock('Ramsey\Uuid\Converter\TimeConverterInterface');
|
||||
$timeConverter
|
||||
->shouldReceive('calculateTime')
|
||||
->andReturnUsing(function ($seconds, $microseconds) {
|
||||
->andReturnUsing(function (int $seconds, int $microseconds) {
|
||||
return new Hexadecimal('abcd' . dechex($microseconds) . dechex($seconds));
|
||||
});
|
||||
|
||||
$timeProvider = \Mockery::mock('Ramsey\Uuid\Provider\TimeProviderInterface', [
|
||||
$timeProvider = Mockery::mock('Ramsey\Uuid\Provider\TimeProviderInterface', [
|
||||
'currentTime' => [
|
||||
'sec' => 1578522046,
|
||||
'usec' => 10000,
|
||||
@@ -471,26 +484,24 @@ class ExpectedBehaviorTest extends TestCase
|
||||
$this->assertSame('5e1655be-2710-1bcd-8fff-0123456789ab', $uuid->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
public function testHelperFunctions()
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testHelperFunctions(): void
|
||||
{
|
||||
$uuid1 = \Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
$uuid1 = Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
'toString' => 'aVersion1Uuid',
|
||||
]);
|
||||
$uuid3 = \Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
$uuid3 = Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
'toString' => 'aVersion3Uuid',
|
||||
]);
|
||||
$uuid4 = \Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
$uuid4 = Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
'toString' => 'aVersion4Uuid',
|
||||
]);
|
||||
$uuid5 = \Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
$uuid5 = Mockery::mock('Ramsey\Uuid\UuidInterface', [
|
||||
'toString' => 'aVersion5Uuid',
|
||||
]);
|
||||
|
||||
$factory = \Mockery::mock('Ramsey\Uuid\UuidFactoryInterface', [
|
||||
$factory = Mockery::mock('Ramsey\Uuid\UuidFactoryInterface', [
|
||||
'uuid1' => $uuid1,
|
||||
'uuid3' => $uuid3,
|
||||
'uuid4' => $uuid4,
|
||||
@@ -499,7 +510,7 @@ class ExpectedBehaviorTest extends TestCase
|
||||
|
||||
Uuid::setFactory($factory);
|
||||
|
||||
$this->assertSame('aVersion1Uuid', \Ramsey\Uuid\v1('ffffffffffff', 0xffff));
|
||||
$this->assertSame('aVersion1Uuid', \Ramsey\Uuid\v1('ffffffffffff', 0x3fff));
|
||||
$this->assertSame('aVersion3Uuid', \Ramsey\Uuid\v3(Uuid::NAMESPACE_URL, 'https://example.com/foo'));
|
||||
$this->assertSame('aVersion4Uuid', \Ramsey\Uuid\v4());
|
||||
$this->assertSame('aVersion5Uuid', \Ramsey\Uuid\v5(Uuid::NAMESPACE_URL, 'https://example.com/foo'));
|
||||
@@ -508,7 +519,7 @@ class ExpectedBehaviorTest extends TestCase
|
||||
/**
|
||||
* @link https://git.io/JvJZo Use of TimestampFirstCombCodec in laravel/framework
|
||||
*/
|
||||
public function testUseOfTimestampFirstCombCodec()
|
||||
public function testUseOfTimestampFirstCombCodec(): void
|
||||
{
|
||||
$factory = new UuidFactory();
|
||||
|
||||
@@ -541,16 +552,13 @@ class ExpectedBehaviorTest extends TestCase
|
||||
$expectedHex = implode('', $fields);
|
||||
$expectedBytes = hex2bin($expectedHex);
|
||||
|
||||
$this->assertInstanceOf('Ramsey\Uuid\UuidInterface', $uuid);
|
||||
$this->assertSame(Variant::Rfc4122, $uuid->getFields()->getVariant());
|
||||
$this->assertSame(Version::Random, $uuid->getFields()->getVersion());
|
||||
$this->assertSame($expectedBytes, $uuid->getBytes());
|
||||
$this->assertSame($expectedHex, (string) $uuid->getHex());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideUuidConstantTests
|
||||
*/
|
||||
#[DataProvider('provideUuidConstantTests')]
|
||||
public function testUuidConstants(string $constantName, int | string $expected): void
|
||||
{
|
||||
$this->assertSame($expected, constant("Ramsey\\Uuid\\Uuid::{$constantName}"));
|
||||
@@ -559,7 +567,7 @@ class ExpectedBehaviorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{string, int | string}>
|
||||
*/
|
||||
public function provideUuidConstantTests(): array
|
||||
public static function provideUuidConstantTests(): array
|
||||
{
|
||||
return [
|
||||
['NAMESPACE_DNS', '6ba7b810-9dad-11d1-80b4-00c04fd430c8'],
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
@@ -85,16 +86,15 @@ class CombGeneratorTest extends TestCase
|
||||
/**
|
||||
* @return array<array<positive-int>>
|
||||
*/
|
||||
public function lengthLessThanSix(): array
|
||||
public static function lengthLessThanSix(): array
|
||||
{
|
||||
return [[1], [2], [3], [4], [5]];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param positive-int $length
|
||||
*
|
||||
* @dataProvider lengthLessThanSix
|
||||
*/
|
||||
#[DataProvider('lengthLessThanSix')]
|
||||
public function testGenerateWithLessThanTimestampBytesThrowsException(int $length): void
|
||||
{
|
||||
/** @var MockObject & RandomGeneratorInterface $randomGenerator */
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Converter\Number\GenericNumberConverter;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\Time\GenericTimeConverter;
|
||||
@@ -30,9 +31,8 @@ class DceSecurityGeneratorTest extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $node
|
||||
* @param positive-int $providedDomain
|
||||
*
|
||||
* @dataProvider provideValuesForDceSecurityGenerator
|
||||
*/
|
||||
#[DataProvider('provideValuesForDceSecurityGenerator')]
|
||||
public function testGenerateBytesReplacesBytesWithDceValues(
|
||||
int | string $uid,
|
||||
int | string $gid,
|
||||
@@ -78,7 +78,7 @@ class DceSecurityGeneratorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uid: int|string, node: string, seconds: int, microseconds: int, providedDomain: int, providedId: IntegerObject|null, providedNode: null, expectedId: string, expectedDomain: string, expectedNode: string, expectedTimeMidHi: string}>
|
||||
*/
|
||||
public function provideValuesForDceSecurityGenerator(): array
|
||||
public static function provideValuesForDceSecurityGenerator(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\NameException;
|
||||
use Ramsey\Uuid\Generator\DefaultNameGenerator;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -17,9 +18,8 @@ class DefaultNameGeneratorTest extends TestCase
|
||||
* @param non-empty-string $ns
|
||||
* @param non-empty-string $name
|
||||
* @param non-empty-string $algorithm
|
||||
*
|
||||
* @dataProvider provideNamesForHashingTest
|
||||
*/
|
||||
#[DataProvider('provideNamesForHashingTest')]
|
||||
public function testDefaultNameGeneratorHashesName(string $ns, string $name, string $algorithm): void
|
||||
{
|
||||
$namespace = Uuid::fromString($ns);
|
||||
@@ -33,7 +33,7 @@ class DefaultNameGeneratorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{ns: non-empty-string, name: non-empty-string, algorithm: non-empty-string}>
|
||||
*/
|
||||
public function provideNamesForHashingTest(): array
|
||||
public static function provideNamesForHashingTest(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Ramsey\Uuid\Test\Generator;
|
||||
use Exception;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Ramsey\Uuid\BinaryUtils;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -113,10 +115,8 @@ class DefaultTimeGeneratorTest extends TestCase
|
||||
$defaultTimeGenerator->generate($this->nodeId, $this->clockSeq);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateDoesNotApplyVersionAndVariant(): void
|
||||
{
|
||||
$expectedBytes = hex2bin('83cb98e098e003cb0fe2122f80ca9e06');
|
||||
@@ -138,10 +138,8 @@ class DefaultTimeGeneratorTest extends TestCase
|
||||
$this->assertSame($expectedBytes, $defaultTimeGenerator->generate($this->nodeId, $this->clockSeq));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateUsesRandomSequenceWhenClockSeqNull(): void
|
||||
{
|
||||
PHPMockery::mock('Ramsey\Uuid\Generator', 'random_int')
|
||||
@@ -160,10 +158,8 @@ class DefaultTimeGeneratorTest extends TestCase
|
||||
$defaultTimeGenerator->generate($this->nodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateThrowsExceptionWhenExceptionThrownByRandomint(): void
|
||||
{
|
||||
PHPMockery::mock('Ramsey\Uuid\Generator', 'random_int')
|
||||
|
||||
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use Ramsey\Uuid\BinaryUtils;
|
||||
use Ramsey\Uuid\Exception\NameException;
|
||||
use Ramsey\Uuid\Generator\PeclUuidNameGenerator;
|
||||
@@ -22,10 +24,9 @@ class PeclUuidNameGeneratorTest extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $ns
|
||||
* @param non-empty-string $algorithm
|
||||
*
|
||||
* @dataProvider provideNamesForHashingTest
|
||||
* @requires extension uuid
|
||||
*/
|
||||
#[DataProvider('provideNamesForHashingTest')]
|
||||
#[RequiresPhpExtension('uuid')]
|
||||
public function testPeclUuidNameGeneratorHashesName(string $ns, string $name, string $algorithm): void
|
||||
{
|
||||
$namespace = Uuid::fromString($ns);
|
||||
@@ -60,7 +61,7 @@ class PeclUuidNameGeneratorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{ns: string, name: string, algorithm: string}>
|
||||
*/
|
||||
public function provideNamesForHashingTest(): array
|
||||
public static function provideNamesForHashingTest(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use Ramsey\Uuid\Generator\PeclUuidRandomGenerator;
|
||||
use Ramsey\Uuid\Rfc4122\Fields;
|
||||
use Ramsey\Uuid\Rfc4122\Version;
|
||||
@@ -12,9 +13,7 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
class PeclUuidRandomGeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @requires extension uuid
|
||||
*/
|
||||
#[RequiresPhpExtension('uuid')]
|
||||
public function testGenerateCreatesUuidUsingPeclUuidMethods(): void
|
||||
{
|
||||
$generator = new PeclUuidRandomGenerator();
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
|
||||
use Ramsey\Uuid\Generator\PeclUuidTimeGenerator;
|
||||
use Ramsey\Uuid\Rfc4122\Fields;
|
||||
use Ramsey\Uuid\Rfc4122\Version;
|
||||
@@ -12,9 +13,7 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
class PeclUuidTimeGeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @requires extension uuid
|
||||
*/
|
||||
#[RequiresPhpExtension('uuid')]
|
||||
public function testGenerateCreatesUuidUsingPeclUuidMethods(): void
|
||||
{
|
||||
$generator = new PeclUuidTimeGenerator();
|
||||
|
||||
@@ -5,6 +5,9 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Generator;
|
||||
|
||||
use Exception;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use Ramsey\Uuid\Exception\RandomSourceException;
|
||||
use Ramsey\Uuid\Generator\RandomBytesGenerator;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -17,7 +20,7 @@ class RandomBytesGeneratorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: positive-int, 1: non-empty-string}>
|
||||
*/
|
||||
public function lengthAndHexDataProvider(): array
|
||||
public static function lengthAndHexDataProvider(): array
|
||||
{
|
||||
return [
|
||||
[6, '4f17dd046fb8'],
|
||||
@@ -31,11 +34,10 @@ class RandomBytesGeneratorTest extends TestCase
|
||||
* @param non-empty-string $hex
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @dataProvider lengthAndHexDataProvider
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('lengthAndHexDataProvider')]
|
||||
public function testGenerateReturnsRandomBytes(int $length, string $hex): void
|
||||
{
|
||||
$bytes = hex2bin($hex);
|
||||
@@ -50,10 +52,8 @@ class RandomBytesGeneratorTest extends TestCase
|
||||
$this->assertSame($bytes, $generator->generate($length));
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateThrowsExceptionWhenExceptionThrownByRandomBytes(): void
|
||||
{
|
||||
PHPMockery::mock('Ramsey\Uuid\Generator', 'random_bytes')
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace Ramsey\Uuid\Test\Generator;
|
||||
use DateTimeImmutable;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use Ramsey\Uuid\Generator\RandomBytesGenerator;
|
||||
use Ramsey\Uuid\Generator\RandomGeneratorInterface;
|
||||
use Ramsey\Uuid\Generator\UnixTimeGenerator;
|
||||
@@ -14,10 +16,8 @@ use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
class UnixTimeGeneratorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerate(): void
|
||||
{
|
||||
$dateTime = new DateTimeImmutable('@1578612359.521023');
|
||||
@@ -36,10 +36,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
$this->assertSame($expectedBytes, $bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResults(): void
|
||||
{
|
||||
$randomGenerator = new RandomBytesGenerator();
|
||||
@@ -52,10 +50,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsWithSameDate(): void
|
||||
{
|
||||
$dateTime = new DateTimeImmutable('now');
|
||||
@@ -69,10 +65,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsFor32BitPath(): void
|
||||
{
|
||||
$randomGenerator = new RandomBytesGenerator();
|
||||
@@ -85,10 +79,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsWithSameDateFor32BitPath(): void
|
||||
{
|
||||
$dateTime = new DateTimeImmutable('now');
|
||||
@@ -102,10 +94,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsStartingWithAllBitsSet(): void
|
||||
{
|
||||
/** @var RandomGeneratorInterface&MockInterface $randomGenerator */
|
||||
@@ -126,10 +116,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsStartingWithAllBitsSetWithSameDate(): void
|
||||
{
|
||||
$dateTime = new DateTimeImmutable('now');
|
||||
@@ -152,10 +140,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsStartingWithAllBitsSetFor32BitPath(): void
|
||||
{
|
||||
/** @var RandomGeneratorInterface&MockInterface $randomGenerator */
|
||||
@@ -176,10 +162,8 @@ class UnixTimeGeneratorTest extends TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess since values are stored statically on the class
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGenerateProducesMonotonicResultsStartingWithAllBitsSetWithSameDateFor32BitPath(): void
|
||||
{
|
||||
$dateTime = new DateTimeImmutable('now');
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Guid;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Guid\Fields;
|
||||
use Ramsey\Uuid\Rfc4122\Version;
|
||||
@@ -29,9 +30,8 @@ class FieldsTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $guid
|
||||
*
|
||||
* @dataProvider nonRfc4122GuidVariantProvider
|
||||
*/
|
||||
#[DataProvider('nonRfc4122GuidVariantProvider')]
|
||||
public function testConstructorThrowsExceptionIfNotRfc4122Variant(string $guid): void
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
@@ -51,7 +51,7 @@ class FieldsTest extends TestCase
|
||||
*
|
||||
* @return array<array{0: non-empty-string}>
|
||||
*/
|
||||
public function nonRfc4122GuidVariantProvider(): array
|
||||
public static function nonRfc4122GuidVariantProvider(): array
|
||||
{
|
||||
// In string representation, the following IDs would begin as:
|
||||
// ff6f8cb0-c57d-11e1-...
|
||||
@@ -71,9 +71,8 @@ class FieldsTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $guid
|
||||
*
|
||||
* @dataProvider invalidVersionProvider
|
||||
*/
|
||||
#[DataProvider('invalidVersionProvider')]
|
||||
public function testConstructorThrowsExceptionIfInvalidVersion(string $guid): void
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
@@ -90,7 +89,7 @@ class FieldsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string}>
|
||||
*/
|
||||
public function invalidVersionProvider(): array
|
||||
public static function invalidVersionProvider(): array
|
||||
{
|
||||
// The following UUIDs are in GUID byte order. Dashes have
|
||||
// been removed in the tests to distinguish these from string
|
||||
@@ -111,9 +110,8 @@ class FieldsTest extends TestCase
|
||||
* @param non-empty-string $bytes
|
||||
* @param non-empty-string $methodName
|
||||
* @param Variant | Version | bool | non-empty-string | null $expectedValue
|
||||
*
|
||||
* @dataProvider fieldGetterMethodProvider
|
||||
*/
|
||||
#[DataProvider('fieldGetterMethodProvider')]
|
||||
public function testFieldGetterMethods(
|
||||
string $bytes,
|
||||
string $methodName,
|
||||
@@ -139,7 +137,7 @@ class FieldsTest extends TestCase
|
||||
* 2: Variant | Version | bool | non-empty-string | null,
|
||||
* }>
|
||||
*/
|
||||
public function fieldGetterMethodProvider(): array
|
||||
public static function fieldGetterMethodProvider(): array
|
||||
{
|
||||
// The following UUIDs are in GUID byte order. Dashes have
|
||||
// been removed in the tests to distinguish these from string
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Nonstandard;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Nonstandard\Fields;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -31,9 +32,8 @@ class FieldsTest extends TestCase
|
||||
* @param non-empty-string $uuid
|
||||
* @param non-empty-string $methodName
|
||||
* @param Variant | bool | non-empty-string | null $expectedValue
|
||||
*
|
||||
* @dataProvider fieldGetterMethodProvider
|
||||
*/
|
||||
#[DataProvider('fieldGetterMethodProvider')]
|
||||
public function testFieldGetterMethods(
|
||||
string $uuid,
|
||||
string $methodName,
|
||||
@@ -55,7 +55,7 @@ class FieldsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string, 1: non-empty-string, 2: Variant | bool | non-empty-string | null}>
|
||||
*/
|
||||
public function fieldGetterMethodProvider(): array
|
||||
public static function fieldGetterMethodProvider(): array
|
||||
{
|
||||
return [
|
||||
['ff6f8cb0-c57d-91e1-0b21-0800200c9a66', 'getClockSeq', '0b21'],
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Nonstandard;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -22,9 +23,7 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UuidV6Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -47,7 +46,7 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
@@ -62,9 +61,8 @@ class UuidV6Test extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
*
|
||||
* @dataProvider provideUuidV6WithOddMicroseconds
|
||||
*/
|
||||
#[DataProvider('provideUuidV6WithOddMicroseconds')]
|
||||
public function testGetDateTimeProperlyHandlesLongMicroseconds(string $uuid, string $expected): void
|
||||
{
|
||||
/** @var UuidV6 $object */
|
||||
@@ -79,7 +77,7 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: non-empty-string, expected: non-empty-string}>
|
||||
*/
|
||||
public function provideUuidV6WithOddMicroseconds(): array
|
||||
public static function provideUuidV6WithOddMicroseconds(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -104,9 +102,8 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuidv6
|
||||
* @param non-empty-string $uuidv1
|
||||
*
|
||||
* @dataProvider provideUuidV1UuidV6Equivalents
|
||||
*/
|
||||
#[DataProvider('provideUuidV1UuidV6Equivalents')]
|
||||
public function testToUuidV1(string $uuidv6, string $uuidv1): void
|
||||
{
|
||||
/** @var UuidV6 $uuid6 */
|
||||
@@ -125,9 +122,8 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuidv6
|
||||
* @param non-empty-string $uuidv1
|
||||
*
|
||||
* @dataProvider provideUuidV1UuidV6Equivalents
|
||||
*/
|
||||
#[DataProvider('provideUuidV1UuidV6Equivalents')]
|
||||
public function testFromUuidV1(string $uuidv6, string $uuidv1): void
|
||||
{
|
||||
/** @var LazyUuidFromString $uuid */
|
||||
@@ -147,7 +143,7 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @return array<array{uuidv6: non-empty-string, uuidv1: non-empty-string}>
|
||||
*/
|
||||
public function provideUuidV1UuidV6Equivalents(): array
|
||||
public static function provideUuidV1UuidV6Equivalents(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -5,6 +5,9 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Provider\Dce;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use Ramsey\Uuid\Exception\DceSecurityException;
|
||||
use Ramsey\Uuid\Provider\Dce\SystemDceSecurityProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -14,10 +17,8 @@ use function array_merge;
|
||||
|
||||
class SystemDceSecurityProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetUidThrowsExceptionIfShellExecDisabled(): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -49,10 +50,8 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
$this->assertSame(5, $caughtException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetUidForPosixThrowsExceptionIfShellExecReturnsNull(): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -84,11 +83,10 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideWindowsBadValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideWindowsBadValues')]
|
||||
public function testGetUidForWindowsThrowsExceptionIfShellExecForWhoAmIReturnsBadValues($value): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -118,11 +116,9 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
$provider->getUid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideWindowsGoodWhoAmIValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideWindowsGoodWhoAmIValues')]
|
||||
public function testGetUidForWindowsWhenShellExecForWhoAmIReturnsGoodValues(
|
||||
string $value,
|
||||
string $expectedId
|
||||
@@ -153,7 +149,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: non-empty-string, expectedId: non-empty-string}>
|
||||
*/
|
||||
public function provideWindowsGoodWhoAmIValues(): array
|
||||
public static function provideWindowsGoodWhoAmIValues(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -171,11 +167,9 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider providePosixTestValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('providePosixTestValues')]
|
||||
public function testGetUidForPosixSystems(string $os, string $id): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -201,10 +195,8 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
$this->assertSame($uid, $provider->getUid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetGidThrowsExceptionIfShellExecDisabled(): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -236,10 +228,8 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
$this->assertSame(5, $caughtException);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetGidForPosixThrowsExceptionIfShellExecReturnsNull(): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -269,11 +259,9 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
$provider->getGid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider providePosixTestValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('providePosixTestValues')]
|
||||
public function testGetGidForPosixSystems(string $os, string $id): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -301,11 +289,10 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideWindowsBadValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideWindowsBadValues')]
|
||||
public function testGetGidForWindowsThrowsExceptionWhenShellExecForNetUserReturnsBadValues($value): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -337,11 +324,10 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param mixed $value
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideWindowsBadGroupValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideWindowsBadGroupValues')]
|
||||
public function testGetGidForWindowsThrowsExceptionWhenShellExecForWmicGroupGetReturnsBadValues($value): void
|
||||
{
|
||||
PHPMockery::mock(
|
||||
@@ -378,11 +364,9 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
$provider->getGid();
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideWindowsGoodNetUserAndWmicGroupValues
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideWindowsGoodNetUserAndWmicGroupValues')]
|
||||
public function testGetGidForWindowsSucceeds(
|
||||
string $netUserResponse,
|
||||
string $wmicGroupResponse,
|
||||
@@ -427,7 +411,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
* expectedId: non-empty-string,
|
||||
* }>
|
||||
*/
|
||||
public function provideWindowsGoodNetUserAndWmicGroupValues(): array
|
||||
public static function provideWindowsGoodNetUserAndWmicGroupValues(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -460,7 +444,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{os: non-empty-string, id: non-empty-string}>
|
||||
*/
|
||||
public function providePosixTestValues(): array
|
||||
public static function providePosixTestValues(): array
|
||||
{
|
||||
return [
|
||||
['os' => 'Darwin', 'id' => '1042'],
|
||||
@@ -476,7 +460,7 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: string | null}>
|
||||
*/
|
||||
public function provideWindowsBadValues(): array
|
||||
public static function provideWindowsBadValues(): array
|
||||
{
|
||||
return [
|
||||
['value' => null],
|
||||
@@ -492,10 +476,10 @@ class SystemDceSecurityProviderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: string | null}>
|
||||
*/
|
||||
public function provideWindowsBadGroupValues(): array
|
||||
public static function provideWindowsBadGroupValues(): array
|
||||
{
|
||||
return array_merge(
|
||||
$this->provideWindowsBadValues(),
|
||||
self::provideWindowsBadValues(),
|
||||
[
|
||||
['value' => 'Users Not a valid SID string'],
|
||||
['value' => 'Users 344aab9758bb0d018b93739e7893fb3a'],
|
||||
|
||||
@@ -5,6 +5,8 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Provider\Node;
|
||||
|
||||
use Exception;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use Ramsey\Uuid\Exception\RandomSourceException;
|
||||
use Ramsey\Uuid\Provider\Node\RandomNodeProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -18,10 +20,8 @@ use function substr;
|
||||
|
||||
class RandomNodeProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeUsesRandomBytes(): void
|
||||
{
|
||||
$bytes = hex2bin('38a675685d50');
|
||||
@@ -38,10 +38,8 @@ class RandomNodeProviderTest extends TestCase
|
||||
$this->assertSame($expectedNode, $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeAlreadyHasMulticastBit(): void
|
||||
{
|
||||
$bytesHex = '4161a1ff5d50';
|
||||
@@ -60,10 +58,8 @@ class RandomNodeProviderTest extends TestCase
|
||||
$this->assertSame($expectedNode, $provider->getNode()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeSetsMulticastBitForLowNodeValue(): void
|
||||
{
|
||||
$bytes = hex2bin('100000000001');
|
||||
@@ -104,10 +100,8 @@ class RandomNodeProviderTest extends TestCase
|
||||
$this->assertSame('010000000000', $node);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeThrowsExceptionWhenExceptionThrownByRandombytes(): void
|
||||
{
|
||||
PHPMockery::mock('Ramsey\Uuid\Provider\Node', 'random_bytes')
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Provider\Node;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Provider\Node\StaticNodeProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
@@ -13,9 +14,8 @@ class StaticNodeProviderTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param non-empty-string $expectedNode
|
||||
*
|
||||
* @dataProvider provideNodeForTest
|
||||
*/
|
||||
#[DataProvider('provideNodeForTest')]
|
||||
public function testStaticNode(Hexadecimal $node, string $expectedNode): void
|
||||
{
|
||||
$staticNode = new StaticNodeProvider($node);
|
||||
@@ -26,7 +26,7 @@ class StaticNodeProviderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{node: Hexadecimal, expectedNode: non-empty-string}>
|
||||
*/
|
||||
public function provideNodeForTest(): array
|
||||
public static function provideNodeForTest(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -4,6 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Provider\Node;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\PreserveGlobalState;
|
||||
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Exception\NodeException;
|
||||
use Ramsey\Uuid\Provider\Node\SystemNodeProvider;
|
||||
@@ -58,13 +61,11 @@ class SystemNodeProviderTest extends TestCase
|
||||
/**
|
||||
* @var Spy[]
|
||||
*/
|
||||
private $functionProxies = [];
|
||||
private array $functionProxies = [];
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideValidNetStatOutput
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideValidNetStatOutput')]
|
||||
public function testGetNodeReturnsSystemNodeFromMacAddress(string $netstatOutput, string $expected): void
|
||||
{
|
||||
/* Arrange mocks for native functions */
|
||||
@@ -94,11 +95,9 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertMatchesRegularExpression('/^[A-Fa-f0-9]{12}$/', $node->toString(), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideInvalidNetStatOutput
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideInvalidNetStatOutput')]
|
||||
public function testGetNodeShouldNotReturnsSystemNodeForInvalidMacAddress(string $netstatOutput): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -127,11 +126,9 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertInstanceOf(NodeException::class, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideNotationalFormats
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideNotationalFormats')]
|
||||
public function testGetNodeReturnsNodeStrippedOfNotationalFormatting(string $formatted, string $expected): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -155,11 +152,9 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame($expected, $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideInvalidNotationalFormats
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideInvalidNotationalFormats')]
|
||||
public function testGetNodeDoesNotAcceptIncorrectNotationalFormatting(string $formatted): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -188,10 +183,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertInstanceOf(NodeException::class, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeReturnsFirstMacAddressFound(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -215,10 +208,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame('aabbccddeeff', $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeReturnsFalseWhenNodeIsNotFound(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -247,10 +238,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertInstanceOf(NodeException::class, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeWillNotExecuteSystemCallIfFailedFirstTime(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -287,11 +276,9 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertInstanceOf(NodeException::class, $exception2);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideCommandPerOs
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideCommandPerOs')]
|
||||
public function testGetNodeGetsNetworkInterfaceConfig(string $os, string $command): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -335,10 +322,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertInstanceOf(NodeException::class, $exception);
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeReturnsSameNodeUponSubsequentCalls(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -363,10 +348,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame($node->toString(), $node2->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testSubsequentCallsToGetNodeDoNotRecallIfconfig(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -391,11 +374,9 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame($node->toString(), $node2->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
* @dataProvider provideCommandPerOs
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
#[DataProvider('provideCommandPerOs')]
|
||||
public function testCallGetsysfsOnLinux(string $os, string $command): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -447,10 +428,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame('010203040506', $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testCallGetsysfsOnLinuxWhenGlobReturnsFalse(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -480,10 +459,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame('010203040506', $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testCallGetsysfsOnLinuxWhenGlobReturnsEmptyArray(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -513,10 +490,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame('010203040506', $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testCallGetsysfsOnLinuxWhenGlobFilesAreNotReadable(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -548,10 +523,8 @@ class SystemNodeProviderTest extends TestCase
|
||||
$this->assertSame('010203040506', $node->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @runInSeparateProcess
|
||||
* @preserveGlobalState disabled
|
||||
*/
|
||||
#[RunInSeparateProcess]
|
||||
#[PreserveGlobalState(false)]
|
||||
public function testGetNodeReturnsFalseWhenPassthruIsDisabled(): void
|
||||
{
|
||||
/* Arrange */
|
||||
@@ -587,21 +560,14 @@ class SystemNodeProviderTest extends TestCase
|
||||
|
||||
/**
|
||||
* Replaces the return value for functions with the given value or callback.
|
||||
*
|
||||
* @param callback|mixed|null $fileGetContentsBody
|
||||
* @param callback|mixed|null $globBody
|
||||
* @param callback|mixed|null $passthruBody
|
||||
* @param callback|mixed|null $constantBody
|
||||
* @param callback|mixed|null $iniGetDisableFunctionsBody
|
||||
* @param callback|mixed|null $isReadableBody
|
||||
*/
|
||||
private function arrangeMockFunctions(
|
||||
$fileGetContentsBody,
|
||||
$globBody,
|
||||
$passthruBody,
|
||||
$constantBody,
|
||||
$iniGetDisableFunctionsBody,
|
||||
$isReadableBody = true
|
||||
mixed $fileGetContentsBody,
|
||||
mixed $globBody,
|
||||
mixed $passthruBody,
|
||||
mixed $constantBody,
|
||||
mixed $iniGetDisableFunctionsBody,
|
||||
mixed $isReadableBody = true
|
||||
): void {
|
||||
$mockFunction = [
|
||||
self::MOCK_FILE_GET_CONTENTS => $fileGetContentsBody,
|
||||
@@ -689,7 +655,7 @@ class SystemNodeProviderTest extends TestCase
|
||||
*
|
||||
* @return array<string, array{0: non-empty-string, 1: non-empty-string}>
|
||||
*/
|
||||
public function provideCommandPerOs(): array
|
||||
public static function provideCommandPerOs(): array
|
||||
{
|
||||
return [
|
||||
'windows' => ['Windows', 'ipconfig /all 2>&1'],
|
||||
@@ -706,7 +672,7 @@ class SystemNodeProviderTest extends TestCase
|
||||
*
|
||||
* @return array<string, array{0: non-empty-string}>
|
||||
*/
|
||||
public function provideInvalidNetStatOutput(): array
|
||||
public static function provideInvalidNetStatOutput(): array
|
||||
{
|
||||
return [
|
||||
'Not an octal value' => [
|
||||
@@ -732,7 +698,7 @@ class SystemNodeProviderTest extends TestCase
|
||||
*
|
||||
* @return array<array{0: non-empty-string}>
|
||||
*/
|
||||
public function provideInvalidNotationalFormats(): array
|
||||
public static function provideInvalidNotationalFormats(): array
|
||||
{
|
||||
return [
|
||||
['01:23-45-67-89-ab'],
|
||||
@@ -752,7 +718,7 @@ class SystemNodeProviderTest extends TestCase
|
||||
*
|
||||
* @return array<array{0: non-empty-string, 1: non-empty-string}>
|
||||
*/
|
||||
public function provideNotationalFormats(): array
|
||||
public static function provideNotationalFormats(): array
|
||||
{
|
||||
return [
|
||||
['01-23-45-67-89-ab', '0123456789ab'],
|
||||
@@ -765,7 +731,7 @@ class SystemNodeProviderTest extends TestCase
|
||||
*
|
||||
* @return array<string, array{0: non-empty-string, 1: non-empty-string}>
|
||||
*/
|
||||
public function provideValidNetStatOutput(): array
|
||||
public static function provideValidNetStatOutput(): array
|
||||
{
|
||||
return [
|
||||
/* Full output of related command */
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Rfc4122\Fields;
|
||||
use Ramsey\Uuid\Rfc4122\Version;
|
||||
@@ -30,9 +31,8 @@ class FieldsTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
*
|
||||
* @dataProvider nonRfc4122VariantProvider
|
||||
*/
|
||||
#[DataProvider('nonRfc4122VariantProvider')]
|
||||
public function testConstructorThrowsExceptionIfNotRfc4122Variant(string $uuid): void
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
@@ -49,7 +49,7 @@ class FieldsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string}>
|
||||
*/
|
||||
public function nonRfc4122VariantProvider(): array
|
||||
public static function nonRfc4122VariantProvider(): array
|
||||
{
|
||||
return [
|
||||
['ff6f8cb0-c57d-11e1-0b21-0800200c9a66'],
|
||||
@@ -69,9 +69,8 @@ class FieldsTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
*
|
||||
* @dataProvider invalidVersionProvider
|
||||
*/
|
||||
#[DataProvider('invalidVersionProvider')]
|
||||
public function testConstructorThrowsExceptionIfInvalidVersion(string $uuid): void
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
@@ -88,7 +87,7 @@ class FieldsTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string}>
|
||||
*/
|
||||
public function invalidVersionProvider(): array
|
||||
public static function invalidVersionProvider(): array
|
||||
{
|
||||
return [
|
||||
['ff6f8cb0-c57d-01e1-8b21-0800200c9a66'],
|
||||
@@ -106,9 +105,8 @@ class FieldsTest extends TestCase
|
||||
* @param non-empty-string $uuid
|
||||
* @param non-empty-string $methodName
|
||||
* @param Variant | Version | bool | non-empty-string | null $expectedValue
|
||||
*
|
||||
* @dataProvider fieldGetterMethodProvider
|
||||
*/
|
||||
#[DataProvider('fieldGetterMethodProvider')]
|
||||
public function testFieldGetterMethods(
|
||||
string $uuid,
|
||||
string $methodName,
|
||||
@@ -134,7 +132,7 @@ class FieldsTest extends TestCase
|
||||
* 2: Variant | Version | bool | non-empty-string | null,
|
||||
* }>
|
||||
*/
|
||||
public function fieldGetterMethodProvider(): array
|
||||
public static function fieldGetterMethodProvider(): array
|
||||
{
|
||||
return [
|
||||
['ff6f8cb0-c57d-11e1-9b21-0800200c9a66', 'getClockSeq', '1b21'],
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\StringCodec;
|
||||
use Ramsey\Uuid\Converter\Number\GenericNumberConverter;
|
||||
use Ramsey\Uuid\Converter\Time\GenericTimeConverter;
|
||||
@@ -33,9 +34,8 @@ class UuidBuilderTest extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
* @param class-string $expectedClass
|
||||
*
|
||||
* @dataProvider provideBuildTestValues
|
||||
*/
|
||||
#[DataProvider('provideBuildTestValues')]
|
||||
public function testBuild(string $uuid, string $expectedClass, ?Version $expectedVersion): void
|
||||
{
|
||||
/** @var non-empty-string $bytes */
|
||||
@@ -59,7 +59,7 @@ class UuidBuilderTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: non-empty-string, expectedClass: class-string, expectedVersion: Version | null}>
|
||||
*/
|
||||
public function provideBuildTestValues(): array
|
||||
public static function provideBuildTestValues(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -21,9 +22,7 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UuidV1Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -46,7 +45,7 @@ class UuidV1Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::DceSecurity],
|
||||
@@ -62,9 +61,8 @@ class UuidV1Test extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
* @param numeric-string $expected
|
||||
*
|
||||
* @dataProvider provideUuidV1WithOddMicroseconds
|
||||
*/
|
||||
#[DataProvider('provideUuidV1WithOddMicroseconds')]
|
||||
public function testGetDateTimeProperlyHandlesLongMicroseconds(string $uuid, string $expected): void
|
||||
{
|
||||
/** @var UuidV1 $object */
|
||||
@@ -79,7 +77,7 @@ class UuidV1Test extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: non-empty-string, expected: numeric-string}>
|
||||
*/
|
||||
public function provideUuidV1WithOddMicroseconds(): array
|
||||
public static function provideUuidV1WithOddMicroseconds(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use DateTimeInterface;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\Number\GenericNumberConverter;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
@@ -30,9 +31,7 @@ use Ramsey\Uuid\UuidFactory;
|
||||
|
||||
class UuidV2Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -55,7 +54,7 @@ class UuidV2Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
@@ -70,9 +69,8 @@ class UuidV2Test extends TestCase
|
||||
|
||||
/**
|
||||
* @param positive-int $domain
|
||||
*
|
||||
* @dataProvider provideLocalDomainAndIdentifierForTests
|
||||
*/
|
||||
#[DataProvider('provideLocalDomainAndIdentifierForTests')]
|
||||
public function testGetLocalDomainAndIdentifier(
|
||||
int $domain,
|
||||
IntegerObject $identifier,
|
||||
@@ -124,7 +122,7 @@ class UuidV2Test extends TestCase
|
||||
* expectedTime: non-empty-string,
|
||||
* }>
|
||||
*/
|
||||
public function provideLocalDomainAndIdentifierForTests(): array
|
||||
public static function provideLocalDomainAndIdentifierForTests(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -16,9 +17,7 @@ use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
class UuidV3Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -41,7 +40,7 @@ class UuidV3Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -16,9 +17,7 @@ use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
class UuidV4Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -41,7 +40,7 @@ class UuidV4Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -16,9 +17,7 @@ use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
class UuidV5Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -41,7 +40,7 @@ class UuidV5Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -22,9 +23,7 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UuidV6Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -47,7 +46,7 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
@@ -63,9 +62,8 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
* @param non-empty-string $expected
|
||||
*
|
||||
* @dataProvider provideUuidV6WithOddMicroseconds
|
||||
*/
|
||||
#[DataProvider('provideUuidV6WithOddMicroseconds')]
|
||||
public function testGetDateTimeProperlyHandlesLongMicroseconds(string $uuid, string $expected): void
|
||||
{
|
||||
/** @var UuidV6 $object */
|
||||
@@ -80,7 +78,7 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: non-empty-string, expected: non-empty-string}>
|
||||
*/
|
||||
public function provideUuidV6WithOddMicroseconds(): array
|
||||
public static function provideUuidV6WithOddMicroseconds(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -105,9 +103,8 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuidv6
|
||||
* @param non-empty-string $uuidv1
|
||||
*
|
||||
* @dataProvider provideUuidV1UuidV6Equivalents
|
||||
*/
|
||||
#[DataProvider('provideUuidV1UuidV6Equivalents')]
|
||||
public function testToUuidV1(string $uuidv6, string $uuidv1): void
|
||||
{
|
||||
/** @var UuidV6 $uuid6 */
|
||||
@@ -126,9 +123,8 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @param non-empty-string $uuidv6
|
||||
* @param non-empty-string $uuidv1
|
||||
*
|
||||
* @dataProvider provideUuidV1UuidV6Equivalents
|
||||
*/
|
||||
#[DataProvider('provideUuidV1UuidV6Equivalents')]
|
||||
public function testFromUuidV1(string $uuidv6, string $uuidv1): void
|
||||
{
|
||||
/** @var LazyUuidFromString $uuid */
|
||||
@@ -148,7 +144,7 @@ class UuidV6Test extends TestCase
|
||||
/**
|
||||
* @return array<array{uuidv6: non-empty-string, uuidv1: non-empty-string}>
|
||||
*/
|
||||
public function provideUuidV1UuidV6Equivalents(): array
|
||||
public static function provideUuidV1UuidV6Equivalents(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -21,9 +22,7 @@ use Ramsey\Uuid\Uuid;
|
||||
|
||||
class UuidV7Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -46,7 +45,7 @@ class UuidV7Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
@@ -61,9 +60,8 @@ class UuidV7Test extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
*
|
||||
* @dataProvider provideUuidV7WithMicroseconds
|
||||
*/
|
||||
#[DataProvider('provideUuidV7WithMicroseconds')]
|
||||
public function testGetDateTimeProperlyHandlesMicroseconds(string $uuid, string $expected): void
|
||||
{
|
||||
/** @var UuidV7 $object */
|
||||
@@ -78,7 +76,7 @@ class UuidV7Test extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: string, expected: numeric-string}>
|
||||
*/
|
||||
public function provideUuidV7WithMicroseconds(): array
|
||||
public static function provideUuidV7WithMicroseconds(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
use Ramsey\Uuid\Converter\NumberConverterInterface;
|
||||
use Ramsey\Uuid\Converter\TimeConverterInterface;
|
||||
@@ -16,9 +17,7 @@ use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
class UuidV8Test extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTestVersions
|
||||
*/
|
||||
#[DataProvider('provideTestVersions')]
|
||||
public function testConstructorThrowsExceptionWhenFieldsAreNotValidForType(Version $version): void
|
||||
{
|
||||
$fields = Mockery::mock(FieldsInterface::class, [
|
||||
@@ -41,7 +40,7 @@ class UuidV8Test extends TestCase
|
||||
/**
|
||||
* @return array<array{version: Version}>
|
||||
*/
|
||||
public function provideTestVersions(): array
|
||||
public static function provideTestVersions(): array
|
||||
{
|
||||
return [
|
||||
['version' => Version::Time],
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Rfc4122\Validator;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
|
||||
@@ -13,9 +14,7 @@ use function strtoupper;
|
||||
|
||||
class ValidatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideValuesForValidation
|
||||
*/
|
||||
#[DataProvider('provideValuesForValidation')]
|
||||
public function testValidate(string $value, bool $expected): void
|
||||
{
|
||||
$variations = [];
|
||||
@@ -45,7 +44,7 @@ class ValidatorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: string, expected: bool}>
|
||||
*/
|
||||
public function provideValuesForValidation(): array
|
||||
public static function provideValuesForValidation(): array
|
||||
{
|
||||
$hexMutations = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'];
|
||||
$trueVersions = [1, 2, 3, 4, 5, 6, 7, 8];
|
||||
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Ramsey\Uuid\Test\Rfc4122;
|
||||
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidBytesException;
|
||||
use Ramsey\Uuid\Rfc4122\Fields;
|
||||
use Ramsey\Uuid\Rfc4122\VariantTrait;
|
||||
@@ -16,9 +17,7 @@ use function str_replace;
|
||||
|
||||
class VariantTraitTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider invalidBytesProvider
|
||||
*/
|
||||
#[DataProvider('invalidBytesProvider')]
|
||||
public function testGetVariantThrowsExceptionForWrongNumberOfBytes(string $bytes): void
|
||||
{
|
||||
/** @var Fields $trait */
|
||||
@@ -37,7 +36,7 @@ class VariantTraitTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string}>
|
||||
*/
|
||||
public function invalidBytesProvider(): array
|
||||
public static function invalidBytesProvider(): array
|
||||
{
|
||||
return [
|
||||
['not16Bytes_abcd'],
|
||||
@@ -45,9 +44,7 @@ class VariantTraitTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider uuidVariantProvider
|
||||
*/
|
||||
#[DataProvider('uuidVariantProvider')]
|
||||
public function testGetVariant(string $uuid, int $expectedVariant): void
|
||||
{
|
||||
$bytes = (string) hex2bin(str_replace('-', '', $uuid));
|
||||
@@ -65,7 +62,7 @@ class VariantTraitTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string, 1: int}>
|
||||
*/
|
||||
public function uuidVariantProvider(): array
|
||||
public static function uuidVariantProvider(): array
|
||||
{
|
||||
return [
|
||||
['ff6f8cb0-c57d-11e1-0b21-0800200c9a66', 0],
|
||||
|
||||
+17
-18
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Type;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Decimal;
|
||||
@@ -15,9 +16,7 @@ use function unserialize;
|
||||
|
||||
class DecimalTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideDecimal
|
||||
*/
|
||||
#[DataProvider('provideDecimal')]
|
||||
public function testDecimalValueType(
|
||||
float | int | Decimal | string $value,
|
||||
string $expected,
|
||||
@@ -33,7 +32,7 @@ class DecimalTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: float | int | Decimal | string, expected: string, expectedIsNegative: bool}>
|
||||
*/
|
||||
public function provideDecimal(): array
|
||||
public static function provideDecimal(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -249,9 +248,7 @@ class DecimalTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDecimalBadValues
|
||||
*/
|
||||
#[DataProvider('provideDecimalBadValues')]
|
||||
public function testDecimalTypeThrowsExceptionForBadValues(string $value): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
@@ -266,7 +263,7 @@ class DecimalTest extends TestCase
|
||||
/**
|
||||
* @return array<array{string}>
|
||||
*/
|
||||
public function provideDecimalBadValues(): array
|
||||
public static function provideDecimalBadValues(): array
|
||||
{
|
||||
return [
|
||||
['123abc'],
|
||||
@@ -278,11 +275,12 @@ class DecimalTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDecimal
|
||||
*/
|
||||
public function testSerializeUnserializeDecimal(float | int | Decimal | string $value, string $expected): void
|
||||
{
|
||||
#[DataProvider('provideDecimal')]
|
||||
public function testSerializeUnserializeDecimal(
|
||||
float | int | Decimal | string $value,
|
||||
string $expected,
|
||||
bool $expectedIsNegative,
|
||||
): void {
|
||||
$decimal = new Decimal($value);
|
||||
$serializedDecimal = serialize($decimal);
|
||||
|
||||
@@ -292,11 +290,12 @@ class DecimalTest extends TestCase
|
||||
$this->assertSame($expected, $unserializedDecimal->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideDecimal
|
||||
*/
|
||||
public function testJsonSerialize(float | int | Decimal | string $value, string $expected): void
|
||||
{
|
||||
#[DataProvider('provideDecimal')]
|
||||
public function testJsonSerialize(
|
||||
float | int | Decimal | string $value,
|
||||
string $expected,
|
||||
bool $expectedIsNegative,
|
||||
): void {
|
||||
$decimal = new Decimal($value);
|
||||
$expectedJson = sprintf('"%s"', $expected);
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Type;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Hexadecimal;
|
||||
@@ -17,9 +18,8 @@ class HexadecimalTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param Hexadecimal|non-empty-string $value
|
||||
*
|
||||
* @dataProvider provideHex
|
||||
*/
|
||||
#[DataProvider('provideHex')]
|
||||
public function testHexadecimalType(Hexadecimal | string $value, string $expected): void
|
||||
{
|
||||
$hexadecimal = new Hexadecimal($value);
|
||||
@@ -31,7 +31,7 @@ class HexadecimalTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: Hexadecimal | non-empty-string, expected: string}>
|
||||
*/
|
||||
public function provideHex(): array
|
||||
public static function provideHex(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -55,9 +55,8 @@ class HexadecimalTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $value
|
||||
*
|
||||
* @dataProvider provideHexBadValues
|
||||
*/
|
||||
#[DataProvider('provideHexBadValues')]
|
||||
public function testHexadecimalTypeThrowsExceptionForBadValues(string $value): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
@@ -71,7 +70,7 @@ class HexadecimalTest extends TestCase
|
||||
/**
|
||||
* @return array<array{string}>
|
||||
*/
|
||||
public function provideHexBadValues(): array
|
||||
public static function provideHexBadValues(): array
|
||||
{
|
||||
return [
|
||||
['-123456.789'],
|
||||
@@ -83,9 +82,8 @@ class HexadecimalTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param Hexadecimal|non-empty-string $value
|
||||
*
|
||||
* @dataProvider provideHex
|
||||
*/
|
||||
#[DataProvider('provideHex')]
|
||||
public function testSerializeUnserializeHexadecimal(Hexadecimal | string $value, string $expected): void
|
||||
{
|
||||
$hexadecimal = new Hexadecimal($value);
|
||||
@@ -99,9 +97,8 @@ class HexadecimalTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param Hexadecimal|non-empty-string $value
|
||||
*
|
||||
* @dataProvider provideHex
|
||||
*/
|
||||
#[DataProvider('provideHex')]
|
||||
public function testJsonSerialize(Hexadecimal | string $value, string $expected): void
|
||||
{
|
||||
$hexadecimal = new Hexadecimal($value);
|
||||
|
||||
+12
-14
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Type;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Exception\InvalidArgumentException;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
@@ -17,13 +18,12 @@ class IntegerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param numeric-string $expected
|
||||
*
|
||||
* @dataProvider provideInteger
|
||||
*/
|
||||
#[DataProvider('provideInteger')]
|
||||
public function testIntegerType(
|
||||
float | int | IntegerObject | string $value,
|
||||
string $expected,
|
||||
bool $expectedIsNegative
|
||||
bool $expectedIsNegative,
|
||||
): void {
|
||||
$integer = new IntegerObject($value);
|
||||
|
||||
@@ -35,7 +35,7 @@ class IntegerTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: float | int | IntegerObject | string, expected: numeric-string, expectedIsNegative: bool}>
|
||||
*/
|
||||
public function provideInteger(): array
|
||||
public static function provideInteger(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -166,9 +166,7 @@ class IntegerTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideIntegerBadValues
|
||||
*/
|
||||
#[DataProvider('provideIntegerBadValues')]
|
||||
public function testIntegerTypeThrowsExceptionForBadValues(float | int | string $value): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
@@ -183,7 +181,7 @@ class IntegerTest extends TestCase
|
||||
/**
|
||||
* @return array<array{float | int | string}>
|
||||
*/
|
||||
public function provideIntegerBadValues(): array
|
||||
public static function provideIntegerBadValues(): array
|
||||
{
|
||||
return [
|
||||
[-9223372036854775809], // String value is "-9.2233720368548E+18"
|
||||
@@ -202,12 +200,12 @@ class IntegerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param numeric-string $expected
|
||||
*
|
||||
* @dataProvider provideInteger
|
||||
*/
|
||||
#[DataProvider('provideInteger')]
|
||||
public function testSerializeUnserializeInteger(
|
||||
float | int | IntegerObject | string $value,
|
||||
string $expected
|
||||
string $expected,
|
||||
bool $expectedIsNegative,
|
||||
): void {
|
||||
$integer = new IntegerObject($value);
|
||||
$serializedInteger = serialize($integer);
|
||||
@@ -220,12 +218,12 @@ class IntegerTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param numeric-string $expected
|
||||
*
|
||||
* @dataProvider provideInteger
|
||||
*/
|
||||
#[DataProvider('provideInteger')]
|
||||
public function testJsonSerialize(
|
||||
float | int | IntegerObject | string $value,
|
||||
string $expected
|
||||
string $expected,
|
||||
bool $expectedIsNegative,
|
||||
): void {
|
||||
$integer = new IntegerObject($value);
|
||||
$expectedJson = sprintf('"%s"', $expected);
|
||||
|
||||
+5
-10
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Type;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Type\Integer as IntegerObject;
|
||||
use Ramsey\Uuid\Type\Time;
|
||||
@@ -14,9 +15,7 @@ use function unserialize;
|
||||
|
||||
class TimeTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideTimeValues
|
||||
*/
|
||||
#[DataProvider('provideTimeValues')]
|
||||
public function testTime(
|
||||
int | IntegerObject | string $seconds,
|
||||
int | IntegerObject | string | null $microseconds
|
||||
@@ -46,7 +45,7 @@ class TimeTest extends TestCase
|
||||
/**
|
||||
* @return array<array{seconds: int | IntegerObject | string, microseconds: int | IntegerObject | string | null}>
|
||||
*/
|
||||
public function provideTimeValues(): array
|
||||
public static function provideTimeValues(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -68,9 +67,7 @@ class TimeTest extends TestCase
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTimeValues
|
||||
*/
|
||||
#[DataProvider('provideTimeValues')]
|
||||
public function testSerializeUnserializeTime(
|
||||
int | IntegerObject | string $seconds,
|
||||
int | IntegerObject | string | null $microseconds
|
||||
@@ -94,9 +91,7 @@ class TimeTest extends TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider provideTimeValues
|
||||
*/
|
||||
#[DataProvider('provideTimeValues')]
|
||||
public function testJsonSerialize(
|
||||
int | IntegerObject | string $seconds,
|
||||
int | IntegerObject | string | null $microseconds
|
||||
|
||||
@@ -8,6 +8,7 @@ use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Mockery;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Ramsey\Uuid\Builder\UuidBuilderInterface;
|
||||
use Ramsey\Uuid\Codec\CodecInterface;
|
||||
@@ -142,9 +143,8 @@ class UuidFactoryTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param int<0, 16383>|null $clockSeq
|
||||
*
|
||||
* @dataProvider provideDateTime
|
||||
*/
|
||||
#[DataProvider('provideDateTime')]
|
||||
public function testFromDateTime(
|
||||
DateTimeInterface $dateTime,
|
||||
?Hexadecimal $node,
|
||||
@@ -164,7 +164,7 @@ class UuidFactoryTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: DateTimeInterface, 1: Hexadecimal | null, 2: int | null, 3: string, 4: string}>
|
||||
*/
|
||||
public function provideDateTime(): array
|
||||
public static function provideDateTime(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
|
||||
+28
-52
@@ -11,6 +11,7 @@ use DateTimeImmutable;
|
||||
use DateTimeInterface;
|
||||
use Mockery;
|
||||
use Mockery\MockInterface;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Ramsey\Uuid\Codec\StringCodec;
|
||||
use Ramsey\Uuid\Codec\TimestampFirstCombCodec;
|
||||
@@ -402,9 +403,8 @@ class UuidTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param non-empty-string $uuid
|
||||
*
|
||||
* @dataProvider provideVariousVariantUuids
|
||||
*/
|
||||
#[DataProvider('provideVariousVariantUuids')]
|
||||
public function testGetVariantForVariousVariantUuids(string $uuid, Variant $variant): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuidInstance */
|
||||
@@ -415,7 +415,7 @@ class UuidTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: non-empty-string, 1: Variant}>
|
||||
*/
|
||||
public function provideVariousVariantUuids(): array
|
||||
public static function provideVariousVariantUuids(): array
|
||||
{
|
||||
return [
|
||||
['ff6f8cb0-c57d-11e1-0b21-0800200c9a66', Variant::ReservedNcs],
|
||||
@@ -806,9 +806,8 @@ class UuidTest extends TestCase
|
||||
* @param non-empty-string $uuid
|
||||
* @param non-empty-string $ns
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @dataProvider provideUuid3WithKnownUuids
|
||||
*/
|
||||
#[DataProvider('provideUuid3WithKnownUuids')]
|
||||
public function testUuid3WithKnownUuids(string $uuid, string $ns, string $name): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uobj1 */
|
||||
@@ -826,7 +825,7 @@ class UuidTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: non-empty-string, ns: non-empty-string, name: non-empty-string}>
|
||||
*/
|
||||
public function provideUuid3WithKnownUuids(): array
|
||||
public static function provideUuid3WithKnownUuids(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -948,9 +947,8 @@ class UuidTest extends TestCase
|
||||
* @param non-empty-string $uuid
|
||||
* @param non-empty-string $ns
|
||||
* @param non-empty-string $name
|
||||
*
|
||||
* @dataProvider provideUuid5WithKnownUuids
|
||||
*/
|
||||
#[DataProvider('provideUuid5WithKnownUuids')]
|
||||
public function testUuid5WithKnownUuids(string $uuid, string $ns, string $name): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uobj1 */
|
||||
@@ -968,7 +966,7 @@ class UuidTest extends TestCase
|
||||
/**
|
||||
* @return array<array{uuid: non-empty-string, ns: non-empty-string, name: non-empty-string}>
|
||||
*/
|
||||
public function provideUuid5WithKnownUuids(): array
|
||||
public static function provideUuid5WithKnownUuids(): array
|
||||
{
|
||||
return [
|
||||
[
|
||||
@@ -1303,9 +1301,8 @@ class UuidTest extends TestCase
|
||||
* @param non-empty-string $urn
|
||||
* @param non-empty-string $time
|
||||
* @param non-empty-string $clockSeq
|
||||
*
|
||||
* @dataProvider providePythonTests
|
||||
*/
|
||||
#[DataProvider('providePythonTests')]
|
||||
public function testUuidPassesPythonTests(
|
||||
string $string,
|
||||
string $curly,
|
||||
@@ -1370,12 +1367,12 @@ class UuidTest extends TestCase
|
||||
* fields: array<string, string>,
|
||||
* urn: non-empty-string,
|
||||
* time: non-empty-string,
|
||||
* clock_seq: non-empty-string,
|
||||
* clockSeq: non-empty-string,
|
||||
* variant: Variant,
|
||||
* version: Version | null,
|
||||
* }>
|
||||
*/
|
||||
public function providePythonTests(): array
|
||||
public static function providePythonTests(): array
|
||||
{
|
||||
// This array is taken directly from the Python tests, more or less.
|
||||
return [
|
||||
@@ -1395,7 +1392,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:00000000-0000-0000-0000-000000000000',
|
||||
'time' => '000000000000000',
|
||||
'clock_seq' => '0000',
|
||||
'clockSeq' => '0000',
|
||||
// This is a departure from the Python tests. The Python tests
|
||||
// are technically "correct" because all bits are set to zero,
|
||||
// so it stands to reason that the variant is also zero, but
|
||||
@@ -1421,7 +1418,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:00010203-0405-0607-0809-0a0b0c0d0e0f',
|
||||
'time' => '607040500010203',
|
||||
'clock_seq' => '0809',
|
||||
'clockSeq' => '0809',
|
||||
'variant' => Variant::ReservedNcs,
|
||||
'version' => null,
|
||||
],
|
||||
@@ -1441,7 +1438,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:02d9e6d5-9467-382e-8f9b-9300a64ac3cd',
|
||||
'time' => '82e946702d9e6d5',
|
||||
'clock_seq' => '0f9b',
|
||||
'clockSeq' => '0f9b',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::HashMd5,
|
||||
],
|
||||
@@ -1461,7 +1458,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:12345678-1234-5678-1234-567812345678',
|
||||
'time' => '678123412345678',
|
||||
'clock_seq' => '1234',
|
||||
'clockSeq' => '1234',
|
||||
'variant' => Variant::ReservedNcs,
|
||||
'version' => null,
|
||||
],
|
||||
@@ -1481,7 +1478,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:6ba7b810-9dad-11d1-80b4-00c04fd430c8',
|
||||
'time' => '1d19dad6ba7b810',
|
||||
'clock_seq' => '00b4',
|
||||
'clockSeq' => '00b4',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Time,
|
||||
],
|
||||
@@ -1501,7 +1498,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:6ba7b811-9dad-11d1-80b4-00c04fd430c8',
|
||||
'time' => '1d19dad6ba7b811',
|
||||
'clock_seq' => '00b4',
|
||||
'clockSeq' => '00b4',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Time,
|
||||
],
|
||||
@@ -1521,7 +1518,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:6ba7b812-9dad-11d1-80b4-00c04fd430c8',
|
||||
'time' => '1d19dad6ba7b812',
|
||||
'clock_seq' => '00b4',
|
||||
'clockSeq' => '00b4',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Time,
|
||||
],
|
||||
@@ -1541,7 +1538,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:6ba7b814-9dad-11d1-80b4-00c04fd430c8',
|
||||
'time' => '1d19dad6ba7b814',
|
||||
'clock_seq' => '00b4',
|
||||
'clockSeq' => '00b4',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Time,
|
||||
],
|
||||
@@ -1561,7 +1558,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:7d444840-9dc0-11d1-b245-5ffdce74fad2',
|
||||
'time' => '1d19dc07d444840',
|
||||
'clock_seq' => '3245',
|
||||
'clockSeq' => '3245',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Time,
|
||||
],
|
||||
@@ -1581,7 +1578,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:e902893a-9d22-3c7e-a7b8-d6e313b71d9f',
|
||||
'time' => 'c7e9d22e902893a',
|
||||
'clock_seq' => '27b8',
|
||||
'clockSeq' => '27b8',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::HashMd5,
|
||||
],
|
||||
@@ -1601,7 +1598,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:eb424026-6f54-4ef8-a4d0-bb658a1fc6cf',
|
||||
'time' => 'ef86f54eb424026',
|
||||
'clock_seq' => '24d0',
|
||||
'clockSeq' => '24d0',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Random,
|
||||
],
|
||||
@@ -1621,7 +1618,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6',
|
||||
'time' => '1d07decf81d4fae',
|
||||
'clock_seq' => '2765',
|
||||
'clockSeq' => '2765',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => Version::Time,
|
||||
],
|
||||
@@ -1641,7 +1638,7 @@ class UuidTest extends TestCase
|
||||
],
|
||||
'urn' => 'urn:uuid:fffefdfc-fffe-fffe-fffe-fffefdfcfbfa',
|
||||
'time' => 'ffefffefffefdfc',
|
||||
'clock_seq' => '3ffe',
|
||||
'clockSeq' => '3ffe',
|
||||
'variant' => Variant::ReservedFuture,
|
||||
'version' => null,
|
||||
],
|
||||
@@ -1673,16 +1670,13 @@ class UuidTest extends TestCase
|
||||
// However, since all the bits in this UUID are defined as being
|
||||
// set to one, we will consider the clock sequence as 0xffff,
|
||||
// which all bits set to one.
|
||||
'clock_seq' => 'ffff',
|
||||
'clockSeq' => 'ffff',
|
||||
'variant' => Variant::Rfc4122,
|
||||
'version' => null,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Ramsey\Uuid\Uuid::jsonSerialize
|
||||
*/
|
||||
public function testJsonSerialize(): void
|
||||
{
|
||||
$uuid = Uuid::uuid1();
|
||||
@@ -1747,9 +1741,6 @@ class UuidTest extends TestCase
|
||||
$this->assertSame('b6c54489-38a0-5f50-a60a-fd8d76219cae', $uuid->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetVersionForVersion1
|
||||
*/
|
||||
public function testUuidVersionConstantForVersion1(): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
||||
@@ -1757,9 +1748,6 @@ class UuidTest extends TestCase
|
||||
$this->assertSame($uuid->getFields()->getVersion(), Version::Time);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetVersionForVersion2
|
||||
*/
|
||||
public function testUuidVersionConstantForVersion2(): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
||||
@@ -1767,9 +1755,6 @@ class UuidTest extends TestCase
|
||||
$this->assertSame($uuid->getFields()->getVersion(), Version::DceSecurity);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetVersionForVersion3
|
||||
*/
|
||||
public function testUuidVersionConstantForVersion3(): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
||||
@@ -1777,9 +1762,6 @@ class UuidTest extends TestCase
|
||||
$this->assertSame($uuid->getFields()->getVersion(), Version::HashMd5);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetVersionForVersion4
|
||||
*/
|
||||
public function testUuidVersionConstantForVersion4(): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
||||
@@ -1787,9 +1769,6 @@ class UuidTest extends TestCase
|
||||
$this->assertSame($uuid->getFields()->getVersion(), Version::Random);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetVersionForVersion5
|
||||
*/
|
||||
public function testUuidVersionConstantForVersion5(): void
|
||||
{
|
||||
/** @var \Ramsey\Uuid\Rfc4122\UuidInterface $uuid */
|
||||
@@ -1842,9 +1821,8 @@ class UuidTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param array<int | string> $args
|
||||
*
|
||||
* @dataProvider provideStaticMethods
|
||||
*/
|
||||
#[DataProvider('provideStaticMethods')]
|
||||
public function testStaticCreationMethodsReturnSpecificUuidInstances(
|
||||
string $staticMethod,
|
||||
array $args = []
|
||||
@@ -1854,9 +1832,8 @@ class UuidTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param array<int | string> $args
|
||||
*
|
||||
* @dataProvider provideStaticMethods
|
||||
*/
|
||||
#[DataProvider('provideStaticMethods')]
|
||||
public function testUuidInstancesBuiltFromStringAreEquivalentToTheirGeneratedCounterparts(
|
||||
string $staticMethod,
|
||||
array $args = []
|
||||
@@ -1872,9 +1849,8 @@ class UuidTest extends TestCase
|
||||
|
||||
/**
|
||||
* @param array<int | string> $args
|
||||
*
|
||||
* @dataProvider provideStaticMethods
|
||||
*/
|
||||
#[DataProvider('provideStaticMethods')]
|
||||
public function testUuidInstancesBuiltFromBytesAreEquivalentToTheirGeneratedCounterparts(
|
||||
string $staticMethod,
|
||||
array $args = []
|
||||
@@ -1891,7 +1867,7 @@ class UuidTest extends TestCase
|
||||
/**
|
||||
* @return array<array{0: string, 1?: array<int | string>}>
|
||||
*/
|
||||
public function provideStaticMethods(): array
|
||||
public static function provideStaticMethods(): array
|
||||
{
|
||||
return [
|
||||
['uuid1'],
|
||||
|
||||
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Ramsey\Uuid\Test\Validator;
|
||||
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use Ramsey\Uuid\Test\TestCase;
|
||||
use Ramsey\Uuid\Validator\GenericValidator;
|
||||
|
||||
@@ -12,9 +13,7 @@ use function strtoupper;
|
||||
|
||||
class GenericValidatorTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider provideValuesForValidation
|
||||
*/
|
||||
#[DataProvider('provideValuesForValidation')]
|
||||
public function testValidate(string $value, bool $expected): void
|
||||
{
|
||||
$variations = [];
|
||||
@@ -36,7 +35,7 @@ class GenericValidatorTest extends TestCase
|
||||
/**
|
||||
* @return array<array{value: string, expected: bool}>
|
||||
*/
|
||||
public function provideValuesForValidation(): array
|
||||
public static function provideValuesForValidation(): array
|
||||
{
|
||||
$hexMutations = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user