Example #1
3
 public function setUp()
 {
     parent::setUp();
     $this->request = m::mock('\\Illuminate\\Http\\Request');
     $this->themes = new Themes();
     self::$files->shouldReceive('exists')->andReturn(false);
     $this->lastWeek = Carbon::today()->subWeek()->format('Y-m-d');
     $this->yesterday = Carbon::yesterday()->format('Y-m-d');
     $this->today = Carbon::today()->format('Y-m-d');
     $this->tomorrow = Carbon::tomorrow()->format('Y-m-d');
     $this->nextWeek = Carbon::today()->addWeek()->format('Y-m-d');
 }
Example #2
1
 /** @test */
 public function conferences_dont_accept_proposals_outside_of_the_call_for_papers()
 {
     $conference = Factory::create('conference', ['cfp_starts_at' => Carbon::tomorrow(), 'cfp_ends_at' => Carbon::tomorrow()->addDay()]);
     $this->assertFalse($conference->isCurrentlyAcceptingProposals());
     $conference = Factory::create('conference', ['cfp_starts_at' => Carbon::yesterday()->subDay(), 'cfp_ends_at' => Carbon::yesterday()]);
     $this->assertFalse($conference->isCurrentlyAcceptingProposals());
 }
Example #3
1
 /**
  * @return array
  */
 private function getDateRange()
 {
     if (is_array($this->dateRange)) {
         return $this->dateRange;
     }
     switch (strtolower($this->dateRange)) {
         case 'today':
             return [$this->carbon->today(), $this->carbon->tomorrow()];
         case 'yesterday':
             return [$this->carbon->yesterday(), $this->carbon->today()];
         case 'thisweek':
             return [$this->carbon->today()->dayOfWeek === 0 ? $this->carbon->today() : $this->carbon->today()->previous(0), $this->carbon->tomorrow()];
         case 'lastweek':
             return [$this->carbon->today()->dayOfWeek === 0 ? $this->carbon->today()->previous(0) : $this->carbon->today()->previous(0)->previous(), $this->carbon->today()->previous(6)->addDay()];
         case 'thismonth':
             return [$this->carbon->today()->startOfMonth(), $this->carbon->tomorrow()];
         case 'lastmonth':
             return [$this->carbon->today()->subMonth()->startOfMonth(), $this->carbon->today()->subMonth()->endOfMonth()];
     }
 }
 /**
  * Tests that getting a task from repo that does not exists by date returns null.
  */
 public function testRepoReturnsNullIfNotWorkingDayWithThatDayExists()
 {
     $this->repo->add($this->workingDayWithTask);
     $nullWorkingDay = $this->repo->getByDate(Carbon::tomorrow());
     $this->assertNull($nullWorkingDay);
     $this->repo->remove($this->workingDayWithTask);
 }
 /**
  * Show the application dashboard.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $today = Carbon::today();
     $tomorrow = Carbon::tomorrow();
     $tomorrowbookinguser = Booking::where('bookingdate', '=', $tomorrow)->get();
     $dt = Carbon::now();
     $year = $dt->year;
     $month = $dt->month;
     $currentmonthbreakfast = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('breakfast', '=', 'on')->count();
     $currentmonthlunch = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('lunch', '=', 'on')->count();
     $currentmonthdinner = Booking::where('user_id', Auth::user()->id)->whereMonth('bookingdate', '=', $month)->whereMonth('bookingdate', '=', $month)->whereYear('bookingdate', '=', $year)->where('dinner', '=', 'on')->count();
     $totalbooking = $currentmonthbreakfast + $currentmonthlunch + $currentmonthdinner;
     $price = Account::whereMonth('accountdate', '=', date('m'))->where('user_id', Auth::user()->id)->sum('amount');
     $todaydayshop = Shop::where('shopdate', $today)->get();
     $tomorrowshop = Shop::where('shopdate', $tomorrow)->get();
     $bookings = Booking::where('bookingdate', '=', $today)->get();
     $breakfast = Booking::where('bookingdate', '=', $today)->where('breakfast', '=', 'on')->count();
     $lunch = Booking::where('bookingdate', '=', $today)->where('lunch', '=', 'on')->count();
     $dinner = Booking::where('bookingdate', '=', $today)->where('dinner', '=', 'on')->count();
     $t_breakfast = Booking::where('bookingdate', '=', $tomorrow)->where('breakfast', '=', 'on')->count();
     $t_lunch = Booking::where('bookingdate', '=', $tomorrow)->where('lunch', '=', 'on')->count();
     $t_dinner = Booking::where('bookingdate', '=', $tomorrow)->where('dinner', '=', 'on')->count();
     $useraccounts = DB::table('useraccounts')->where('user_id', Auth::user()->id)->select('user_id', DB::raw("SUM(foodamount) AS t_foodamount"), DB::raw("SUM(houserent) AS t_houserent"), DB::raw("SUM(internetbill) AS t_internetbill"), DB::raw("SUM(utlitybill) AS t_utlitybill"), DB::raw("SUM(buabill) AS t_buabill"), DB::raw("SUM(pay) AS t_pay"))->get();
     foreach ($useraccounts as $account) {
         $amount = $account->t_foodamount + $account->t_houserent + $account->t_internetbill + $account->t_utlitybill + $account->t_buabill;
         $balance = $amount - $account->t_pay;
     }
     return view('home', ['bookings' => $bookings, 'breakfast' => $breakfast, 'lunch' => $lunch, 'dinner' => $dinner, 't_breakfast' => $t_breakfast, 't_lunch' => $t_lunch, 't_dinner' => $t_dinner, 'tomorrow' => $tomorrow, 'todaydayshop' => $todaydayshop, 'tomorrowshop' => $tomorrowshop, 'tomorrowbookinguser' => $tomorrowbookinguser, 'balance' => $balance, 'currentmonthbreakfast' => $currentmonthbreakfast, 'currentmonthlunch' => $currentmonthlunch, 'currentmonthdinner' => $currentmonthdinner, 'totalbooking' => $totalbooking, 'price' => $price]);
 }
 public function test_renderContent_returns_twig_parsed_content()
 {
     $campaign2 = Campaign::create(['name' => 'Test split2', 'file_name' => 'test-split2.htm', 'file_type' => 'partial', 'start_at' => Carbon::today(), 'end_at' => Carbon::tomorrow(), 'version_a_content' => 'Foo', 'version_b_content' => 'Bar']);
     $campaign1 = Campaign::create(['name' => 'Test split1', 'file_name' => 'test-split1.htm', 'file_type' => 'partial', 'start_at' => Carbon::today(), 'end_at' => Carbon::tomorrow(), 'version_a_content' => 'Hello {{ split(' . $campaign2->id . ') }}', 'version_b_content' => 'World {{ split(' . $campaign2->id . ') }}']);
     $content = CmsHelper::renderContent($campaign1->id);
     $this->assertTrue(in_array($content, ['Hello Foo', 'Hello Bar', 'World Foo', 'World Bar']));
 }
Example #7
0
 public function index()
 {
     //using function from the Trait currentDate.
     $targetDay = $this->getCurrentDate();
     //retrieving data for the next 3 days prior and after the currentDate
     $dateDayAfter = Carbon::tomorrow();
     $dateDayBefore = Carbon::yesterday();
     $dateDayAfter2 = Carbon::tomorrow()->addDay();
     $dateDayAfter3 = Carbon::tomorrow()->addDays(2);
     $weekBeforeObject = Carbon::yesterday()->subDays(6);
     $weekAfterObject = Carbon::tomorrow()->addDays(6);
     $dateDayBefore2 = Carbon::yesterday()->subDay();
     $dateDayBefore3 = Carbon::yesterday()->subDays(2);
     //putting the data in the array using the function inside the controller
     $dayAfter = $this->dateObjectToArray($dateDayAfter);
     $dayBefore = $this->dateObjectToArray($dateDayBefore);
     $dayAfter2 = $this->dateObjectToArray($dateDayAfter2);
     $dayAfter3 = $this->dateObjectToArray($dateDayAfter3);
     $dayBefore2 = $this->dateObjectToArray($dateDayBefore2);
     $dayBefore3 = $this->dateObjectToArray($dateDayBefore3);
     $weekBefore = $this->dateObjectToArray($weekBeforeObject);
     $weekAfter = $this->dateObjectToArray($weekAfterObject);
     $data = ['thisDay' => '', 'thisWeek' => "class = active ", 'thisMonth' => '', 'id' => 'thisWeek'];
     // $listdata = $this->listRepository->getLists();
     return view('main-tabs.thisWeek', $data)->with('targetDay', $targetDay)->with('dayBefore', $dayBefore)->with('dayAfter', $dayAfter)->with('dayAfter2', $dayAfter2)->with('dayAfter3', $dayAfter3)->with('dayBefore2', $dayBefore2)->with('dayBefore3', $dayBefore3)->with('weekYearBefore', $weekBefore['currentYear'])->with('weekYearAfter', $weekAfter['currentYear'])->with('weekMonthBefore', $weekBefore['currentMonth'])->with('weekMonthAfter', $weekAfter['currentMonth'])->with('weekDayBefore', $weekBefore['currentDay'])->with('weekDayAfter', $weekAfter['currentDay']);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request, Trip $trip)
 {
     $company = Auth::travel_company_staff()->get()->travel_company;
     $stations = $company->stations->lists('city')->toArray();
     $dps = $request->departure_station;
     $des = $request->destination_station;
     $this->validate($request, ['departure_station' => "required | different:destination_station", 'departure_date' => "required", 'departure_time' => 'required', 'destination_station' => "required", 'fare' => 'required', 'transport_model' => 'required', 'hour' => 'integer|required', 'minute' => 'integer|required', 'boarding_point' => 'required', 'number_of_seats' => 'required|integer']);
     if (!in_array($dps, $stations) or !in_array($des, $stations)) {
         return redirect()->back()->withInput()->withErrors('Invalid Station');
     }
     $departure_date = $this->carbonize($request->departure_date);
     if ($departure_date->lte(Carbon::tomorrow())) {
         return redirect()->back()->withInput()->withErrors('Invalid Departure Date');
     }
     $min = $request->minute;
     $hour = $request->hour;
     $duration = $this->durationize($hour, $min);
     $slug = str_slug($request->departure_station . ' to ' . $request->destination_station);
     $code = $trip->code();
     $input = array_add($request->except(['minute', 'hour']), 'code', $code);
     $input['departure_date'] = $departure_date;
     $input = array_add($input, 'travel_company_id', $company->id);
     $input = array_add($input, 'duration', $duration);
     $input = array_add($input, 'slug', $slug);
     Trip::create($input);
     return redirect()->route('company.trips.index');
 }
Example #9
0
 public function testWillExpire()
 {
     $job = new Job();
     $this->assertFalse($job->willExpire());
     $job->expires_at = Carbon::tomorrow();
     $this->assertTrue($job->willExpire());
 }
 /**
  * Tests that getting a task from repo that does not exists by date returns null.
  */
 public function testRepoReturnsNullIfNotWorkingDayWithThatDayExists()
 {
     $this->workingDayWithTask = $this->getWorkingDayWithTask();
     $this->inMemoryRepo->add($this->workingDayWithTask);
     $nullWorkingDayFromRepo = $this->inMemoryRepo->getByDate(Carbon::tomorrow());
     $this->assertNull($nullWorkingDayFromRepo);
 }
Example #11
0
 public function index()
 {
     //getting the date today, and finding the corresponding list to it.
     $dateToday = $this->getCurrentDate();
     $dateObjectYesterday = Carbon::yesterday();
     $dateObjectTomorrow = Carbon::tomorrow();
     $dateArrayYesterday = $this->dateObjectToArray($dateObjectYesterday);
     $dateArrayTomorrow = $this->dateObjectToArray($dateObjectTomorrow);
     $dayBefore = $dateArrayYesterday['currentDay'] . "/" . $dateArrayYesterday['currentMonth'] . "/" . $dateArrayYesterday['currentYear'];
     $dayAfter = $dateArrayTomorrow['currentDay'] . "/" . $dateArrayTomorrow['currentMonth'] . "/" . $dateArrayTomorrow['currentYear'];
     //checks if a lists exists for a corresponnding date. If there is no list, returns a null value.
     $currentList = $this->listRepository->getSpecificList($dateToday['currentDay'] . "/" . $dateToday['currentMonth'] . "/" . $dateToday['currentYear']);
     if (!empty($currentList)) {
         $currentListID = $currentList->id;
         $logsData = $this->logRepository->getSpecificLogsByList($currentListID);
         if ($logsData->isEmpty()) {
             $logsData = null;
         }
     } else {
         $logsData = null;
     }
     $data = ['thisDay' => "class = active ", 'thisWeek' => '', 'thisMonth' => '', 'id' => 'thisDay'];
     $dayName = $dateToday['currentDayName'];
     $monthName = $dateToday['currentMonthName'];
     $day = $dateToday['currentDay'];
     $year = $dateToday['currentYear'];
     return view('main-tabs.thisDay', $data)->with('logsData', $logsData)->with('dayBefore', $dayBefore)->with('dayAfter', $dayAfter)->with('dayName', $dayName)->with('monthName', $monthName)->with('day', $day)->with('year', $year);
 }
Example #12
0
 public function createformat()
 {
     $today = rtrim(Carbon::today()->formatLocalized('%A %e'), '.');
     $tomorrow = rtrim(Carbon::tomorrow()->formatLocalized('%A %e'), '.');
     $week = rtrim(Carbon::today()->formatLocalized('%e %b'), '.') . ' - ' . rtrim(Carbon::today()->addWeek()->formatLocalized('%e %b'), '.');
     $weekend = rtrim(Carbon::today()->parse('next saturday')->formatLocalized('%e %b'), '.') . ' - ' . rtrim(Carbon::today()->parse('next sunday')->formatLocalized('%e %b'), '.');
     $month = rtrim(Carbon::today()->formatLocalized('%e %b'), '.') . ' - ' . rtrim(Carbon::today()->addMonth()->formatLocalized('%e %b'), '.');
     return $dateformat = ['today' => $today, 'tomorrow' => $tomorrow, 'week' => $week, 'weekend' => $weekend, 'month' => $month];
 }
Example #13
0
 public function book()
 {
     $now = Carbon::now();
     $tomorrow = Carbon::tomorrow();
     $nowString = '';
     //$now->format('d/m/Y 10:00');
     $tomorrowString = '';
     //$tomorrow->format('d/m/Y 10:00');
     return view('home.book', compact('nowString', 'tomorrowString'));
 }
Example #14
0
 public function seedDiscounts()
 {
     $expired = Factory::create(new Discount(), ['start_at' => null, 'end_at' => Carbon::yesterday()]);
     $running = Factory::create(new Discount(), ['start_at' => Carbon::yesterday(), 'end_at' => Carbon::tomorrow()]);
     $running->products()->sync([1, 2, 3]);
     $running->save();
     $upcoming = Factory::create(new Discount(), ['start_at' => Carbon::tomorrow(), 'end_at' => null]);
     $upcoming->categories()->sync([5]);
     $upcoming->save();
 }
 /**
  * Tests if the service's add tournament
  * works as supposed.
  */
 public function testServiceAddTournamentRepoCalled()
 {
     $name = 'tournament name';
     $fakeAdmin = m::mock('App\\Models\\Administrator');
     $fakeTournament = m::mock('App\\Models\\Tournament');
     \Admin::shouldReceive('getLogged')->once()->andReturn($fakeAdmin);
     $this->fakeTournamentsRepo->shouldReceive('addTournament')->withArgs([m::type('App\\Models\\Administrator'), $name, m::type('\\Carbon\\Carbon'), m::type('\\Carbon\\Carbon'), false])->once()->andReturn($fakeTournament);
     $tournament = $this->service->addTournament($name, \Carbon\Carbon::now(), \Carbon\Carbon::tomorrow(), false);
     $this->assertEquals($tournament, $fakeTournament);
 }
Example #16
0
 public function testInstance()
 {
     $rule = new RedirectRule([1, Redirect::TYPE_EXACT, Redirect::TARGET_TYPE_PATH_URL, '/from/url', '/to/url', null, null, 301, null, Carbon::today(), Carbon::tomorrow()]);
     self::assertEquals(1, $rule->getId());
     self::assertEquals(Redirect::TYPE_EXACT, $rule->getMatchType());
     self::assertEquals(Redirect::TARGET_TYPE_PATH_URL, $rule->getTargetType());
     self::assertEquals('/from/url', $rule->getFromUrl());
     self::assertEquals('/to/url', $rule->getToUrl());
     self::assertEquals(301, $rule->getStatusCode());
     self::assertEquals(Carbon::today(), $rule->getFromDate());
     self::assertEquals(Carbon::tomorrow(), $rule->getToDate());
 }
 /**
  * Tests the update tournament method.
  */
 public function testUpdateTournamentUpdateSuccess()
 {
     $name = 'testing name update';
     $beginDate = \Carbon\Carbon::yesterday();
     $finishDate = \Carbon\Carbon::tomorrow();
     $has_ended = true;
     $tournament = Factory::create('App\\Models\\Tournament');
     $tournament = $this->repository->updateTournament(Administrator::find($tournament->created_by), $tournament->name, $beginDate, $finishDate, $has_ended);
     $this->assertEquals($tournament->begin, $beginDate);
     $this->assertEquals($tournament->finish, $finishDate);
     $this->assertEquals($tournament->has_ended, $has_ended);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     Model::reguard();
     $userTest = User::create(['name' => 'userTest', 'email' => '*****@*****.**', 'password' => bcrypt('userTest'), 'height_inches' => 70]);
     $workout1 = Workout::create(['user_id' => $userTest->id, 'title' => 'Push', 'note' => 'This is a note']);
     $workout2 = Workout::create(['user_id' => $userTest->id, 'title' => 'Pull', 'note' => 'This is a note']);
     $workout3 = Workout::create(['user_id' => $userTest->id, 'title' => 'Legs', 'note' => 'This is a note']);
     $exercise1 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Barbell Bench Press', 'max_one_rep_max' => 190, 'type' => 'Weighted', 'category' => 'Chest']);
     $exercise2 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Overhead Press', 'max_one_rep_max' => 100, 'type' => 'Weighted', 'category' => 'Shoulders']);
     $exercise3 = Exercise::create(['user_id' => $userTest->id, 'title' => 'One Arm Row', 'max_one_rep_max' => 75, 'type' => 'Weighted', 'category' => 'Back']);
     $exercise4 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Pulldown', 'max_one_rep_max' => 200, 'type' => 'Weighted', 'category' => 'Back']);
     $exercise5 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Squats', 'max_one_rep_max' => 225, 'type' => 'Weighted', 'category' => 'Legs']);
     $exercise6 = Exercise::create(['user_id' => $userTest->id, 'title' => 'Deadlifts', 'max_one_rep_max' => 200, 'type' => 'Weighted', 'category' => 'Legs']);
     $session1 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise1->id, 'session_date' => Carbon::now()]);
     $session2 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise2->id, 'session_date' => Carbon::now()]);
     $session3 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise3->id, 'session_date' => Carbon::now()]);
     $session4 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise4->id, 'session_date' => Carbon::now()]);
     $session5 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise5->id, 'session_date' => Carbon::now()]);
     $session6 = Session::create(['user_id' => $userTest->id, 'exercise_id' => $exercise6->id, 'session_date' => Carbon::now()]);
     $sessionSet1 = SessionSet::create(['session_id' => $session1->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet2 = SessionSet::create(['session_id' => $session1->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet3 = SessionSet::create(['session_id' => $session1->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet4 = SessionSet::create(['session_id' => $session2->id, 'number_of_reps' => 8, 'weight_lifted' => 95, 'one_rep_max' => 100, 'failed' => false]);
     $sessionSet5 = SessionSet::create(['session_id' => $session2->id, 'number_of_reps' => 8, 'weight_lifted' => 95, 'one_rep_max' => 100, 'failed' => false]);
     $sessionSet6 = SessionSet::create(['session_id' => $session2->id, 'number_of_reps' => 8, 'weight_lifted' => 95, 'one_rep_max' => 100, 'failed' => false]);
     $sessionSet7 = SessionSet::create(['session_id' => $session3->id, 'number_of_reps' => 8, 'weight_lifted' => 65, 'one_rep_max' => 80, 'failed' => false]);
     $sessionSet8 = SessionSet::create(['session_id' => $session3->id, 'number_of_reps' => 8, 'weight_lifted' => 65, 'one_rep_max' => 80, 'failed' => false]);
     $sessionSet9 = SessionSet::create(['session_id' => $session3->id, 'number_of_reps' => 8, 'weight_lifted' => 65, 'one_rep_max' => 80, 'failed' => false]);
     $sessionSet10 = SessionSet::create(['session_id' => $session4->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet11 = SessionSet::create(['session_id' => $session4->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet12 = SessionSet::create(['session_id' => $session4->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet13 = SessionSet::create(['session_id' => $session5->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet14 = SessionSet::create(['session_id' => $session5->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet15 = SessionSet::create(['session_id' => $session5->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet16 = SessionSet::create(['session_id' => $session6->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet17 = SessionSet::create(['session_id' => $session6->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $sessionSet18 = SessionSet::create(['session_id' => $session6->id, 'number_of_reps' => 8, 'weight_lifted' => 180, 'one_rep_max' => 190, 'failed' => false]);
     $plan1 = Plan::create(['user_id' => $userTest->id, 'title' => '5/3/1', 'start_date' => Carbon::now(), 'end_date' => Carbon::now()->addWeeks(4)]);
     $planWorkout1 = PlanWorkout::create(['plan_id' => $plan1->id, 'workout_id' => $workout1->id]);
     $planWorkout2 = PlanWorkout::create(['plan_id' => $plan1->id, 'workout_id' => $workout2->id]);
     $planWorkout3 = PlanWorkout::create(['plan_id' => $plan1->id, 'workout_id' => $workout3->id]);
     $planDate1 = PlanDate::create(['plan_workout_id' => $planWorkout1->id, 'planned_date' => Carbon::tomorrow()]);
     $planDate2 = PlanDate::create(['plan_workout_id' => $planWorkout1->id, 'planned_date' => Carbon::tomorrow()->addDays(5)]);
     $planDate3 = PlanDate::create(['plan_workout_id' => $planWorkout2->id, 'planned_date' => Carbon::tomorrow()->addDay()]);
     $planDate4 = PlanDate::create(['plan_workout_id' => $planWorkout2->id, 'planned_date' => Carbon::tomorrow()->addDays(6)]);
     $planExercise1 = PlanExercise::create(['plan_workout_id' => $planWorkout1->id, 'exercise_id' => $exercise1->id, 'weight_to_add_for_success' => 5, 'weight_to_sub_for_fail' => 5]);
     $planExercise2 = PlanExercise::create(['plan_workout_id' => $planWorkout1->id, 'exercise_id' => $exercise2->id, 'weight_to_add_for_success' => 5, 'weight_to_sub_for_fail' => 5]);
     $planSet1 = PlanSet::create(['plan_exercise_id' => $planExercise1->id, 'expected_reps' => 10, 'expected_weight' => 100]);
     $planSet2 = PlanSet::create(['plan_exercise_id' => $planExercise1->id, 'expected_reps' => 10, 'expected_weight' => 100]);
 }
Example #19
0
 /**
  * @test
  */
 public function it_has_the_correct_response_if_the_user_does_not_have_a_weight_entry_on_the_specified_date()
 {
     $this->logInUser();
     $date = Carbon::tomorrow()->format('Y-m-d');
     $response = $this->call('GET', '/api/weights/' . $date);
     $content = json_decode($response->getContent(), true);
     //        dd($content);
     $this->checkWeightKeysExist($content);
     $this->assertNull($content['weight']);
     $this->assertNull($content['id']);
     $this->assertNull($content['date']);
     $this->assertEquals(Response::HTTP_OK, $response->getStatusCode());
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('posts', function (Blueprint $table) {
         $table->increments('id');
         $table->timestamps();
         $table->softDeletes();
         $table->integer('user_id')->unsigned();
         $table->foreign('user_id')->references('id')->on('users');
         $table->string('title');
         $table->string('slug');
         $table->text('content');
         $table->timestamp('published_at')->default(\Carbon\Carbon::tomorrow());
     });
 }
Example #21
0
 /**
  * @return \Illuminate\View\View
  */
 public function welcome()
 {
     //		$collection = array();
     //		for($i = 1; $i < 10; $i++){
     //			$ukey = strtoupper(substr(sha1(microtime() . $i), rand(0, 5), 25));
     //			if(!in_array($ukey, $collection)){ // you can check this in database as well.
     //				$collection[] = implode("-", str_split($ukey, 5));
     //			}
     //		}
     //		dd($collection);
     $trips = Trip::where('departure_date', Carbon::tomorrow())->take(3)->get();
     //		dd($trips->isEmpty());
     return view('pages.welcome', ['trips_to_display' => $trips]);
 }
 /**
  * Registers a new match when a pairings
  * array is given.
  *
  * @param array $pairings
  * @param int $tournamentID
  * @param Carbon $begin
  * @param Carbon $finish
  *
  * @return array
  */
 private function registerMatches($pairings, $tournamentID, \Carbon\Carbon $begin = null, \Carbon\Carbon $finish = null)
 {
     if (!$begin) {
         $begin = \Carbon\Carbon::now();
     }
     if (!$finish) {
         $finish = \Carbon\Carbon::tomorrow();
     }
     $matches = [];
     foreach ($pairings as $pair) {
         $firstPlayerID = $pair[0]->id;
         $secondPlayerID = isset($pair[1]) ? $pair[1]->id : null;
         $currentMatch = $this->matchesService->addMatch($tournamentID, $firstPlayerID, $secondPlayerID, $begin, $finish);
         $matches[] = $currentMatch;
     }
     return $matches;
 }
 /**
  * Tests if the Add match works
  * with the right interactions.
  */
 public function testServiceAddMatchCorrectInteractions()
 {
     $tournamentID = 1;
     $firstUserID = 1;
     $secondUserID = 2;
     $firstFakePlayer = m::mock('App\\Models\\Player');
     $secondFakePlayer = m::mock('App\\Models\\Player');
     $fakeTournament = m::mock('App\\Models\\Tournament');
     $fakeAdmin = m::mock('App\\Models\\Administrator');
     $fakeMatch = m::mock('App\\Models\\Match');
     \Admin::shouldReceive('getLogged')->once()->andReturn($fakeAdmin);
     $this->fakeTournamentsRepo->shouldReceive('getTournament')->with($tournamentID)->once()->andReturn($fakeTournament);
     $this->fakePlayersRepo->shouldReceive(['getPlayer' => $firstFakePlayer, 'getPlayer' => $secondFakePlayer])->withArgs([m::type('App\\Models\\Tournament'), m::type('int')])->twice();
     $this->fakeMatchesRepo->shouldReceive('addMatch')->withArgs([m::type('App\\Models\\Administrator'), m::type('App\\Models\\Tournament'), m::type('App\\Models\\Player'), m::type('App\\Models\\Player'), m::type('\\Carbon\\Carbon'), m::type('\\Carbon\\Carbon')])->once()->andReturn($fakeMatch);
     $match = $this->service->addMatch($tournamentID, $firstUserID, $secondUserID, \Carbon\Carbon::now(), \Carbon\Carbon::tomorrow());
     $this->assertEquals($match, $fakeMatch);
 }
 public function classDateTime()
 {
     $datetimeStr = "";
     $date = Carbon::createFromTimestamp(strtotime($this->attributes['class_date']));
     if ($date->isToday()) {
         $datetimeStr = '今天';
     } else {
         if ($date->isTomorrow()) {
             $datetimeStr = '明天';
         } else {
             if ($date->toDateString() === Carbon::tomorrow()->addDay()->toDateString()) {
                 $datetimeStr = '后天';
             }
         }
     }
     $datetimeStr = $datetimeStr . $date->format('m月d日') . " " . $this->attributes['week'] . " " . $this->course->attributes['class_time_begin'];
     return $datetimeStr;
 }
 public function test_selecting_discount_statuses()
 {
     $expired1 = Factory::create(new Discount(), ['start_at' => null, 'end_at' => Carbon::yesterday()]);
     $expired2 = Factory::create(new Discount(), ['start_at' => Carbon::now()->subDays(5), 'end_at' => Carbon::yesterday()]);
     $running1 = Factory::create(new Discount(), ['start_at' => null, 'end_at' => null]);
     $running2 = Factory::create(new Discount(), ['start_at' => Carbon::yesterday(), 'end_at' => null]);
     $running3 = Factory::create(new Discount(), ['start_at' => null, 'end_at' => Carbon::tomorrow()]);
     $running4 = Factory::create(new Discount(), ['start_at' => Carbon::yesterday(), 'end_at' => Carbon::tomorrow()]);
     $upcoming1 = Factory::create(new Discount(), ['start_at' => Carbon::tomorrow(), 'end_at' => null]);
     $upcoming2 = Factory::create(new Discount(), ['start_at' => Carbon::tomorrow(), 'end_at' => Carbon::now()->addDays(5)]);
     $discounts = Discount::selectStatus()->get();
     $this->assertEquals(-1, $discounts->where('id', $expired1->id)->first()->status);
     $this->assertEquals(-1, $discounts->where('id', $expired2->id)->first()->status);
     $this->assertEquals(0, $discounts->where('id', $running1->id)->first()->status);
     $this->assertEquals(0, $discounts->where('id', $running2->id)->first()->status);
     $this->assertEquals(0, $discounts->where('id', $running3->id)->first()->status);
     $this->assertEquals(0, $discounts->where('id', $running4->id)->first()->status);
     $this->assertEquals(1, $discounts->where('id', $upcoming1->id)->first()->status);
     $this->assertEquals(1, $discounts->where('id', $upcoming2->id)->first()->status);
 }
Example #26
0
 /**
  * Display a listing of comments, be sure to hide the user_id or identifying features if this person is not logged in
  *
  * @return Response
  */
 public function index()
 {
     $input = Request::all();
     if (!isset($input['start_date'])) {
         $input['start_date'] = Carbon::today();
     }
     if (!isset($input['end_date'])) {
         $input['end_date'] = Carbon::tomorrow();
     }
     if (!isset($input['number'])) {
         $input['number'] = 1;
     }
     $validator = Validator::make($input, ['start_date' => 'date', 'end_date' => 'date', 'number' => 'integer']);
     if ($validator->fails()) {
         return $validator->errors();
     }
     $comments = Comment::with('commentvotes', 'vote')->betweenDates($input['start_date'], $input['end_date'])->get()->sortBy(function ($comment) {
         return $comment->commentvotes->count();
     });
     return $comments->sortBy('commentRank')->chunk($input['number'])->reverse();
 }
 public function getCoursesByStoreId(Request $request, $id)
 {
     $dates = array();
     $courseSchedules = array();
     $today = Carbon::today();
     $tomorrow = Carbon::tomorrow();
     $day_after_tomorrow = Carbon::tomorrow()->addDay();
     $dates['today'] = '今天' . $today->format('m-d');
     $dates['tomorrow'] = '明天' . $tomorrow->format('m-d');
     $dates['day_after_tomorrow'] = '后天' . $day_after_tomorrow->format('m-d');
     $store = Store::find($id);
     $courseSchedules['today'] = CourseSchedule::whereHas('course', function ($query) use($store) {
         $query->where('store_id', $store->id);
     })->where('class_date', $today->format('Y-m-d'))->where('status', 'approved')->orderBy('created_at', 'desc')->get();
     $courseSchedules['tomorrow'] = CourseSchedule::whereHas('course', function ($query) use($store) {
         $query->where('store_id', $store->id);
     })->where('class_date', $tomorrow->format('Y-m-d'))->where('status', 'approved')->orderBy('created_at', 'desc')->get();
     $courseSchedules['day_after_tomorrow'] = CourseSchedule::whereHas('course', function ($query) use($store) {
         $query->where('store_id', $store->id);
     })->where('class_date', $day_after_tomorrow->format('Y-m-d'))->where('status', 'approved')->orderBy('created_at', 'desc')->get();
     return view('mobile.courses', compact('store', 'courseSchedules', 'dates'));
 }
 public function testThisWeek()
 {
     $period = CarbonPeriod::thisWeek();
     $start = Carbon::today();
     $end = Carbon::tomorrow();
     if ($start->dayOfWeek !== Carbon::MONDAY) {
         $start->modify('last monday');
     }
     $this->assertEquals($start, $period->start());
     $this->assertEquals($end, $period->end());
 }
Example #29
-1
 public function test_has_expiration_and_has_ended_methods()
 {
     $running1 = Factory::make(new Discount(), ['end_at' => null]);
     $running2 = Factory::make(new Discount(), ['end_at' => Carbon::tomorrow()]);
     $ended = Factory::make(new Discount(), ['end_at' => Carbon::yesterday()]);
     $this->assertFalse($running1->hasEnded());
     $this->assertFalse($running2->hasEnded());
     $this->assertTrue($ended->hasEnded());
     $this->assertFalse($running1->hasExpiration());
     $this->assertTrue($running2->hasExpiration());
 }
 /**
  * Tests if the update match on the repo
  * works correctly.
  */
 public function testUpdateMatchUpdateSuccess()
 {
     $match = Factory::create('App\\Models\\Match');
     $newPlayer = Factory::create('App\\Models\\Player');
     $newSecondPlayer = Factory::create('App\\Models\\Player');
     $winner = $newPlayer;
     $ended = true;
     $newBegin = \Carbon\Carbon::yesterday();
     $newFinish = \Carbon\Carbon::tomorrow();
     $match = $this->repository->updateMatch(Administrator::find($match->created_by), $match->id, $newPlayer, $newSecondPlayer, $winner, $newBegin, $newFinish, $ended);
     $this->assertEquals($match->firstPlayer->id, $newPlayer->id);
     $this->assertEquals($match->secondPlayer->id, $newSecondPlayer->id);
     $this->assertEquals($match->winner, $winner->id);
     $this->assertEquals($match->begin, $newBegin);
     $this->assertEquals($match->finish, $newFinish);
     $this->assertEquals($match->has_ended, $ended);
 }