本文整理汇总了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);
}
示例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#');*/
}
示例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');
}
示例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');
}
示例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());
}
示例6: validate
protected function validate($bool)
{
Validator::shouldReceive('make')->once()->andReturn(m::mock(['passes' => $bool]));
}
示例7: setupValidator
protected function setupValidator($returnValue, $returnErrs = array())
{
Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(array('passes' => $returnValue, 'errors' => $returnErrs)));
}
示例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);
}