assertSame('timestamp', $field->name); $this->assertSame(41, $field->bits); } public function testTimestampHasDefaultParameterValues(): void { $field = new Timestamp; $this->assertSame('timestamp', $field->name); $this->assertSame(41, $field->bits); } public function testTimestampHasMakeFactoryMethod(): void { $field = Timestamp::make('timestamp', 41); $this->assertSame('timestamp', $field->name); $this->assertSame(41, $field->bits); } public function testTimestampHasDynamicValue(): void { $field = new Timestamp; $value1 = $field->value(); usleep(1000); // Sleep for 1 millisecond $value2 = $field->value(); $this->assertGreaterThan($value1, $value2); } public function testEpochCanBeCustomized(): void { $epoch = new \DateTime('2026-01-01 00:00:00'); $field = new Timestamp('timestamp', 41, $epoch); $now = (int) floor(microtime(as_float: true) * 1000); $this->assertSame($now - $epoch->getTimestamp() * 1000, $field->value()); } public function testEpochCanBeSetAsInteger(): void { $epoch = new \DateTime('2026-01-01 00:00:00'); $timestampInMillis = $epoch->getTimestamp() * 1000; $field = new Timestamp('timestamp', 41, $timestampInMillis); $now = (int) floor(microtime(as_float: true) * 1000); $this->assertSame($now - $timestampInMillis, $field->value()); } public function testEpochMustBeNonNegative(): void { $this->expectException(\InvalidArgumentException::class); $this->expectExceptionMessage('Epoch must be non-negative.'); new Timestamp('timestamp', 41, -1); } }