/** * Поиск шагов в истории * * @param EntryInterface $entry * * @return array */ public function findHistorySteps(EntryInterface $entry) { $dql = "\n SELECT\n step\n FROM {$this->_entityName} step\n JOIN step.entry entry\n WHERE\n entry.id = :entryId\n AND\n step.type = :stepType\n ORDER BY step.finishDate ASC\n "; $query = $this->_em->createQuery($dql); $query->setParameter('entryId', $entry->getId()); $query->setParameter('stepType', StepInterface::HISTORY_STEP); /** @var StepInterface[] $steps */ return $query->getResult(); }
/** * Работа с шагами */ public function testStep() { /** @var Step $currentStep */ $currentStep = $this->getMock(Step::class); static::assertEquals($this->entry, $this->entry->addCurrentStep($currentStep)); static::assertEquals($this->entry, $this->entry->addCurrentStep($currentStep)); static::assertEquals($this->entry, $this->entry->addCurrentStep($currentStep)); static::assertEquals($currentStep, $this->entry->getSteps()->current()); static::assertCount(1, $this->entry->getSteps()); }
/** * @param EntryInterface $entry * * @return $this */ public function setEntry(EntryInterface $entry) { $this->entry = $entry; if (!$entry->getSteps()->contains($this)) { $entry->getSteps()->add($this); } return $this; }