/** * Creates a new poll * * @param PollId $id * @param string $poll_title * @return Poll * @throws InvalidPollTitle */ public static function create(PollId $id, $poll_title) { $validator = new PollTitleValidator(); if (!$validator->isSatisfiedBy($poll_title)) { throw new InvalidPollTitle($poll_title); } $poll = new self(); $poll->apply(new PollCreatedEvent($id, $poll_title)); return $poll; }
/** * @test * @group unit */ public function non_empty_string_returns_true() { $validator = new PollTitleValidator(); $this->assertTrue($validator->isSatisfiedBy('Title')); }