/** * Tests the update function in the TestCategoryController * @param void * @return void */ public function testUpdate() { // Update the TestCategory $this->withoutMiddleware(); $this->call('POST', '/testcategory', $this->testCategoryData); $testCategorystored = TestCategory::orderBy('id', 'desc')->first(); $this->withoutMiddleware(); $this->call('PUT', '/testcategory/' . $testCategorystored->id, $this->testCategoryUpdate); $testCategorySaved = TestCategory::find($testCategorystored->id); $this->assertEquals($testCategorySaved->name, $this->testCategoryUpdate['name']); $this->assertEquals($testCategorySaved->description, $this->testCategoryUpdate['description']); }
/** * turnaroundTime() function returns the turnaround time blade with necessary contents * * @return Response */ public function turnaroundTime() { $today = date('Y-m-d'); $from = Input::get('start'); $to = Input::get('end'); if (!$to) { $to = $today; } $testCategory = Input::get('section_id'); $testType = Input::get('test_type'); $labSections = ['' => trans('messages.select-lab-section')] + TestCategory::lists('name', 'id')->all(); $interval = Input::get('period'); $error = null; $accredited = array(); if (!$testType) { $error = trans('messages.select-test-type'); } if ($testCategory) { $testTypes = TestCategory::find($testCategory)->testTypes->lists('name', 'id'); } else { $testTypes = array("" => ""); } if ($from || $to) { if (strtotime($from) > strtotime($to) || strtotime($from) > strtotime($today) || strtotime($to) > strtotime($today)) { $error = trans('messages.check-date-range'); } else { $toPlusOne = date_add(new DateTime($to), date_interval_create_from_date_string('1 day')); Session::flash('fine', ''); } } $resultset = self::getTatStats($from, $to, $testCategory, $testType, $interval); return view('reports.tat.index')->with('labSections', $labSections)->with('testTypes', $testTypes)->with('resultset', $resultset)->with('testCategory', $testCategory)->with('testType', $testType)->with('interval', $interval)->with('error', $error)->with('accredited', $accredited)->withInput(Input::all()); }
/** * Remove the specified resource from storage (soft delete). * * @param int $id * @return Response */ public function delete($id) { //Soft delete the test category $testcategory = TestCategory::find($id); $testCategoryInUse = TestType::where('test_category_id', '=', $id)->first(); if (empty($testCategoryInUse)) { // The test category is not in use $testcategory->delete(); } else { // The test category is in use $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans('messages.failure-test-category-in-use')); } // redirect $url = session('SOURCE_URL'); return redirect()->to($url)->with('message', trans_choice('messages.record-successfully-deleted', 1)); }