本文整理汇总了PHP中Input::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::replace方法的具体用法?PHP Input::replace怎么用?PHP Input::replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input::replace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCanReplaceInputVlues
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: testCanReplaceInputValues
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: store
/**
* 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: runIndex
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: update
/**
* 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'] = 'Required|Confirmed';
$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: testLoginSuccess
public function testLoginSuccess()
{
Auth::shouldReceive('attempt')->once()->andReturn(true);
Input::replace(array('email' => 'admin@admin.com', 'password' => 'password'));
$this->post($this->prefix . 'login');
$this->assertRedirectedToRoute(Config::get('empower::baseurl'));
}
示例7: store
/**
* 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: store
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: testUpdateSuccess
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: seedUser
/**
* Add products to the database
*
* @return void
*/
private function seedUser()
{
User::truncate();
UserAddress::truncate();
Input::replace(array('username' => 'Test', 'email' => 'test@test.com', 'addresses' => array(array('address' => '123 Fake Street', 'city' => 'Faketon'), array('address' => '10 Test Street', 'city' => 'Testville'))));
$user = new User();
$user->saveRecursive();
}
示例11: testHandleEditDuplicateOffer
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: testSendPromo
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: testHandleLoginFailedAttempt
public function testHandleLoginFailedAttempt()
{
Input::replace($input = array('email' => 'chris@theantichris.com', '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: testStoreFailsForInvalidData
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: testDelete
/**
* 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);
}