public function testGetMotionTheme() { $motionTheme = $this->repository->getMotionTheme(2); $this->assertInstanceOf('Wonderland\\Application\\Model\\MotionTheme', $motionTheme); $this->assertEquals('2', $motionTheme->getId()); $this->assertEquals('motion_themes.action', $motionTheme->getLabel()); $this->assertEquals('3', $motionTheme->getDuration()); }
/** * @param string $title * @param string $description * @param int $themeId * @param \Wonderland\Application\Model\Member $author * @param string $means * * @return \Wonderland\Application\Model\Motion * * @throws \Wonderland\Library\Exception\NotFoundException */ public function createMotion($title, $description, $themeId, Member $author, $means) { if (($theme = $this->repository->getMotionTheme($themeId)) === null) { throw new NotFoundException('Motion Theme Not Found'); } $endedAt = new \DateTime(); $endedAt->add(new \DateInterval("P{$theme->getDuration()}D")); $motion = (new Motion())->setTitle($title)->setDescription($description)->setMeans($means)->setAuthor($author)->setTheme($theme)->setIsActive(1)->setIsApproved(0)->setCreatedAt(new \DateTime())->setEndedAt($endedAt); $this->repository->createMotion($motion); return $motion; }