コード例 #1
1
ファイル: InputTests.php プロジェクト: brslv/code
 public function testCanReplaceInputVlues()
 {
     $newInputs = ["get" => ["foo" => "Hello"], "post" => ["bar" => "World"]];
     $input = new Input();
     $input->replace($newInputs);
     $this->assertEquals($newInputs["get"]["foo"], $input->get("foo"));
     $this->assertEquals($newInputs["post"]["bar"], $input->post("bar"));
 }
コード例 #2
1
 public function testCanReplaceInputValues()
 {
     $newInputs = array('get' => array('foo' => 'hello'), 'post' => array('bar' => 'World'));
     $input = new Input();
     $input->replace($newInputs);
     $this->assertEquals($newInputs['get']['foo'], $input->get('foo'));
     $this->assertEquals($newInputs['post']['bar'], $input->post('bar'));
 }
コード例 #3
0
 /**
  * Store a newly created category in storage.
  *
  * @return Response
  */
 public function store()
 {
     $categoryValidator = Validator::make($data = Input::all(), Category::$rules);
     if ($categoryValidator->fails()) {
         return Redirect::back()->withErrors($categoryValidator)->withInput();
     }
     /* Category */
     if (Input::has('createCategory')) {
         Category::create($data);
         $message = "登録しました。";
     }
     if (Input::has('deleteCategory')) {
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $message = "削除しました。";
         if (Input::has('selectedCategory')) {
             Input::replace(array('selectedCategory', ''));
         }
     }
     if (Input::has('updateCategory')) {
         $err = array('required' => '新しい部門名を入力してください。');
         $categoryValidator = Validator::make($data = Input::all(), Category::$update_rules, $err);
         if ($categoryValidator->fails()) {
             return Redirect::back()->withErrors($categoryValidator)->withInput();
         }
         $c = Category::where('Bumon', Input::get('Bumon'))->first();
         Category::destroy($c->id);
         $data['Bumon'] = $data['new_categoryName'];
         Category::create($data);
         $message = "更新しました。";
     }
     return Redirect::route('employees.index')->with('message', $message);
 }
コード例 #4
0
 public function runIndex($searchValue, $formInput, $returnValue, $returnValue2 = null, $returnValue3 = null)
 {
     Input::replace($formInput);
     $controller = new TestController();
     $view = $controller->index();
     $tests = $view->getData()['testSet'];
     if (isset($returnValue3)) {
         $field3 = $returnValue3;
         $field2 = $returnValue2;
     } elseif (isset($returnValue2)) {
         $field2 = $returnValue2;
     }
     $field = $returnValue;
     if (is_numeric($searchValue) && $field == 'specimen_id' | $field == 'visit_id') {
         if ($searchValue == '0') {
             $this->assertEquals($searchValue, count($tests));
         } else {
             $this->assertGreaterThanOrEqual(1, count($tests));
         }
     } else {
         foreach ($tests as $key => $test) {
             if (isset($field3)) {
                 $this->assertEquals($searchValue, $test->{$field}->{$field2}->{$field3});
             } elseif (isset($field2)) {
                 $this->assertEquals($searchValue, $test->{$field}->{$field2});
             } else {
                 $this->assertEquals($searchValue, $test->{$field});
             }
         }
     }
 }
コード例 #5
0
 /**
  * Update the specified resource in storage.
  *
  * @return Response
  */
 public function update($id)
 {
     // Declare the rules for the form validation.
     //
     $rules = array();
     // Get all the inputs.
     //
     $inputs = Input::all();
     // If we are updating the password.
     //
     if (Input::get('password')) {
         // Update the validation rules.
         //
         $rules['password'] = '******';
         $rules['password_confirmation'] = 'Required';
     } else {
         // unset password fields once we are not updateing it
         //
         $input = Input::except(array('password', 'password_confirmation'));
         Input::replace($input);
     }
     // Validate the inputs.
     //
     $validator = Validator::make($inputs, $rules);
     // Check if the form validates with success.
     //
     if ($validator->fails()) {
         // Something went wrong.
         //
         return Redirect::to("/{$this->cmsAdminUrl}/{$this->package}/" . $id)->withErrors($validator->messages());
     }
     return parent::update($id);
 }
コード例 #6
0
ファイル: AccessControllerTest.php プロジェクト: sorora/aurp
 public function testLoginSuccess()
 {
     Auth::shouldReceive('attempt')->once()->andReturn(true);
     Input::replace(array('email' => '*****@*****.**', 'password' => 'password'));
     $this->post($this->prefix . 'login');
     $this->assertRedirectedToRoute(Config::get('empower::baseurl'));
 }
コード例 #7
0
 /**
  * Store a newly created shop in storage.
  *
  * @return Response
  */
 public function store()
 {
     $shopValidator = Validator::make($data = Input::all(), Shop::$rules);
     if ($shopValidator->fails()) {
         return Redirect::back()->withErrors($shopValidator)->withInput();
     }
     /* Shop */
     if (Input::has('createShop')) {
         Shop::create($data);
     }
     $message = "登録しました。";
     if (Input::has('deleteShop')) {
         $s = Shop::where('Tenpo', Input::get('Tenpo'))->first();
         Shop::destroy($s->id);
         $message = "削除しました。";
         if (Input::has('selectedShop')) {
             Input::replace(array('selectedShop', ''));
         }
     }
     if (Input::has('updateShop')) {
         $messages = array('required' => '新しい店舗名を入力してください。');
         $shopValidator = Validator::make($data = Input::all(), Shop::$update_rules, $messages);
         if ($shopValidator->fails()) {
             return Redirect::back()->withErrors($shopValidator)->withInput();
         }
         $s = Shop::where('Tenpo', Input::get('Tenpo'))->first();
         Shop::destroy($s->id);
         $data['Tenpo'] = $data['new_shopName'];
         Shop::create($data);
         $message = "更新しました。";
     }
     return Redirect::route('employees.index')->with('message', $message);
 }
コード例 #8
0
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Employee::$rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     /* Employee */
     if (Input::has('createEmployee')) {
         Employee::create($data);
     }
     $message = "登録しました。";
     if (Input::has('deleteEmployee')) {
         $e = Employee::where('name', Input::get('name'))->first();
         Employee::destroy($e->id);
         $message = "削除しました。";
         if (Input::has('selectedEmployee')) {
             Input::replace(array('selectedEmployee', ''));
         }
     }
     if (Input::has('updateEmployee')) {
         $validator_for_update = Validator::make($data = Input::all(), Employee::$update_rules);
         if ($validator_for_update->fails()) {
             return Redirect::back()->withErrors($validator_for_update)->withInput();
         }
         $e = Employee::where('name', Input::get('name'))->first();
         Employee::destroy($e->id);
         $data['name'] = $data['new_name'];
         Employee::create($data);
         $message = "更新しました。";
     }
     return Redirect::route('employees.index')->with('message', $message);
 }
コード例 #9
0
ファイル: SeriesControllerTest.php プロジェクト: sorora/bms
 public function testUpdateSuccess()
 {
     Input::replace(array('title' => 'Foo', 'task' => 'Foo'));
     $this->mock->shouldReceive('findOrFail')->with(3)->once()->andReturn($this->mock);
     $this->mock->shouldReceive('update')->once()->andReturn(true);
     $this->put($this->url . '/3');
     $this->assertRedirectedToRoute($this->route . '.index');
 }
コード例 #10
0
ファイル: UserSeeder.php プロジェクト: lakedawson/vocal
 /**
  * Add products to the database
  *
  * @return void
  */
 private function seedUser()
 {
     User::truncate();
     UserAddress::truncate();
     Input::replace(array('username' => 'Test', 'email' => '*****@*****.**', 'addresses' => array(array('address' => '123 Fake Street', 'city' => 'Faketon'), array('address' => '10 Test Street', 'city' => 'Testville'))));
     $user = new User();
     $user->saveRecursive();
 }
コード例 #11
0
 public function testHandleEditDuplicateOffer()
 {
     Input::replace($input = array('key_word' => 'offerone', 'url' => 'http://test.com'));
     $this->storageObject->shouldReceive('findOrFail')->once()->andReturn($this->storageObject);
     $this->storageObject->shouldReceive('isDuplicate')->once()->andReturn(true);
     $this->call('POST', '/edit', $input);
     $this->assertRedirectedToAction('OffersController@edit');
     $this->assertSessionHasErrors('duplicate');
 }
コード例 #12
0
 public function testSendPromo()
 {
     Input::replace($input = array('From' => '5551234567', 'Body' => 'http://test.com'));
     $this->offer->url = 'http://test.com';
     $this->offer->shouldReceive('where')->once()->andReturn($this->offer);
     $this->messageProvider->shouldReceive('message')->once();
     $this->call('POST', '/promo', $input);
     $this->assertResponseOk();
 }
コード例 #13
0
 public function testHandleLoginFailedAttempt()
 {
     Input::replace($input = array('email' => '*****@*****.**', 'password' => 'test'));
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(array('fails' => false)));
     Auth::shouldReceive('attempt')->once()->andReturn(false);
     $this->call('POST', '/login', $input);
     $this->assertRedirectedTo('/login');
     $this->assertSessionHasErrors('invalid');
 }
コード例 #14
0
 public function testStoreFailsForInvalidData()
 {
     $this->setupValidator(False);
     Input::replace(array('item' => 'foo'));
     $response = $this->test->store();
     $this->assertIsRedirectToIndex($response);
     $this->assertSessionHasErrors();
     $this->assertSessionHas('_old_input.item');
 }
コード例 #15
0
 /**
  * Tests the update function in the SpecimenRejectionController
  */
 public function testDelete()
 {
     Input::replace($this->rejectionReasonData);
     $rejectionReason = new SpecimenRejectionController();
     $rejectionReason->store();
     $rejectionReasonstored = RejectionReason::orderBy('id', 'desc')->take(1)->get()->toArray();
     $rejectionReason->delete($rejectionReasonstored[0]['id']);
     $rejectionReasonDeleted = RejectionReason::find($rejectionReasonstored[0]['id']);
     $this->assertNull($rejectionReasonDeleted);
 }
コード例 #16
0
 public function specimenCountPerStatus()
 {
     Input::replace($this->specimenData);
     $specimenType = new SpecimenTypeController();
     $specimenType->store();
     $specimenTypeStored = SpecimenType::orderBy('id', 'desc')->take(1)->get()->toArray();
     $specimenTypeSaved = SpecimenType::find($specimenTypeStored[0]['id']);
     $count = $specimenTypeSaved->countPerStatus([Specimen::ACCEPTED, Specimen::REJECTED, Specimen::NOT_COLLECTED]);
     $this->assertEquals($specimenTypeSaved->specimen->count(), $count);
 }
コード例 #17
0
 /**
  * Tests the update function in the TestCategoryController
  * @param  void
  * @return void
  */
 public function testDelete()
 {
     Input::replace($this->testCategoryData);
     $testCategory = new TestCategoryController();
     $testCategory->store();
     $testCategorystored = TestCategory::orderBy('id', 'desc')->take(1)->get()->toArray();
     $testCategory->delete($testCategorystored[0]['id']);
     $testCategoriesDeleted = TestCategory::withTrashed()->find($testCategorystored[0]['id']);
     $this->assertNotNull($testCategoriesDeleted->deleted_at);
 }
コード例 #18
0
 /**
  * Testing Control saveResults function
  */
 public function testSaveResults()
 {
     Input::replace($this->inputSaveResults);
     $controlController = new ControlController();
     $controlController->saveResults(1);
     $results = ControlTest::orderBy('id', 'desc')->first()->controlResults;
     foreach ($results as $result) {
         $key = 'm_' . $result->control_measure_id;
         $this->assertEquals($this->inputSaveResults[$key], $result->results);
     }
 }
コード例 #19
0
 public function testRunPrincipalAndSendSuccessMessage()
 {
     $listener = Mockery::mock('Listener');
     $listener->shouldReceive('storeSucceeded')->once()->with('foo<br>bar');
     $principal = Mockery::mock('Principal');
     $principal->shouldReceive('wrap')->once()->andReturn('foo\\nbar');
     $adapter = new StringWrapAdapter($listener, $principal);
     Input::replace(array('text' => 'foo', 'length' => 2));
     $this->setupValidator(True);
     $adapter->store();
 }
コード例 #20
0
 public function test_check_sql()
 {
     Input::replace($input = ['title' => 'Prof', 'title2' => 'Prof;!', 'number_double' => '3.14;<>', 'number_float' => '1.5;<>', 'number_integer' => '1;<>', 'sortby' => 'id;desc', 'limit' => 10, 'offset' => 5]);
     $sql = RESTQuery::create(TestModel::class)->query()->toSql();
     $this->assertContains('where `title` LIKE ?', $sql);
     $this->assertContains('`title2` != ?', $sql);
     $this->assertContains('`number_double` <> ?', $sql);
     $this->assertContains('order by `id` desc', $sql);
     $this->assertContains('limit 10', $sql);
     $this->assertContains('offset 5', $sql);
 }
コード例 #21
0
 /**
  * Testing ControlResultsController Update function
  */
 public function testUpdate()
 {
     echo "\n\nCONTROL RESULTS CONTROLLER TEST\n\n";
     Input::replace($this->inputUpdateResults);
     $controlResultsController = new ControlResultsController();
     $controlResultsController->update(1);
     $results = ControlTest::orderBy('id', 'asc')->first()->controlResults;
     foreach ($results as $result) {
         $key = 'm_' . $result->control_measure_id;
         $this->assertEquals($this->inputUpdateResults[$key], $result->results);
     }
 }
コード例 #22
0
 /**
  * Tests the update function in the DrugController
  * @param  void
  * @return void
  */
 public function testUpdate()
 {
     // Update the Drug
     Input::replace($this->drugData);
     $drug = new DrugController();
     $drug->store();
     $drugStored = Drug::orderBy('id', 'desc')->take(1)->get()->toArray();
     Input::replace($this->drugUpdate);
     $drug->update($drugStored[0]['id']);
     $drugSaved = Drug::find($drugStored[0]['id']);
     $this->assertEquals($drugSaved->name, $this->drugUpdate['name']);
     $this->assertEquals($drugSaved->description, $this->drugUpdate['description']);
 }
コード例 #23
0
 public function testAuthControllerRequestsDataFromGoogle()
 {
     Input::replace(array('code' => 'foo'));
     Config::shouldReceive('get')->atLeast()->once()->andReturn('google');
     $mock = Mockery::mock('day005_google')->shouldReceive('requestAccessToken')->once()->shouldReceive('request')->once()->andReturn('{"Foo":"Bar"}')->getMock();
     OAuth::shouldReceive('consumer')->once()->andReturn($mock);
     $response = $this->test->postLogin();
     $this->assertPropertyExists($this->layout, 'content');
     $this->assertIsView($this->layout->content);
     // TODO: Figure out why this is no longer working
     // $result = $this->layout->render();
     // $this->assertContains('Bar', $result);
 }
コード例 #24
0
 /**
  * Tests the diseases CRUD
  *
  * @return void
  */
 public function testifDiseaseCrudWorks()
 {
     // add, edit and delete disease entry
     Input::replace($this->inputDisease);
     $config = new ReportController();
     $config->disease();
     $diseaseModel = Disease::all();
     //Check if entry was added
     $this->assertEquals($diseaseModel[3]->name, $this->inputDisease['new-diseases']['1']['disease']);
     //Check if entry was edited
     $this->assertEquals($diseaseModel[0]->name, $this->inputDisease['diseases']['1']['disease']);
     //Check if entry was deleted - the only available are the three above => one deleted
     $this->assertEquals(count($diseaseModel), 4);
 }
コード例 #25
0
 public function testCreate_ok()
 {
     $abv = \Mockery::mock(ABV::class)->makePartial();
     $ar = \Mockery::mock(AR::class)->makePartial();
     $abc = new ABC($abv, $ar);
     $req = new Request();
     $abv->shouldReceive('create')->with(149, $req);
     $ar->shouldReceive('addBooks')->with(149, [150]);
     \Input::replace(['id' => 150]);
     $r = $abc->create($req, 149);
     $this->assertInstanceOf(JsonResponse::class, $r);
     $this->assertSame(200, $r->getStatusCode());
     $this->assertSame([], $r->getData());
 }
コード例 #26
0
 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $adminPassword = Config::get('madison.seeder.admin_password');
     // Login as admin to create docs
     $credentials = array('email' => $adminEmail, 'password' => $adminPassword);
     Auth::attempt($credentials);
     $admin = Auth::user();
     $annotation1 = ['user_id' => 1, 'doc_id' => 1, 'quote' => 'Document', 'text' => 'Annotation!', 'uri' => '/docs/example-document', 'tags' => [], 'comments' => [], 'ranges' => [['start' => '/p[1]', 'end' => '/p[1]', 'startOffset' => 4, 'endOffset' => 12]]];
     Input::replace($annotation1);
     App::make('App\\Http\\Controllers\\AnnotationApiController')->postIndex($annotation1['doc_id']);
     $annotation2 = ['user_id' => 1, 'doc_id' => 1, 'quote' => 'Content', 'text' => 'Another Annotation!', 'uri' => '/docs/example-document', 'tags' => [], 'comments' => [], 'ranges' => [['start' => '/p[1]', 'end' => '/p[1]', 'startOffset' => 13, 'endOffset' => 20]]];
     Input::replace($annotation2);
     App::make('App\\Http\\Controllers\\AnnotationApiController')->postIndex($annotation2['doc_id']);
 }
コード例 #27
0
 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $adminPassword = Config::get('madison.seeder.admin_password');
     // Login as admin to create docs
     $credentials = ['email' => $adminEmail, 'password' => $adminPassword];
     Auth::attempt($credentials);
     $admin = Auth::user();
     $category1 = ['text' => 'first category'];
     $category2 = ['text' => 'second category'];
     Input::replace($input = ['categories' => [$category1]]);
     App::make('App\\Http\\Controllers\\DocumentController')->postCategories(1);
     Input::replace($input = ['categories' => [$category1, $category2]]);
     App::make('App\\Http\\Controllers\\DocumentController')->postCategories(1);
 }
コード例 #28
0
 /**
  * Tests the update function in the OrganismController
  * @param  void
  * @return void
  */
 public function testUpdate()
 {
     Input::replace($this->organismData);
     $organism = new OrganismController();
     $organism->store();
     $organismStored = Organism::orderBy('id', 'desc')->take(1)->get()->toArray();
     Input::replace($this->organismDataUpdate);
     $organism->update($organismStored[0]['id']);
     $organismSavedUpdated = Organism::find($organismStored[0]['id']);
     $this->assertEquals($organismSavedUpdated->name, $this->organismDataUpdate['name']);
     $this->assertEquals($organismSavedUpdated->description, $this->organismDataUpdate['description']);
     //Getting the drugs related to the organism
     /*$organismDrugUpdated = Organism::find($organismStored[0]['id'])->drugs->toArray();
     		
     		$this->assertEquals(12, $this->organismDataUpdate['drugs'][0]);*/
 }
コード例 #29
0
ファイル: ApiController.php プロジェクト: lcalderonc/hdc2016
 /**
  * reenviar tarea de officetrack
  * POST /api/reenviarot
  * @param  int  gestion_id
  * @return Response
  */
 public function postReenviarot()
 {
     if (Input::has('gestion_id')) {
         Input::replace(array('buscar' => Input::get('gestion_id'), 'tipo' => 'g.id'));
         $result = Gestion::getCargar();
         $resultDos = array();
         if ($result['rst'] == '1') {
             $datos = $result['datos'][0];
             $resultDos['fh_agenda'] = $datos->fh_agenda;
             $resultDos['codactu'] = trim($datos->codactu . ' ');
             $resultDos['fecha_registro'] = trim($datos->fecha_registro . ' ');
             $resultDos['nombre_cliente'] = trim($datos->nombre_cliente . ' ');
             $resultDos['act_codmotivo_req_catv'] = trim($datos->codmotivo_req_catv . ' ');
             $resultDos['orden_trabajo'] = trim($datos->orden_trabajo . ' ');
             $resultDos['fftt'] = trim($datos->fftt . ' ');
             $resultDos['dir_terminal'] = trim($datos->dir_terminal . ' ');
             $resultDos['inscripcion'] = trim($datos->inscripcion . ' ');
             $resultDos['mdf'] = trim($datos->mdf . ' ');
             $resultDos['segmento'] = trim($datos->segmento . ' ');
             $resultDos['clase_servicio_catv'] = trim($datos->clase_servicio_catv . ' ');
             $resultDos['total_averias'] = trim($datos->total_averias . ' ');
             $resultDos['zonal'] = trim($datos->zonal . ' ');
             $resultDos['llamadastec15dias'] = trim($datos->llamadastec15dias . ' ');
             $resultDos['quiebre'] = trim($datos->quiebre . ' ');
             $resultDos['lejano'] = trim($datos->lejano . ' ');
             $resultDos['distrito'] = trim($datos->distrito . ' ');
             $resultDos['averia_m1'] = trim($datos->averia_m1 . ' ');
             $resultDos['telefono_codclientecms'] = trim($datos->telefono_codclientecms . ' ');
             $resultDos['area2'] = trim($datos->area2 . ' ');
             $resultDos['eecc_final'] = trim($datos->eecc_zona . ' ');
             $resultDos['gestion_id'] = trim($datos->id . ' ');
             $resultDos['estado'] = trim($datos->estado . ' ');
             $resultDos['velocidad'] = trim($datos->veloc_adsl . ' ');
             $resultDos['cr_observacion'] = trim($datos->observacion . ' ');
             //$resultDos['reenviar'] =trim( $datos->reenviar.' ');
             $resultDos['actividad'] = trim($datos->actividad . ' ');
             $resultDos['tecnico_id'] = trim($datos->tecnico_id . ' ');
             $resultDos['coordinado2'] = trim($datos->coordinado . ' ');
             $resultDos['direccion_instalacion'] = trim($datos->direccion_instalacion . ' ');
             $resultTres = Helpers::ruta('officetrack/procesarot', 'POST', $resultDos, false);
             return Response::json($resultTres);
         } else {
             return Response::json($result);
         }
     }
 }
コード例 #30
0
ファイル: Helpers.php プロジェクト: lueimg/activista
 /**
  * Metodo para crear request entre controladores
  * 
  * @param type $url Metodo destino
  * @param type $method Metodo de envio (GET o POST)
  * @param type $data Arreglo de datos
  * @param type $json Si el retorno es json o array
  * @return type JSON o ARRAY
  */
 public static function ruta($url, $method, $data, $json = true)
 {
     //Datos enviados, vector
     Input::replace($data);
     //Crea Request via GET o POST
     $request = Request::create($url, $method);
     //Obtener response
     $response = Route::dispatch($request);
     //Solo contenido, en formato json
     $content = $response->getContent();
     if ($json) {
         //Retorna formato JSON
         return $content;
     } else {
         //Retorna un arreglo
         return json_decode($content);
     }
 }