public function addMember(Request $req, MemberRepository $repo)
 {
     $id = MemberId::generate();
     $member = Member::instantiate($id, $req->input('first_name'), $req->input('last_name'));
     $repo->save($member);
     return redirect('/admin/member');
 }
 /** @test */
 public function a_sale_can_be_completed()
 {
     $bookId = BookId::generate();
     $sellersId = MemberId::generate();
     $buyersId = MemberId::generate();
     $this->scenario->given([new BookOffered($bookId, $sellersId, "0534408133", 1500), new BookSoldToMember($bookId, $buyersId)])->when(new BookSaleCompleted($bookId))->then([]);
 }
 public function buy(Request $req, BookRepository $repo, $id)
 {
     $book = $repo->load(new BookId($id));
     $book->sellToMember(MemberId::generate());
     ///@todo use session memberId
     $repo->save($book);
     return redirect('/study/books');
 }
 /** @test */
 function a_member_can_be_removed_from_a_committee()
 {
     $id = CommitteeId::generate();
     $committee = new CommitteesList($id, 'S[ck]rip(t|t?c)ie', 'Digital anarchy');
     $member = MemberId::generate();
     $committee = $committee->addMember($member, "Mark", "Redeman");
     $committee = $committee->removeMember($member);
     $this->assertEquals([], $committee->members());
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $repo = App::make(Books\BookRepository::class);
     $faker = App::make(Faker\Generator::class);
     foreach ($this->isbns as $isbn) {
         $sellersId = MemberId::generate();
         $bookId = Books\BookId::generate();
         $book = Books\Book::offer($bookId, $sellersId, $isbn, 1500);
         $repo->save($book);
     }
 }
 /**
  * @test
  */
 public function a_book_cannot_be_sold_twice()
 {
     $bookId = BookId::generate();
     $memberId = MemberId::generate();
     $buyersId1 = MemberId::generate();
     $buyersId2 = MemberId::generate();
     $book = Book::offer($bookId, $memberId, "0534408133", 1500);
     //15 euro
     $book->sellToMember($buyersId1);
     $this->expectException(\Exception::class);
     $this->expectExceptionMessage("A book cannot be sold twice");
     $book->sellToMember($buyersId2);
 }
 protected function createInstance()
 {
     return new PostList(PostId::generate(), MemberId::generate(), 'My Title', 'My Content', 'blog', new DateTimeImmutable('2016-09-02T10:14:05'));
 }
 protected function createInstance()
 {
     return new MemberLeftCommittee(committeeId::generate(), MemberId::generate());
 }
 /** @test */
 public function registering_a_member_is_idempotent()
 {
     $id = ActivityId::generate();
     $memberId = MemberId::generate();
     $this->scenario->withAggregateId($id)->given([$this->socialActivityWasPlanned($id), new ActivityPublished($id), new MemberRegisteredToParticipate($id, $memberId)])->when(function ($activity) use($memberId) {
         return $activity->registerParticipant($memberId);
     })->then([]);
 }
 /** @test */
 function it_stores_a_users_firstname_and_lastnaem()
 {
     $id = MemberId::generate();
     $this->scenario->when(new MemberJoinedFrancken($id, "Mark", "Redeman"))->then([new MemberList($id, "Mark", "Redeman")]);
 }
 protected function createInstance()
 {
     return new MemberList(MemberId::generate(), "Mark", "Redeman");
 }
 protected function createInstance()
 {
     $bookId = BookId::generate();
     $buyersId = MemberId::generate();
     return new BookSoldToMember($bookId, $buyersId);
 }
 protected function createInstance()
 {
     return new MemberRegisteredToParticipate(ActivityId::generate(), MemberId::generate());
 }
 /**
  * @test
  */
 public function a_committee_has_members()
 {
     $id = CommitteeId::generate();
     $memberId = MemberId::generate();
     $this->scenario->withAggregateId($id)->given([new CommitteeInstantiated($id, 'S[ck]rip(t|t?c)ie', 'Digital anarchy')])->when(function ($committee) use($memberId) {
         $committee->joinByMember($memberId);
     })->then([new MemberJoinedCommittee($id, $memberId)])->when(function ($committee) use($memberId) {
         $committee->joinByMember($memberId);
     })->then([]);
 }
 protected function createInstance()
 {
     $bookId = BookId::generate();
     $sellersId = MemberId::generate();
     return new BookOffered($bookId, $sellersId, "0534408133", 1500);
 }