newRepo(); $repo->save($this->makeDevice()); $found = $repo->findById('dev-1'); $this->assertSame('dev-1', $found->getId()); } public function testFindByIdThrowsWhenMissing(): void { $repo = $this->newRepo(); $this->expectException(DeviceNotFoundException::class); $repo->findById('nope'); } public function testSaveInsertsAndUpdates(): void { $repo = $this->newRepo(); $repo->save($this->makeDevice()); $updated = new Device( id: 'dev-1', sessionId: 'sess-updated', userAgent: 'Mozilla/5.0', ipAddress: '10.0.0.1', lastSeenAt: new DateTimeImmutable('2026-02-01T00:00:00Z'), ); $repo->save($updated); $this->assertSame('sess-updated', $repo->findById('dev-1')->getSessionId()); } public function testDeleteById(): void { $repo = $this->newRepo(); $repo->save($this->makeDevice()); $repo->deleteById('dev-1'); $this->expectException(DeviceNotFoundException::class); $repo->findById('dev-1'); } }