/** * @covers ::execute * @covers ::getCurrent * @covers ::setTimeout * @covers ::setStep */ public function testExecuteTimeout() { $increment = 0; $callback = function (Attempt $attempt) use(&$increment) { $increment += 1; return false; }; $attempt = new Attempt($callback); $attempt->setTimeout(200); $attempt->setStep(80); $attempt->execute(); $this->assertEquals(3, $attempt->getCurrent()); $this->assertEquals(3, $increment, 'The function should be called the same amount of times as reported by getCurrent'); }
/** * @param Query\AbstractQuery $query * @param string $parentId * @return array */ public function queryIds(Query\AbstractQuery $query, $parentId = null) { $attempt = new Attempt(function () use($query, $parentId) { $ids = $parentId === null ? $this->getElementIds($query) : $this->getChildElementIds($query, $parentId); return $query->getFilters()->matchAll($this, (array) $ids); }); return $attempt->execute(); }