コード例 #1
0
 /**
  * @test
  */
 public function canRegisterAFamilyAsGuestWithFees()
 {
     $this->simulateTransaction();
     $shirtSize = 'XL';
     $tournament = Tournament::firstOrFail();
     $playerFirstName = 'Mark';
     $firstName = 'John';
     $lastName = 'Smith';
     $email = 'testuser' . time() . '@example.com';
     $street = '123 Test Street';
     $spouseFirstName = 'apples';
     $this->visit('/tournaments/' . $tournament->slug . '/registration/spectator')->type($firstName, 'first_name')->type($lastName, 'last_name')->type($email, 'email')->press('Continue')->see('The street address field is required')->see('The zip code field is required')->type($street, 'address_one')->type('12345', 'zip_code')->select($shirtSize, 'shirt_size')->type($spouseFirstName, 'spouse_first_name')->type($playerFirstName, 'minor[1][first_name]')->press('Continue')->seePageIs('/cart')->see('Family Tournament Registration')->press('Submit')->see('Your registration is complete');
     $spectator = Spectator::orderBy('id', 'desc')->first();
     $this->assertEquals($shirtSize, $spectator->shirt_size);
     // defaults to no group selected
     $this->assertNull($spectator->group_id);
     $this->assertEquals($firstName, $spectator->first_name);
     $this->assertEquals($lastName, $spectator->last_name);
     $this->assertEquals($email, $spectator->email);
     $this->assertEquals($spouseFirstName, $spectator->spouse_first_name);
     // we use the receipt_id to determine if payment has been made
     $this->assertGreaterThan(0, $spectator->receipt_id);
     // verify address is populated
     $this->assertEquals($street, $spectator->address->address_one);
     // assert minor is there
     $this->assertEquals($playerFirstName, $spectator->minors()->first()->name);
 }
コード例 #2
0
 public function update(Tournament $tournament, array $attributes, array $participantTypes)
 {
     DB::beginTransaction();
     $tournament->update($attributes);
     // update or add a new fee
     foreach ($participantTypes as $typeId => $registration) {
         $participantFee = $tournament->participantFees()->where('participant_type_id', $typeId)->first();
         if (is_object($participantFee) && $participantFee->exists) {
             $participantFee->update(['requires_registration' => isset($registration['requireRegistration']) ? (bool) $registration['requireRegistration'] : false, 'fee' => $registration['fee'], 'earlybird_fee' => $registration['earlybird_fee'], 'onsite_fee' => $registration['onsite_fee']]);
         } else {
             $tournament->participantFees()->create(['participant_type_id' => $typeId, 'requires_registration' => isset($registration['requireRegistration']) ? (bool) $registration['requireRegistration'] : false, 'fee' => is_numeric($registration['fee']) ? $registration['fee'] : null, 'earlybird_fee' => is_numeric($registration['earlybird_fee']) ? $registration['earlybird_fee'] : null, 'onsite_fee' => is_numeric($registration['onsite_fee']) ? $registration['onsite_fee'] : null]);
         }
     }
     DB::commit();
     return $tournament;
 }
コード例 #3
0
 /**
  * @test
  */
 public function cantRegisterAsGuest()
 {
     // assert there's a button on the page and we can't click it
     $this->expectException(LogicException::class);
     $this->expectExceptionMessage('The selected node does not have a form ancestor');
     $tournament = Tournament::firstOrFail();
     $this->visit('/tournaments/' . $tournament->slug)->press('Quizmaster');
     // asserts it's a button
 }
コード例 #4
0
 /**
  * Regular registrations are where the Head Coach registers on
  * behalf of the Adult/Family.
  */
 public function postRegistration(SpectatorRegistrationRequest $request, $slug, SpectatorRegistrar $spectatorRegistrar)
 {
     $tournament = Tournament::where('slug', $slug)->firstOrFail();
     $spectator = $spectatorRegistrar->register($tournament, $request->except('_token'), $request->get('registering_as_current_user') == 1 ? Auth::user() : null, Session::group());
     $registrationType = 'Adult';
     if ($spectator->isFamily()) {
         $registrationType = 'Family';
     }
     return redirect('/tournaments/' . $tournament->slug . '/group')->withFlashSuccess($registrationType . ' has been added');
 }
コード例 #5
0
ファイル: GroupController.php プロジェクト: BibleBowl/account
 public function setTeamSet($slug, TeamSet $teamSet)
 {
     $tournament = Tournament::where('slug', $slug)->firstOrFail();
     /** @var GroupRegistration $registration */
     $registration = Session::tournamentGroupRegistration();
     $registration->setTournament($tournament);
     $registration->setTeamSet($teamSet);
     Session::setTournamentGroupRegistration($registration);
     return redirect('tournaments/group/quizmasters');
 }
コード例 #6
0
 /**
  * @param User   $owner
  * @param Season $season
  * @param array  $attributes
  *
  * @return static
  */
 public function create(User $owner, Season $season, array $attributes, array $eventTypes, array $participantTypes)
 {
     $attributes['creator_id'] = $owner->id;
     $attributes['season_id'] = $season->id;
     // don't prefix with season if the name already contains the year (20xx)
     if (str_contains($attributes['name'], '20') == false) {
         $attributes['slug'] = $season->name . ' ' . $attributes['name'];
     } else {
         $attributes['slug'] = $attributes['name'];
     }
     DB::beginTransaction();
     $tournament = Tournament::create($attributes);
     // add fees
     foreach ($participantTypes as $typeId => $registration) {
         $tournament->participantFees()->create(['participant_type_id' => $typeId, 'requires_registration' => isset($registration['requireRegistration']) ? (bool) $registration['requireRegistration'] : false, 'fee' => is_numeric($registration['fee']) ? $registration['fee'] : null, 'earlybird_fee' => is_numeric($registration['earlybird_fee']) ? $registration['earlybird_fee'] : null, 'onsite_fee' => is_numeric($registration['onsite_fee']) ? $registration['onsite_fee'] : null]);
     }
     // add events
     foreach ($eventTypes as $eventTypeId) {
         $tournament->events()->create(['event_type_id' => $eventTypeId]);
     }
     DB::commit();
     return $tournament;
 }
コード例 #7
0
 public static function viewBindings()
 {
     \View::creator('dashboard.guardian-children', function (View $view) {
         $season = Session::season();
         $groupToRegisterWith = Session::getGroupToRegisterWith();
         $view->with('children', Auth::user()->players()->with(['seasons' => function ($q) use($season) {
             $q->where('seasons.id', $season->id);
         }, 'groups' => function ($q) use($season) {
             $q->wherePivot('season_id', $season->id);
         }])->get())->with('season', $season)->with('hasGroupToRegisterWith', $groupToRegisterWith != null)->with('groupToRegisterWith', $groupToRegisterWith);
     });
     \View::creator('dashboard.season-overview', function (View $view) {
         $season = Session::season();
         /** @var MetricsRepository $metrics */
         $metrics = app(MetricsRepository::class);
         $playerCount = $metrics->playerCount($season);
         $view->with(['groupCount' => $metrics->groupCount($season), 'playerCount' => $playerCount, 'averageGroupSize' => $metrics->averageGroupSize($playerCount)]);
     });
     \View::creator('dashboard.tournaments', function (View $view) {
         $season = Session::season();
         $view->with('tournaments', Tournament::visible(Session::group()->program_id, $season)->get());
     });
 }
コード例 #8
0
ファイル: DatabaseSeeder.php プロジェクト: BibleBowl/account
 private function seedTournament($director)
 {
     $tournamentName = 'My Test Tournament';
     $tournament = Tournament::create(['program_id' => Program::TEEN, 'slug' => $this->season->name . ' ' . $tournamentName, 'season_id' => $this->season->id, 'name' => $tournamentName, 'start' => Carbon::now()->addMonths(5)->format('m/d/Y'), 'end' => Carbon::now()->addMonths(7)->format('m/d/Y'), 'registration_start' => Carbon::now()->subMonths(3)->format('m/d/Y'), 'registration_end' => Carbon::now()->addDays(4)->format('m/d/Y'), 'creator_id' => $director->id, 'details' => '<h3>Nearby Hotels</h3><p>There are a few nearby:</p><ul><li>Option #1</li></ul>', 'max_teams' => 64, 'lock_teams' => Carbon::now()->addMonths(3)->addWeeks(2)->format('m/d/Y'), 'earlybird_ends' => Carbon::now()->addMonths(3)->format('m/d/Y')]);
     $tournament->events()->create(['event_type_id' => EventType::ROUND_ROBIN, 'price_per_participant' => '25.00']);
     $tournament->events()->create(['event_type_id' => EventType::DOUBLE_ELIMINATION, 'price_per_participant' => '35.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::PLAYER, 'requires_registration' => 1, 'fee' => '15.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::TEAM, 'requires_registration' => 1, 'earlybird_fee' => '50.00', 'fee' => '75.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::QUIZMASTER, 'requires_registration' => 1, 'fee' => '30.00', 'onsite_fee' => '40.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::ADULT, 'requires_registration' => 1, 'fee' => '30.00', 'onsite_fee' => '40.00']);
     $tournament->participantFees()->create(['participant_type_id' => ParticipantType::FAMILY, 'requires_registration' => 1, 'fee' => '60.00', 'onsite_fee' => '75.00']);
     $groupId = 2;
     $tournament->tournamentQuizmasters()->create(['group_id' => $groupId, 'first_name' => 'Keith', 'last_name' => 'Webb', 'email' => '*****@*****.**', 'gender' => 'M']);
     $user = User::where('email', self::QUIZMASTER_EMAIL)->first();
     $receipt = $this->seedReceipt($user);
     $tournament->tournamentQuizmasters()->create(['group_id' => $groupId, 'receipt_id' => $receipt->id, 'first_name' => 'Warner', 'last_name' => 'Jackson', 'email' => '*****@*****.**', 'gender' => 'F']);
     // guest spectators
     $director = User::where('email', self::DIRECTOR_EMAIL)->first();
     $tournament->spectators()->create(['group_id' => $groupId, 'receipt_id' => $receipt->id, 'first_name' => 'Sarah', 'last_name' => 'Jones', 'shirt_size' => 'L', 'email' => '*****@*****.**', 'gender' => 'F', 'address_id' => $director->primary_address_id]);
     $tournament->spectators()->create(['group_id' => $groupId, 'first_name' => 'Jonathan', 'last_name' => 'Wicker', 'shirt_size' => 'L', 'email' => '*****@*****.**', 'gender' => 'M', 'address_id' => $director->primary_address_id]);
     // family spectators
     $tournament->spectators()->create(['group_id' => $groupId, 'user_id' => $director->id, 'receipt_id' => $receipt->id, 'spouse_first_name' => 'Michelle', 'spouse_gender' => 'F', 'spouse_shirt_size' => 'M']);
     $spectator = $tournament->spectators()->create(['group_id' => $groupId, 'first_name' => 'Clark', 'last_name' => 'Larkson', 'shirt_size' => 'XL', 'email' => '*****@*****.**', 'gender' => 'M', 'spouse_first_name' => 'Lucy', 'spouse_gender' => 'F', 'spouse_shirt_size' => 'M']);
     $spectator->minors()->create(['name' => 'Jonathan', 'age' => '6', 'shirt_size' => 'YS', 'gender' => 'M']);
     $spectator->minors()->create(['name' => 'Christine', 'age' => '12', 'shirt_size' => 'YM', 'gender' => 'F']);
 }
コード例 #9
0
 public function show($slug)
 {
     return view('tournaments.show', ['tournament' => $tournament = Tournament::where('slug', $slug)->firstOrFail(), 'events' => $tournament->events()->with('type')->get()]);
 }
コード例 #10
0
ファイル: AuthTest.php プロジェクト: BibleBowl/account
 /**
  * @test
  */
 public function isRedirectedAfterLogin()
 {
     $tournament = Tournament::firstOrFail();
     $this->visit('/login?returnUrl=tournaments/' . $tournament->slug)->login(AcceptanceTestingSeeder::GUARDIAN_EMAIL, AcceptanceTestingSeeder::GUARDIAN_PASSWORD)->followRedirects()->seePageIs('/tournaments/' . $tournament->slug);
 }
コード例 #11
0
 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return Tournament::where('id', $this->route('tournament'))->where('creator_id', Auth::id())->exists();
 }
コード例 #12
0
 /**
  * @param TournamentCreatorOnlyRequest $request
  *
  * @return \Illuminate\View\View
  */
 public function edit(TournamentCreatorOnlyRequest $request, $tournamentId, $eventId)
 {
     return view('tournaments.admin.events.edit')->withTournament(Tournament::findOrFail($tournamentId))->withEvent(Event::findOrFail($eventId));
 }
コード例 #13
0
 /**
  * Regular registrations are where the Head Coach registers on
  * behalf of the Quizmaster.
  */
 public function postRegistration(QuizmasterRegistrationRequest $request, $slug, QuizmasterRegistrar $quizmasterRegistrar)
 {
     $tournament = Tournament::where('slug', $slug)->firstOrFail();
     $quizmasterRegistrar->register($tournament, $request->except('_token'), null, Session::group());
     return redirect('/tournaments/' . $tournament->slug . '/group')->withFlashSuccess('Quizmaster has been added');
 }
コード例 #14
0
ファイル: TournamentsTest.php プロジェクト: BibleBowl/account
 /**
  * @test
  */
 public function viewUser()
 {
     $tournament = Tournament::first();
     $this->visit('/admin/tournaments/' . $tournament->id)->see($tournament->name);
 }
コード例 #15
0
 /**
  * @test
  */
 public function suggestsOnsiteRegistration()
 {
     $tournament = Tournament::firstOrFail();
     $tournament->update(['registration_start' => Carbon::now()->subDays(10)->format('m/d/Y'), 'registration_end' => Carbon::now()->subDays(1)->format('m/d/Y')]);
     $this->visit('/tournaments/' . $tournament->slug)->see('Quizmaster, Adult and Family registrations will be accepted onsite.');
 }
コード例 #16
0
 /**
  * @test
  */
 public function cantAddSpectatorsWhenRegistrationClosed()
 {
     $tournament = Tournament::firstOrFail();
     $tournament->update(['registration_start' => Carbon::now()->subDays(10)->format('m/d/Y'), 'registration_end' => Carbon::now()->subDays(1)->format('m/d/Y')]);
     $this->visit('/tournaments/' . $tournament->slug . '/group')->dontSee('Add Adult/Family');
 }
コード例 #17
0
 /**
  * @param GroupEditRequest $request
  * @param                  $id
  *
  * @return mixed
  */
 public function update(TournamentEditRequest $request, $id, TournamentUpdater $tournamentUpdater)
 {
     $tournament = Tournament::findOrFail($id);
     $tournamentUpdater->update($tournament, $request->except('participantTypes'), $request->get('participantTypes'));
     return redirect('/admin/tournaments/' . $id)->withFlashSuccess('Your changes were saved');
 }
コード例 #18
0
 public function tournament() : Tournament
 {
     return Tournament::find($this->attributes['tournamentId']);
 }