Exemplo n.º 1
0
 /**
  * @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;
 }
 public function testCreateMotion()
 {
     $motion = $this->getMotionMock();
     $this->repository->createMotion($motion);
     $this->assertEquals(2, $motion->getId());
 }