container->get(PresentationCounter::class); assert($counter instanceof PresentationCounter); $events = [ $this->createEvent( eventDate: Date::fromString('yesterday'), eventName: $this->randomString(), ), ]; PresentationBuilder::create('') ->setEvents($events) ->build(); $this->assertGreaterThanOrEqual( actual: $counter->getPastCount(), expected: 1, ); } public function test_it_only_counts_published_events(): void { $counter = $this->container->get(PresentationCounter::class); assert($counter instanceof PresentationCounter); $count = $counter->getPastCount(); $events = [ $this->createEvent( eventDate: Date::fromString('yesterday'), eventName: $this->randomString(), ), ]; $presentation = PresentationBuilder::create('') ->setEvents($events) ->setPublished(FALSE) ->build(); $this->assertSame( actual: $counter->getPastCount(), expected: $count, ); } public function test_it_only_counts_past_events(): void { $counter = $this->container->get(PresentationCounter::class); assert($counter instanceof PresentationCounter); // Get the existing presentation count (including existing nodes). $originalCount = $counter->getPastCount(); $this->assertGreaterThanOrEqual( actual: $originalCount, expected: 0, ); $events = [ $this->createEvent( eventDate: Date::fromString('tomorrow'), eventName: $this->randomString(), ), $this->createEvent( eventDate: Date::fromString('yesterday'), eventName: $this->randomString(), ), ]; $presentation = PresentationBuilder::create($this->randomString()) ->setEvents($events) ->build(); $presentation->save(); $counter = $this->container->get(PresentationCounter::class); // Ensure the count has only increased by one, even though a future and past event were created. $this->assertSame( actual: $counter->getPastCount(), expected: $originalCount + 1, ); } }