/** * Fonction permettant de tester la * suppression d'un membre d'un projet * * @return void */ public function testMoveTask() { $tache = Tache::create(['description' => 'Ma tache', 'code' => "MoncodeTest", 'start_date' => '2015-11-15', 'end_date' => '2015-11-30', 'us_story_id' => '1']); $take = new TakeTacheController(); $take->edit($tache->id); $tacheUpdated = Tache::where("code", "MoncodeTest")->get()->first(); $this->assertEquals(1, $tacheUpdated->state); $tacheUpdated->delete(); }
/** * Add test. * * @return void */ public function testAdd() { $tache1 = Tache::create(['description' => 'yes you can !', 'code' => hash('ripemd160', 'Your task you can love it before you can do it !!'), 'start_date' => '2015-10-29', 'end_date' => '2015-10-30', 'us_story_id' => '1', 'predecessors' => '1 2 4']); $tache2 = Tache::create(['description' => 'yes you can !', 'code' => hash('ripemd160', 'Your task is good, do it for you before all !!'), 'start_date' => '2015-10-29', 'end_date' => '2015-10-30', 'us_story_id' => '1', 'predecessors' => '1 2 4']); $this->assertEquals(2, Tache::all()->count()); $tache2->update(['description' => 'yours is yours', 'code' => hash('ripemd160', 'Your task is good, do it !!'), 'start_date' => '2015-11-01', 'end_date' => '2015-11-06', 'us_story_id' => '1', 'predecessors' => '1 2 5']); $this->assertEquals('yours is yours', $tache2->description); $this->assertEquals('2015-11-01', $tache2->start_date); $this->assertEquals('2015-11-06', $tache2->end_date); $this->assertEquals(2, Tache::all()->count()); $tache2->delete(); Tache::destroy($tache2->id); $this->assertEquals(1, Tache::all()->count()); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $this->validate($request, ['code' => 'required', 'description' => 'required', 'start_date' => 'required|date', 'end_date' => 'required|date|after:start_date']); if (!empty($request->get('predecessors'))) { $preds = implode(",", $request->get('predecessors')); $request['predecessors'] = $preds; } $taches = Tache::all('code')->toArray(); $ttaches = array(); $i = 0; foreach ($taches as $tachee) { $ttaches[$i] = $tachee['code']; $i++; } if (in_array($request->get('code'), $ttaches)) { Session::flash('danger', "This code already exists !"); return redirect(route('taches.taches.create')); } if (in_array($request->get('code'), $ttaches) == false) { $tache = Tache::create($request->all()); Session::flash('success1', "You Task was added with success !"); return redirect(route('taches.taches.show', $tache->sprint_id)); } }