当前位置: 首页>>代码示例>>PHP>>正文


PHP Validator::shouldReceive方法代码示例

本文整理汇总了PHP中Validator::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::shouldReceive方法的具体用法?PHP Validator::shouldReceive怎么用?PHP Validator::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Validator的用法示例。


在下文中一共展示了Validator::shouldReceive方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetsErrorsOnObjectIfValidationFails

 public function testSetsErrorsOnObjectIfValidationFails()
 {
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['passes' => false, 'messages' => 'messages']));
     $result = $this->model->validate();
     $this->assertEquals(false, $result);
     $this->assertEquals('messages', $this->model->errors);
 }
开发者ID:joyhuang-note,项目名称:laravel-testing-decoded,代码行数:7,代码来源:BaseModelTest.php

示例2: test_add_categoria

 /**
  * A basic test example.
  *
  * @return void
  */
 public function test_add_categoria()
 {
     $this->flushSession();
     $this->withoutMiddleware();
     $credenciales = array('name' => 'elver.galarga', 'password' => 'Elver.Galarga');
     Auth::shouldReceive('attempt')->once()->with($credenciales)->andReturn(true);
     $response = $this->call('POST', '/login', $credenciales);
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['fails' => 'true']));
     //$this->assertEquals(500, $response->getStatusCode());
     //$crawler = $this->followRedirects();
     //$this->assertInstanceOf('Illuminate\Http\RedirectResponse', $response);
     $this->assertEquals($this->baseUrl . '/mi_contenido', $response->getTargetUrl());
     //$this->assertResponseStatus(302);
     //$this->assertTrue($response->isRedirection());
     //$this->assertRedirectedTo('/mi_contenido');
     //$crawler = $this->followRedirect();
     //$this->assertRedirectedTo('/mi_contenido');
     //App::instance('Illuminate\Auth\Manager', $this->getAuthMock(true));
     //$this->assertRedirectedToRoute('mi_contenido');
     //$this->assertRedirectedToAction('contenidosController@create');
     //Auth::shouldReceive('user')->andReturn($user = m::mock('StdClass'));
     /*$faker = Faker\Factory::create();
       $user = new User(['name' => 'elver.galarga']);
       $this->be($user);
       $this->visit('/mi_contenido')
            ->press('Agregar categoría nueva')
            ->type($faker->word, 'txtcategoria')
            ->type($faker->text, 'txtdescripcion')
            ->press('Guardar')
            ->seePageIs('http://app-isw.net/mi_contenido#');*/
 }
开发者ID:elotgamu,项目名称:app-isw,代码行数:36,代码来源:agregar_nueva_categoria_Test.php

示例3: testEsarz

 public function testEsarz()
 {
     $this->mock->shouldReceive('create')->once();
     $this->app->instance('Food', $this->mock);
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['fails' => false]));
     Mail::shouldReceive('send')->once()->with('emails.post', ['title' => 'dasdasd'], $this->getSendCallbackMock());
     $this->call('POST', 'esarz', array('title' => 'dasdasd'));
     $this->assertRedirectedToRoute('foods.index');
 }
开发者ID:sharad23,项目名称:testing,代码行数:9,代码来源:FoodsControllerTest.php

示例4: 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');
 }
开发者ID:theantichris,项目名称:Retext,代码行数:9,代码来源:LoginControllerTest.php

示例5: testStoreIfValidationFails

 public function testStoreIfValidationFails()
 {
     $file = new File(public_path('img/pdf.png'), 'pdf.png', 'image/png', 999, null, true);
     $messageBag = m::mock(['first' => 'foo_bar_baz']);
     \Validator::shouldReceive('make')->andReturnUsing(function ($inputs, $rules) {
         $this->assertEquals('required|mimes:pdf,gif,jpeg,png|max:1024', $rules['submitted_file']);
         return m::self();
     })->shouldReceive('fails')->once()->andReturn(true)->shouldReceive('errors')->once()->andReturn($messageBag);
     $this->call('POST', route('admin.upload_files.store'), [], [], ['submitted_file' => $file]);
     $this->assertEquals(400, $this->response->status());
 }
开发者ID:larasite,项目名称:larasite,代码行数:11,代码来源:UploadFileControllerTest.php

示例6: validate

 protected function validate($bool)
 {
     Validator::shouldReceive('make')->once()->andReturn(m::mock(['passes' => $bool]));
 }
开发者ID:Grapheme,项目名称:doktornarabote,代码行数:4,代码来源:GroupsTest.php

示例7: setupValidator

 protected function setupValidator($returnValue, $returnErrs = array())
 {
     Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(array('passes' => $returnValue, 'errors' => $returnErrs)));
 }
开发者ID:viniciusferreira,项目名称:daily,代码行数:4,代码来源:AdapterTestCase.php

示例8: testUpdateShouldValidateData

 /**
  * Test update should validate data
  *
  * @test
  */
 public function testUpdateShouldValidateData()
 {
     $this->migrate('testbench_mysql');
     // Stub data
     $input = ['stubValue' => 'tata'];
     // Our Validator should "make" itself
     \Validator::shouldReceive('make')->once()->with($input, ['stubValue' => 'required|min:1|max:5'])->andReturn(m::self());
     // We test the data against the rules
     // !!! the validate() method uses fails() for Validation
     \Validator::shouldReceive('fails')->once()->andReturn(false);
     // Since the Validator is suposed to pass
     // the messages() method should NOT be called
     \Validator::shouldNotReceive('messages');
     /**/
     \Resource::update(1, $input);
 }
开发者ID:microffice,项目名称:core,代码行数:21,代码来源:CoreEloquentModelResourceTraitTest.php


注:本文中的Validator::shouldReceive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。