/**
  * @test
  */
 public function it_is_intantiated_with_a_name_and_a_goal()
 {
     $id = CommitteeId::generate();
     $this->scenario->when(function () use($id) {
         return Committee::instantiate($id, 'S[ck]rip(t|t?c)ie', 'Digital anarchy');
     })->then([new CommitteeInstantiated($id, 'S[ck]rip(t|t?c)ie', 'Digital anarchy')]);
 }
 /**
  * @test
  */
 public function a_list_of_all_new_committees_is_kept()
 {
     $id = new CommitteeId($this->generator->generate());
     $committee = Committee::instantiate($id, 'S[ck]rip(t|t?c)ie', 'Digital anarchy');
     $this->repo->save($committee);
     $this->seeInDatabase('committees_list', ['name' => 'S[ck]rip(t|t?c)ie', 'summary' => 'Digital anarchy']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $repo = App::make(Committees\CommitteeRepository::class);
     $faker = App::make(Faker\Generator::class);
     $faker->addProvider(new \DavidBadura\FakerMarkdownGenerator\FakerProvider($faker));
     for ($i = 0; $i < 10; $i++) {
         $id = Committees\CommitteeId::generate();
         $committee = Committees\Committee::instantiate($id, $faker->name, $faker->paragraph);
         $committee->setCommitteePage($faker->markdown);
         $committee->setEmail(new Email('*****@*****.**'));
         $repo->save($committee);
     }
 }
 public function store(Request $req, CommitteeRepository $repo)
 {
     $id = CommitteeId::generate();
     $committee = Committee::instantiate($id, $req->input('name'), $req->input('summary'));
     $committee->setCommitteePage($req->input('page'));
     $email = $req->input('email');
     if (!empty($email)) {
         $committee->setEmail(new Email($req->input('email')));
     } else {
         $committee->setEmail(null);
     }
     $repo->save($committee);
     return redirect('/admin/committee');
 }
 public static function instantiate(CommitteeId $id, string $name, string $summary) : Committee
 {
     $committee = new Committee();
     $committee->apply(new CommitteeInstantiated($id, $name, $summary));
     return $committee;
 }