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


PHP Validator::shouldReceive方法代码示例

本文整理汇总了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]);
 }
开发者ID:peakfijn,项目名称:get-some-rest,代码行数:13,代码来源:ResourceValidatingTraitTest.php

示例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);
 }
开发者ID:andizzle,项目名称:rest-framework,代码行数:11,代码来源:RESTControllerTest.php

示例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);
 }
开发者ID:iolson,项目名称:support,代码行数:13,代码来源:ValidateTraitTest.php

示例4: testGetValidatorReturnsFactory

 public function testGetValidatorReturnsFactory()
 {
     Validator::shouldReceive('getFacadeRoot')->once()->andReturn(Mockery::mock('\\Illuminate\\Validation\\Factory'));
     $validator = $this->trait->getValidator();
 }
开发者ID:dalabarge,项目名称:validating,代码行数:5,代码来源:ValidatingTraitTest.php

示例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'));
 }
开发者ID:iolson,项目名称:support,代码行数:15,代码来源:CrudServiceBaseTest.php


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