build($codec, $bytes); /** @var Fields $fields */ $fields = $result->getFields(); $this->assertInstanceOf($expectedClass, $result); $this->assertSame($expectedVersion, $fields->getVersion()); } /** * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification */ public function provideBuildTestValues(): array { return [ [ 'uuid' => 'ff6f8cb0-c57d-11e1-9b21-0800200c9a66', 'expectedClass' => UuidV1::class, 'expectedVersion' => 1, ], [ 'uuid' => 'ff6f8cb0-c57d-21e1-9b21-0800200c9a66', 'expectedClass' => UuidV2::class, 'expectedVersion' => 2, ], [ 'uuid' => 'ff6f8cb0-c57d-31e1-9b21-0800200c9a66', 'expectedClass' => UuidV3::class, 'expectedVersion' => 3, ], [ 'uuid' => 'ff6f8cb0-c57d-41e1-9b21-0800200c9a66', 'expectedClass' => UuidV4::class, 'expectedVersion' => 4, ], [ 'uuid' => 'ff6f8cb0-c57d-51e1-9b21-0800200c9a66', 'expectedClass' => UuidV5::class, 'expectedVersion' => 5, ], [ 'uuid' => 'ff6f8cb0-c57d-61e1-9b21-0800200c9a66', 'expectedClass' => UuidV6::class, 'expectedVersion' => 6, ], ]; } public function testBuildThrowsUnableToBuildException(): void { $bytes = (string) hex2bin(str_replace('-', '', 'ff6f8cb0-c57d-51e1-9b21-0800200c9a')); $calculator = new BrickMathCalculator(); $numberConverter = new GenericNumberConverter($calculator); $timeConverter = new GenericTimeConverter($calculator); $builder = new UuidBuilder($numberConverter, $timeConverter); $codec = new StringCodec($builder); $this->expectException(UnableToBuildUuidException::class); $this->expectExceptionMessage( 'The byte string must be 16 bytes long; received 15 bytes' ); $builder->build($codec, $bytes); } }