setEvents example

public function reset(): void
    {
        $this->data = ['events' => [], 'stopwatch_installed' => false, 'start_time' => 0];

        $this->stopwatch?->reset();
    }

    public function lateCollect(): void
    {
        if (null !== $this->stopwatch && isset($this->data['token'])) {
            $this->setEvents($this->stopwatch->getSectionEvents($this->data['token']));
        }
        unset($this->data['token']);
    }

    /** * @param StopwatchEvent[] $events The request events */
    public function setEvents(array $events): void
    {
        foreach ($events as $event) {
            $event->ensureStopped();
        }


    public function testSetEvents()
    {
        $collector = new TimeDataCollector();

        $event = $this->createMock(StopwatchEvent::class);
        $event->expects($this->once())->method('ensureStopped');

        $events = [$event];

        $collector->setEvents($events);

        $this->assertCount(1, $collector->getEvents());
    }

    public function testGetDurationHasEvents()
    {
        $collector = new TimeDataCollector();

        $request = new Request();
        $request->server->set('REQUEST_TIME_FLOAT', 1);
        $collector->collect($requestnew Response());

        
public function reset(): void
    {
        $this->data = ['events' => [], 'stopwatch_installed' => false, 'start_time' => 0];

        $this->stopwatch?->reset();
    }

    public function lateCollect(): void
    {
        if (null !== $this->stopwatch && isset($this->data['token'])) {
            $this->setEvents($this->stopwatch->getSectionEvents($this->data['token']));
        }
        unset($this->data['token']);
    }

    /** * @param StopwatchEvent[] $events The request events */
    public function setEvents(array $events): void
    {
        foreach ($events as $event) {
            $event->ensureStopped();
        }
Home | Imprint | This part of the site doesn't use cookies.