コード例 #1
0
 /** @test */
 public function a_visitor_can_request_to_be_registered()
 {
     $id = RegistrationRequestId::generate();
     $this->scenario->when(function () use($id) {
         return RegistrationRequest::submit($id, new FullName('Mark', '', 'Redeman'), Gender::fromString('male'), new DateTimeImmutable('1993-04-26'), ContactInfo::describe(new Email('*****@*****.**'), new Address('Groningen', '9742GS', 'Plutolaan 11')), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356'), new PaymentInfo(true, true));
     })->then([new RegistrationRequestSubmitted($id, new FullName('Mark', '', 'Redeman'), Gender::fromString('male'), new DateTimeImmutable('1993-04-26'), ContactInfo::describe(new Email('*****@*****.**'), new Address('Groningen', '9742GS', 'Plutolaan 11')), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356')), new PaymentInfoProvided($id, new PaymentInfo(true, true))]);
 }
 public static function fromRequest(Request $request)
 {
     $name = new FullName($request->input('firstname'), $request->input('middlename'), $request->input('surname'));
     $birthdate = DateTimeImmutable::createFromFormat('Y-m-d', $request->input('birthdate'));
     $gender = Gender::fromString($request->input('gender'));
     $studyDetails = new StudyDetails($request->input('study'), DateTimeImmutable::createFromFormat('Y-m', $request->input('starting-date-study')), $request->input('student-number'));
     $contactOptions = [];
     return new SubmitRegistrationRequest(RegistrationRequestId::generate(), $name, $birthdate, $gender, $studyDetails, $contactOptions);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $repo = App::make(Repository::class);
     $faker = App::make(Faker\Generator::class);
     $genders = ['male', 'female'];
     for ($i = 0; $i < 10; $i++) {
         $id = RegistrationRequestId::generate();
         $gender = $faker->randomElement($genders);
         $request = RegistrationRequest::submit($id, new FullName($faker->firstName($gender), '', $faker->lastName), Gender::fromString($gender), DateTimeImmutable::createFromMutable($faker->dateTimeInInterval('- 30 years', '-16 years')), ContactInfo::describe(new Email($faker->safeEmail), new Address($faker->city, $faker->postCode, $faker->streetAddress)), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356'), new PaymentInfo(true, $faker->boolean));
         $repo->save($request);
     }
 }
コード例 #4
0
 private function genderFrom(Request $request) : Gender
 {
     return Gender::fromString($request->input('gender'));
 }
 private function registrationRequestSubmitted(RegistrationRequestId $id) : RegistrationRequestSubmitted
 {
     $fullName = new FullName('Mark', '', 'Redeman');
     return new RegistrationRequestSubmitted($id, $fullName, Gender::fromString('male'), new DateTimeImmutable('1993-04-26'), ContactInfo::describe(new Email('*****@*****.**'), new Address('Groningen', '9742GS', 'Plutolaan 11')), new StudyDetails('Msc Applied Mathematics', new DateTimeImmutable('2011-09-01'), 's2218356'));
 }
コード例 #6
0
 /** @test */
 public function it_is_serializable()
 {
     $gender = Gender::fromString('male');
     $this->assertEquals($gender, Gender::deserialize($gender->serialize()));
 }