public function testDestroy() { $server = array('HTTP_X-Requested-With' => 'XMLHttpRequest'); $params = ['_token' => \Session::token(), 'id' => 1]; $this->post('/user/destroy', $params, $server)->seeJsonEqualsExt(['status' => '200', 'message' => 'OK']); $this->seeInDatabaseExt('users', ['id' => 1], ['created_at' => false, 'updated_at' => true], true); }
/** * TodosControllerのテスト * * @return void */ public function testTodosRoutes() { // フィルタを有効にする Route::enableFilters(); // GET /todos $response = $this->call('GET', '/todos'); $this->assertEquals(200, $response->getStatusCode()); // POST /todos $input = ['_token' => Session::token()]; $response = $this->call('POST', '/todos', $input); $this->assertEquals(302, $response->getStatusCode()); $this->assertHasOldInput(); // POST /todos/1/update $input = ['_token' => Session::token()]; $response = $this->call('POST', '/todos/1/update', $input); $this->assertEquals(404, $response->getStatusCode()); // PUT /todos/1/title $input = []; $response = $this->call('PUT', '/todos/1/title', $input); $this->assertEquals(404, $response->getStatusCode()); // POST /todos/1/delete $input = ['_token' => Session::token()]; $response = $this->call('POST', '/todos/1/delete', $input); $this->assertEquals(404, $response->getStatusCode()); // POST /todos/1/restore $input = ['_token' => Session::token()]; $response = $this->call('POST', '/todos/1/restore', $input); $this->assertEquals(404, $response->getStatusCode()); }
public function save() { $id = Input::get('id'); $ct = $this->category->find($id); $token = \Input::get('_token'); if (\Session::token() === $token) { $data = array('ten_vi' => Input::get('ten_vi'), 'hienthi' => Input::has('hienthi'), 'parent' => Input::get('category'), 'slug_vi' => \Str::slug(Input::get('ten_vi'), '-'), 'title_seo_vi' => Input::get('title_seo_vi'), 'desc_seo_vi' => Input::get('desc_seo_vi'), 'keyword_seo_vi' => Input::get('keyword_seo_vi')); // var_dump($data);die(); $ct->hienthi = $data['hienthi']; $ct->ten_vi = $data['ten_vi']; $ct->slug_vi = $data['slug_vi']; $ct->parent = $data['parent']; $ct->title_seo_vi = $data['title_seo_vi']; $ct->desc_seo_vi = $data['desc_seo_vi']; $ct->keyword_seo_vi = $data['keyword_seo_vi']; /* avoiding resubmission of same content */ if (count($ct->getDirty()) > 0) { \DB::beginTransaction(); try { $ct->save(); } catch (\Exception $e) { \DB::rollBack(); return \Redirect::back()->withInput()->with('success', 'ERROR : Update fail'); } \DB::commit(); return \Redirect::back()->withInput()->with('success', 'Cập nhật thành công'); } else { return \Redirect::back()->withInput()->with('success', 'Không thay đổi gì'); } } else { return \Redirect::back()->withInput()->with('success', 'Cập nhật thất bại, Token hết hiệu lực'); } }
public function crearEncuesta($encuesta, $email, $nombre = 'sin dato', $empresa = 'sin dato') { if (Session::token() != Input::get('_token')) { die; } $respuesta = Input::all(); //array respuestas form //print_r($respuesta); $datosEncuesta = DB::table('encuesta')->where('id', $encuesta)->first(); $cantidad = DB::table('pregunta')->where('idEncuesta', $encuesta)->count(); //Inserta usuario por email e ip $ip = Request::getClientIp(); $usuariosEmail = DB::table('users')->where('email', $email)->first(); //codigo rand /*$usuariosEmail = DB::table('users')->where('email', $email)->first(); $base = 1245; $cant= DB::table('users')->count(); $random = $base + $cant;*/ if (empty($usuariosEmail)) { $x = new User(); $x->email = $email; $x->nombre = $nombre; $x->empresa = $empresa; $x->ip = $ip; $x->codigo = ''; $x->save(); //codigo $usuarios = DB::table('users')->where('email', $email)->first(); $usuario = $usuarios->id; $codigo = '12' . $usuario; DB::table('users')->where('id', $usuario)->update(array('codigo' => $codigo)); } else { $mensaje = 'Usted ya ha completado la encuesta, sólo puede realizar esta acción una vez'; return View::make('encuesta.completado', array('mensaje' => $mensaje, 'encuesta' => $datosEncuesta)); } $usuarios = DB::table('users')->where('email', $email)->first(); $usuario = $usuarios->id; $codigo = $usuarios->codigo; Session::put('codigo', $codigo); //Inserta usuario_encuesta $x = new UsuarioEncuesta(); $x->idUsuario = $usuario; $x->idEncuesta = $encuesta; $x->save(); $usuarioEnc = DB::table('usuario_encuesta')->where('idUsuario', $usuario)->first(); $usuarioEncuesta = $usuarioEnc->id; //Inserta respuestas for ($i = 1; $i <= $cantidad; $i++) { $valor = Input::get('pregunta' . $i); if ($valor != '') { $x = new Respuesta(); $x->idUsuarioEncuesta = $usuarioEncuesta; $x->idEncuestaPregunta = $i; $x->valor = $valor; $x->save(); } } return Redirect::to('/formulario-ok'); //return View::make('encuesta.completado', array('encuesta' => $datosEncuesta,'email' => $email, 'nombre' => $nombre, 'empresa' => $empresa, 'codigo' => $random)); }
protected function routeFilters() { Route::filter('csrf', function () { if (\Session::token() != \Input::get('_token')) { throw new \Illuminate\Session\TokenMismatchException(); } }); }
/** * Show the form for creating a new resource. * * @return Response */ public function create() { if (Session::token() == Input::get('_token')) { $response = array('status' => 'fail', 'msg' => 'unauthorized Action'); } try { $month = Input::get('qter'); if ($month <= 3 && $month >= 1) { $q = Leave::whereBetween('date', array('2016-01-01', '2016-03-31'))->where('agent_ID', '=', Input::get('agent'))->count(); } else { if ($month <= 4 && $month >= 6) { $q = Leave::whereBetween('date', array('2016-04-01', '2016-06-30'))->where('agent_ID', '=', Input::get('agent'))->count(); } else { if ($month <= 7 && $month >= 9) { $q = Leave::whereBetween('date', array('2016-07-01', '2016-09-30'))->where('agent_ID', '=', Input::get('agent'))->count(); } else { if ($month <= 10 && $month >= 12) { $q = Leave::whereBetween('date', array('2016-10-01', '2016-12-31'))->where('agent_ID', '=', Input::get('agent'))->count(); } } } } $fullyBooked = Leave::where('date', '=', Input::get('date'))->count(); $agent = Leave::where('date', '=', Input::get('date'))->where('agent_ID', '=', Input::get('agent'))->count(); $monthMax = Leave::where('date', 'like', Input::get('month') . '%')->where('agent_ID', '=', Input::get('agent'))->count(); $maxLeave = Leave::where('agent_ID', '=', Input::get('agent'))->count(); if ($fullyBooked >= 1) { $response = array('status' => 'Error', 'msg' => 'Sorry!! This day is fully Booked..Please select another day'); } else { if ($agent >= 1) { $response = array('status' => 'Error', 'msg' => 'You have already booked this day!!'); } else { if ($q >= 5) { $response = array('status' => 'Error', 'msg' => 'You\'re Not allowed to go for more than 5 days leave in three months.. please see your Team lead in case you want an extra leave for this quota'); } else { if ($monthMax >= 5) { $response = array('status' => 'Error', 'msg' => 'Sorry! You can only take 5 leave days in a month!!'); } else { if ($maxLeave >= 21) { $response = array('status' => 'Error', 'msg' => 'Sorry! You have exhausted your leave days for this Year(21 max allowed)'); } else { $leave = new Leave(); $leave->date = Input::get('date'); $leave->agent_ID = Input::get('agent'); $leave->save(); $response = array('status' => 'success', 'msg' => 'leave day successfully booked'); } } } } } } catch (\Illuminate\Database\Eloquent\MassAssignmentException $e) { $response = array('status' => 'Error', 'msg' => 'mass assignment not allowed!!'); } catch (Illuminate\Database\QueryException $e) { $response = array('status' => 'Error', 'msg' => $e); } return Response::json($response); }
/** * Удаление пользователя * @depends testUpdateUser * @param $user_id */ public function testDeleteUser($user_id) { $this->assertNotEmpty($user_id); $url = '/rest/user/' . $user_id; \Session::start(); $this->delete($url, ['_token' => \Session::token()], ['X-Requested-With' => 'XMLHttpRequest'])->see(1); $this->assertResponseOk(); $this->get($url, ['X-Requested-With' => 'XMLHttpRequest'])->seeJson(['User not found']); }
public function testUpdate() { $server = array('HTTP_X-Requested-With' => 'XMLHttpRequest'); $params = ['_token' => \Session::token(), 'id' => 1, 'name' => 'test_update', 'email' => '*****@*****.**', 'password' => 'updatePassword', 'password_confirmation' => 'updatePassword']; $this->post('/user/store', $params, $server)->seeJsonEqualsExt(['status' => '200', 'message' => 'OK']); $this->seeInDatabaseExt('users', ['id' => 1, 'name' => 'test_update', 'email' => '*****@*****.**'], ['created_at' => false, 'updated_at' => true], false); $user = User::find(1); $this->assertTrue(\Hash::check('updatePassword', $user->password)); }
/** * 登録フォーム * @param null $one */ public function getForm($one = null) { \Session::put(self::SESSION_KEY, \Session::token()); $data = ['id' => $one, 'sections' => $this->section->getSectionList('name', 'section_id')]; if ($one) { $data['category'] = $this->category->getCategory($one); } $this->view('webmaster.category.form', $data); }
public function postDeleteIncasare() { if (Request::ajax()) { if (Session::token() === Input::get('_token')) { $id = Input::get('id_incasare'); DB::table('incasare_factura')->where('id_incasare', $id)->update(array('logical_delete' => 1)); return $id; } } }
/** * Test that a user can write a message. */ public function testWriteMessage() { $admin = $this->createSuperuser(); $this->be($admin); $conversation = $this->createConversation($admin); $this->createMessage($conversation); $this->call('GET', route('conversation.show', ['conversation' => $conversation->id])); $response = $this->call('POST', route('conversation.message.store', ['conversation' => $conversation->id]), ['message' => 'Test', '_token' => \Session::token()]); $this->assertRedirectedToRoute('conversation.show', ['conversation' => $conversation->id, '#message-2']); }
/** * Test that the user can't login with a wrong password. */ public function testLoginWrongPassword() { $password = '******'; $user = $this->createUser($password); $this->call('GET', route('account.login')); $this->assertResponseOk(); $this->call('POST', route('account.doLogin'), ['email' => $user->email, 'password' => $password . 'WRONG', '_token' => Session::token()]); $this->assertRedirectedToRoute('account.login'); $this->assertFalse(\Sentry::check()); }
/** * Удаление продукта * @depends testUpdateProduct * @param $product_id */ public function testDeleteProduct($product_id) { $this->assertNotEmpty($product_id); $url = '/rest/product/' . $product_id; \Session::start(); $user = \App\User::find(8); $this->actingAs($user)->delete($url, ['_token' => \Session::token()], ['X-Requested-With' => 'XMLHttpRequest'])->see(1); $this->assertResponseOk(); $this->get($url, ['X-Requested-With' => 'XMLHttpRequest'])->seeJson(['Product not found']); }
public function postAsociazaRole() { if (Request::ajax()) { if (Session::token() === Input::get('_token')) { $id = Input::get('id'); DB::table('aplicatie_role')->insertGetId(array('id_aplicatie' => Input::get('id_aplicatie'), 'id_role' => $id)); return $id; } } }
public function postDeleteEtapa() { if (Request::ajax()) { if (Session::token() !== Input::get('_token')) { $id = Input::get('id_etapa'); DB::table('etape_predare_livrabile')->where('id_etapa', $id)->update(array('logical_delete' => 1)); return $id; } } }
public function testDeleteOrder() { $order_id = 9; $url = '/rest/product/' . $order_id; \Session::start(); $user = \App\User::find(1); $this->actingAs($user)->delete($url, ['_token' => \Session::token()], ['X-Requested-With' => 'XMLHttpRequest']); $this->assertResponseOk(); $this->get($url, ['X-Requested-With' => 'XMLHttpRequest'])->seeJson(['id' => strval($order_id)]); }
/** * Run Sessionid Import * @return \Illuminate\Http\RedirectResponse * @throws \Illuminate\Session\TokenMismatchException */ public function getRunImport() { if (\Session::token() == \Input::get('_token') && \Fontello::configFileExists()) { $_response = \Fontello::getFontelloSessionId(); if ($_response && is_string($_response)) { return \Redirect::route('fontello.start.import'); } } else { throw new TokenMismatchException('Token has been changed'); } }
public function get_autocomplete() { if (Input::get('csrf_token') != Session::token()) { return '[]'; } $word = Input::get('term'); if (isset($word) and !empty($word)) { $keywords = explode(',', Config::get('settings::core.application_keywords')); return array_search_string($keywords, $word, true); } }
public function test_passwords_delete() { $this->test_access_after_setup(); $user = User::first(); $folder = PasswordFolder::where('user_id', $user->id)->first(); $password = factory(Password::class)->create(['folder_id' => $folder->id]); $this->actingAs($password->folder->user); $token = ['_token' => \Session::token()]; $this->delete(route('passwords.destroy', [$password->id]), $token); $this->assertRedirectedToRoute('passwords.index'); }
/** * Test that a client can be deleted via interface. */ public function testDeleteForm() { $admin = $this->createSuperuser(); $this->be($admin); $client = $this->createClient(); $this->call('GET', route('client.show', ['client' => $client->id])); $this->assertResponseOk(); $response = $this->call('DELETE', route('client.destroy', ['client' => $client->id]), ['_token' => Session::token()]); $this->assertRedirectedToRoute('client.index'); $client = \VisualAppeal\Connect\Client::find($client->id); $this->assertNull($client); }
/** * Test that a ProjectClient can be deleted via interface. */ public function testDeleteForm() { $admin = $this->createSuperuser(); $this->be($admin); $project = $this->createProject(); $projectClient = $this->createProjectClient($project); $this->call('GET', route('project.show', ['project' => $project->id])); $this->assertResponseOk(); $response = $this->call('DELETE', route('project.client.destroy', ['project' => $project->id, 'client' => $projectClient->client_id]), ['_token' => Session::token()]); $this->assertRedirectedToRoute('project.show', ['project' => $project->id]); $this->assertEquals(0, \VisualAppeal\Connect\ProjectClient::count()); }
/** * Test that a company can be deleted via interface. */ public function testDeleteForm() { $admin = $this->createSuperuser(); $this->be($admin); $company = $this->createCompany(); $this->call('GET', route('company.show', ['company' => $company->id])); $this->assertResponseOk(); $response = $this->call('DELETE', route('company.destroy', ['company' => $company->id]), ['_token' => Session::token()]); $this->assertRedirectedToRoute('company.index'); $company = \VisualAppeal\Connect\Company::find(1); $this->assertNull($company); }
public function delete() { $token = \Input::get('_token'); $id = intval(\Input::get('id')); if (\Request::ajax()) { if (\Session::token() === $token) { $idProduct = intval(\Input::get('id_product')); $this->pimgs->delete($id); $productimgs = $this->pimgs->paginateFindProductImgsOfProduct($idProduct, 3); return \Response::json(View::make('quanly.productimgs.ajax.productimgs', ['productimgs' => $productimgs])->render()); } } }
/** * Test that a ProjectPhase can be deleted via interface. */ public function testDeleteForm() { $admin = $this->createSuperuser(); $this->be($admin); $project = $this->createProject(); $projectPhase = $this->createProjectPhase(1, $project); $this->call('GET', route('project.phase.show', ['project' => $project->id, 'phase' => $projectPhase->id])); $this->assertResponseOk(); $response = $this->call('DELETE', route('project.phase.destroy', ['project' => $project->id, 'phase' => $projectPhase->id]), ['_token' => Session::token()]); $this->assertRedirectedToRoute('project.show', ['project' => $project->id]); $project = \VisualAppeal\Connect\ProjectPhase::find(1); $this->assertNull($project); }
/** * Test that a employee can be edited via form. */ public function testEditForm() { $admin = $this->createSuperuser(); $this->be($admin); $company = $this->createCompany(); $profile = $this->createCompanyProfile($company); $this->call('GET', route('company.profile.edit', ['company' => $company->id, 'profile' => $profile->id])); $this->assertResponseOk(); $response = $this->call('PUT', route('company.profile.update', ['company' => $company->id, 'profile' => $profile->id]), ['title' => 'foundation2', 'value' => '2009', '_token' => Session::token()]); $this->assertRedirectedToRoute('company.show', ['company' => $company->id]); $profile = CompanyProfile::find($profile->id); $this->assertNotNull($profile); $this->assertEquals('foundation2', $profile->title); }
/** * Test that a department can be edited via form. */ public function testEditForm() { $admin = $this->createSuperuser(); $this->be($admin); $company = $this->createCompany(); $department = $this->createCompanyDepartment($company); $this->call('GET', route('company.department.edit', ['company' => $company->id, 'department' => $department->id])); $this->assertResponseOk(); $this->call('PUT', route('company.department.update', ['company' => $company->id, 'department' => $department->id]), ['name' => $admin->id, 'phone' => '+12 3456 7890', '_token' => Session::token()]); $this->assertRedirectedToRoute('company.department.show', ['company' => $company->id, 'department' => $department->id]); $department = CompanyDepartment::find($department->id); $this->assertNotNull($department); $this->assertEquals('+12 3456 7890', $department->phone); }
/** * Test that a employee can be edited via form. */ public function testEditForm() { $admin = $this->createSuperuser(); $this->be($admin); $company = $this->createCompany(); $employee = $this->createCompanyClient($company); $this->call('GET', route('company.client.edit', ['company' => $company->id, 'employee' => $employee->id])); $this->assertResponseOk(); $response = $this->call('PUT', route('company.client.update', ['company' => $company->id, 'employee' => $employee->id]), ['employee_client_id' => $admin->client_id, 'joined_at' => '2002-07-05', '_token' => Session::token()]); $this->assertRedirectedToRoute('company.client.show', ['company' => $company->id, 'employee' => $employee->id]); $employee = CompanyClient::find($employee->id); $this->assertNotNull($employee); $this->assertEquals('2002-07-05', $employee->joined_at->format('Y-m-d')); }
/** * Test that a employee can be edited via form. */ public function testEditForm() { $admin = $this->createSuperuser(); $this->be($admin); $client = $this->createClient(); $comment = $this->createClientComment($client); $this->call('GET', route('client.comment.edit', ['client' => $client->id, 'comment' => $comment->id])); $this->assertResponseOk(); $response = $this->call('PUT', route('client.comment.update', ['client' => $client->id, 'comment' => $comment->id]), ['comment' => 'Test Update', '_token' => Session::token()]); $this->assertRedirectedToRoute('client.show', ['client' => $client->id]); $comment = ClientComment::find($comment->id); $this->assertNotNull($comment); $this->assertEquals('Test Update', $comment->comment); }
/** * Test that a ProjectPhaseDocumentComment can be deleted via interface. */ public function testDeleteForm() { $admin = $this->createSuperuser(); $this->be($admin); $project = $this->createProject(); $projectPhase = $this->createProjectPhase(1, $project); $projectPhaseDocument = $this->createProjectPhaseDocument($projectPhase); $projectPhaseDocumentComment = $this->createProjectPhaseDocumentComment($projectPhaseDocument); $this->call('GET', route('project.phase.document.show', ['project' => $project->id, 'phase' => $projectPhase->id, 'document' => $projectPhaseDocumentComment->id])); $this->assertResponseOk(); $this->call('DELETE', route('project.phase.document.comment.destroy', ['project' => $project->id, 'phase' => $projectPhase->id, 'document' => $projectPhaseDocument->id, 'comment' => $projectPhaseDocumentComment->id]), ['_token' => Session::token()]); $this->assertRedirectedToRoute('project.phase.document.show', ['project' => $project->id, 'phase' => $projectPhase->id, 'document' => $projectPhaseDocument->id]); $this->assertEquals(0, ProjectPhaseDocumentComment::count()); }
/** * Загрузка картинки */ public function testLoadImage() { $product_model = \App\BusinessLogic\Models\Product::first(); if (!$product_model) { return; } \Session::start(); $this->call('POST', $this->getFullUrl('/seller/media/upload'), ['product_id' => $product_model->id, '_token' => \Session::token()], [], ['files' => new UploadedFile(base_path() . '/storage/app/media/test.jpg', 'test.jpg')]); //echo "\n1.", csrf_token(), "\n2.", Session::token(), "\n"; //$this->assertEquals($response->getStatusCode(), 200); //\Storage::put('test.log', $response->getContent()); //file_put_contents('/var/www/jp.appros.ru/public/test.php', json_encode($response->original)); $this->assertResponseOk(); //var_dump( $response->getContent() ); }