Ejemplo n.º 1
0
 public function testLabel()
 {
     $object = new FromArray('label');
     $data = array('test field' => array('label' => 'Test field', 'rules' => array('required', 'minLength' => 12)));
     $validator = \Mockery::mock('Fuel\\Validation\\Validator');
     // Ensure the field gets added
     $validator->shouldReceive('addField')->once()->with('test field', 'Test field');
     // Create some expected rules
     $requiredRule = new Required();
     $minLengthRule = new MinLength(12);
     // Make sure the mocked object knows that the rules need to be created
     $validator->shouldReceive('createRuleInstance')->with('required', null)->once()->andReturn($requiredRule);
     $validator->shouldReceive('createRuleInstance')->with('minLength', 12)->once()->andReturn($minLengthRule);
     // Finally make sure the addRule function is called
     $validator->shouldReceive('addRule')->with('test field', $requiredRule)->once();
     $validator->shouldReceive('addRule')->with('test field', $minLengthRule)->once();
     $object->setData($data);
     $object->populateValidator($validator);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function populateValidator(Validator $validator)
 {
     return $this->ruleProvider->populateValidator($validator);
 }