Пример #1
0
 public function testIndex()
 {
     $Activity1 = new \App\activity();
     $Activity1->description = 'Test';
     $Activity1->date = '2015-10-05';
     $Activity1->time = '00:00:00';
     $Activity1->plant_id = \App\Plant::where("name", "=", "TestActivityPlant")->first()->id;
     $Activity1->weather = 'few cloud';
     $Activity2 = new \App\activity();
     $Activity2->description = 'Test2';
     $Activity2->date = '2015-10-05';
     $Activity2->time = '00:00:00';
     $Activity2->plant_id = \App\Plant::where("name", "=", "TestActivityPlant")->first()->id;
     $Activity2->weather = 'rain';
     if (Activity::where("plant_id", "=", \App\Plant::where("name", "=", "TestActivityPlant")->first()->id)->count() <= 2) {
         $Activity1->save();
         $Activity2->save();
     }
     $Activity1->toArray();
     $ActivityController = new \App\Http\Controllers\activityController();
     $farmID = array('farmID' => \App\Farm::where("name", "=", "TestActivityFarm")->first()->id);
     $request = new \Illuminate\Http\Request();
     $request->replace($farmID);
     $test = $ActivityController->index($request);
     print_r($test[0] == $Activity2);
     $this->assertEquals($test[0], $Activity2->toArray());
     $this->assertEquals($test[1], $Activity1->toArray());
     $request->replace(null);
     $test2 = $ActivityController->index($request);
     $this->assertEquals(null, $test2);
 }
Пример #2
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     //
     $activity = activity::find($id);
     $join = player_has_activity::where('player_id', Auth::user()->id)->where('activity_id', $id)->get()->count();
     return view('player.activity.activity_info', ['activity' => $activity, 'join' => $join]);
 }
Пример #3
0
 public function testDestroy()
 {
     $Activity3 = array("description" => "Test store activity updated", "date" => "2015-10-5", "time" => "23:00:00", "plant_id" => \App\Plant::where("name", "=", "TestActivityPlant")->first()->id, "weather" => "fews cloud");
     $ActivityController = new \App\Http\Controllers\activityController();
     $ActivityController->destroy(activity::where("description", "=", "Test store activity updated")->first()->id);
     $this->notSeeInDatabase("activity", $Activity3);
     $this->assertNull($ActivityController->destroy(null));
 }