Esempio n. 1
0
 /**
  * Test that the validation rules are parsed correctly.
  * If the bundle has a parent, also test that the values between the two are merged correctly.
  */
 public function testGetValidationRules()
 {
     $parent = $this->parent->getValidationRules();
     $formats = $this->formats->getValidationRules();
     $inflections = $this->inflections->getValidationRules();
     $validations = $this->validations->getValidationRules();
     $parentValidations = ['phone' => 'ex', 'postalCode' => 'ex', 'ssn' => 'ex'];
     // Parent
     $this->assertTrue(is_array($parent));
     $this->assertEquals($parentValidations, $parent);
     // Formats
     $this->assertTrue(is_array($formats));
     $this->assertEquals($parentValidations, $formats);
     // Inflections
     $this->assertTrue(is_array($inflections));
     $this->assertEquals($parentValidations, $inflections);
     // Validations
     $this->assertTrue(is_array($validations));
     $this->assertEquals(['phone' => 'ex_VA', 'postalCode' => 'ex', 'ssn' => 'ex_VA'], $validations);
     // By key
     $this->assertEquals('ex_VA', $this->validations->getValidationRules('phone'));
     $this->assertEquals('ex_VA', $this->validations->getValidationRules('ssn'));
     $this->assertEquals('ex', $this->validations->getValidationRules('postalCode'));
     $this->assertEquals(null, $this->validations->getValidationRules('fakeKey'));
 }