assertSame('machine_id', $field->name); $this->assertSame(10, $field->bits); $this->assertSame(0, $field->value); } public function testMaxValueShouldBeCalculatedCorrectly(): void { $field = new Constant('machine_id', 10); $maxValue = (1 << 10) - 1; $this->assertSame($maxValue, $field->maxValue()); } public function testInitialValueCanBeSet(): void { $field = new Constant('machine_id', 10, 2); $this->assertSame(2, $field->value); } public function testInitialValueMustBePositive(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Field value must be non-negative.'); new Constant('machine_id', 10, -1); } public function testInitialValueMustNotExceedMaxValue(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Field value 1024 exceeds maximum 1023 for 10 bits.'); new Constant('machine_id', 10, 1024); } public function testConstantHasMakeFactoryMethod(): void { $field = Constant::make('machine_id', 10, 5); $this->assertSame('machine_id', $field->name); $this->assertSame(10, $field->bits); $this->assertSame(5, $field->value); } public function testBitsMustBeAtLeastOne(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Bits must be between 1 and 63.'); new Constant('machine_id', 0); } public function testBitsMustNotExceed63(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Bits must be between 1 and 63.'); new Constant('machine_id', 64); } }