本文整理汇总了PHP中Illuminate\Support\Facades\Validator::shouldReceive方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::shouldReceive方法的具体用法?PHP Validator::shouldReceive怎么用?PHP Validator::shouldReceive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\Validator
的用法示例。
在下文中一共展示了Validator::shouldReceive方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testValidationFailsStoresErrors
/**
* Test if the failing validation stores the error messages.
*
* @return void
*/
public function testValidationFailsStoresErrors()
{
Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['passes' => false, 'messages' => $this->mockMessageBag(['test'])]));
$resource = new ResourceValidatingStub();
$this->assertFalse($resource->validate());
$this->assertInternalType('array', $resource->getErrors());
$this->assertEquals('test', $resource->getErrors()[0]);
}
示例2: testFormValidation
public function testFormValidation()
{
$route = m::mock('Route');
$route->shouldReceive('getAction')->andReturn(array('controller' => 'indexRule'));
$request = m::mock('Request');
$request->shouldReceive('all')->andReturn(array('name' => 'test'));
App::shouldReceive('make')->andReturn(new FormStub());
Validator::shouldReceive('make')->andReturn(new ValidatorClass($this->getRealTranslator(), $request->all(), array('name' => array('required', 'min:5'))));
$controller = new RESTControllerStub();
$controller->validateRequest($route, $request);
}
示例3: validateCustomMessage
/**
* @test
*/
public function validateCustomMessage()
{
$mockClass = m::mock(ValidateStub::class)->makePartial();
$customMessage = 'This has failed.';
$data = ['name' => 'Testing'];
$this->setExpectedException(ValidateException::class, $customMessage);
Validator::shouldReceive('make')->once()->andReturn(m::mock(['fails' => true]));
Lang::shouldReceive('get')->once()->andReturn('Error');
$mockClass->validate($data, $customMessage);
}
示例4: testGetValidatorReturnsFactory
public function testGetValidatorReturnsFactory()
{
Validator::shouldReceive('getFacadeRoot')->once()->andReturn(Mockery::mock('\\Illuminate\\Validation\\Factory'));
$validator = $this->trait->getValidator();
}
示例5: update_ValidateException
/**
* @test
*/
public function update_ValidateException()
{
$this->setExpectedException(ValidateException::class, 'Error');
$mockService = m::mock(CrudServiceBase::class)->makePartial();
$mockModel = m::mock('Model');
$name = null;
Validator::shouldReceive('make')->once()->andReturn(m::mock(['fails' => 'true']));
Lang::shouldReceive('get')->once()->andReturn('Error');
$mockService->shouldReceive('read')->once()->andReturn($mockModel);
$mockService->addValidationOption('rules', 'name', 'required');
$mockService->update(1, compact('name'));
}