generator = new MercureUpdatesGenerator([]); } /** * @test * @dataProvider provideMethod */ public function visitIsProperlySerializedIntoUpdate(string $method, string $expectedTopic): void { $shortUrl = new ShortUrl('', ShortUrlMeta::fromRawData(['customSlug' => 'foo'])); $visit = new Visit($shortUrl, Visitor::emptyInstance()); $update = $this->generator->{$method}($visit); self::assertEquals([$expectedTopic], $update->getTopics()); self::assertEquals([ 'shortUrl' => [ 'shortCode' => $shortUrl->getShortCode(), 'shortUrl' => 'http:/' . $shortUrl->getShortCode(), 'longUrl' => '', 'dateCreated' => $shortUrl->getDateCreated()->toAtomString(), 'visitsCount' => 0, 'tags' => [], 'meta' => [ 'validSince' => null, 'validUntil' => null, 'maxVisits' => null, ], 'domain' => null, ], 'visit' => [ 'referer' => '', 'userAgent' => '', 'visitLocation' => null, 'date' => $visit->getDate()->toAtomString(), ], ], json_decode($update->getData())); } public function provideMethod(): iterable { yield 'newVisitUpdate' => ['newVisitUpdate', 'https://shlink.io/new-visit']; yield 'newShortUrlVisitUpdate' => ['newShortUrlVisitUpdate', 'https://shlink.io/new-visit/foo']; } }