예제 #1
0
 /**
  * Функция, проверяющая входные значения используя набор правил $constraint
  * @param array $fields ассоциативный массив полей
  * @param Symfony\Component\Validator\Constraints\Collection $constraint набор правил, по которым будет производиться проверка
  * @throws Morfin60\BoxberryApi\Exception\ValidationException
  */
 public function validateValues($values, $constraint)
 {
     $violations = $this->validator->validate($values, $constraint);
     $violations_list = [];
     //If failed to validate arguments then we should throw ValidationException and pass violation list to $data
     if (0 !== $violations->count()) {
         throw new ValidationException('Failed to validate values', 1, null, $violations);
     }
 }
예제 #2
0
 /**
  * Test case to check whether at least one contact option has been filled out
  * by the user
  * The test receives a premade Person from the dataprovider and checks whether
  * there are validation errors.
  * @dataProvider contactOptionsProvider
  * @param \Entity\Person  $person       a person with a number of contact options set
  * @param integer         $errorCount   the expected amount of errors
  */
 public function testContactOptions($person, $errorCount)
 {
     $this->markTestIncomplete("testing one property at the time");
     try {
         $errors = $this->validator->validate($person);
     } catch (Exception $e) {
         //nothing needs to be done, this is mainly to sanitize output
     }
     $this->assertEquals($errorCount, count($errors));
 }
 /**
  * Test case for the Approved property (Type: Boolean)
  * The test creates an Testimonial, setting its approved status from an array of
  * fringe cases, then checking whether there are validation errors and whether the
  * retreived approved status equals the set approved status.
  * @dataProvider receiverProvider
  * @param multiple  $approved     a value from the fringe cases array
  * @param integer   $errorCount   the expected amount of errors
  */
 public function testApproved($approved, $errorCount)
 {
     $this->markTestIncomplete("testing one property at the time");
     try {
         $testimonial = $this->baseTestimonial;
         $testimonial->setApproved($approved);
         $errors = $this->validator->validate($testimonial);
     } catch (Exception $e) {
         //nothing needs to be done, this is mainly to sanitize output
     }
     $this->assertEquals($approved, $testimonial->getApproved());
     $this->assertEquals($errorCount, count($errors));
 }
예제 #4
0
 /**
  * Test case for the ParentId property (Type: Integer, maxlength = 10, must be unique).
  * The test creates a Skill, setting its parentId from an array of
  * fringe cases, then checking whether there are validation errors and whether the
  * retreived id equals the set id.
  * @dataProvider parentIdProvider
  * @param multiple  $parentId    a value from the fringe cases array
  * @param integer   $errorCount  the expected amount of errors
  */
 public function testParentId($parentId, $errorCount)
 {
     $this->markTestIncomplete("testing one property at the time");
     try {
         $skill = $this->baseSkill;
         $skill->setId($parentId);
         $errors = $this->validator->validate($skill);
     } catch (Exception $e) {
         //nothing needs to be done, this is mainly to sanitize output
     }
     $this->assertEquals($parentId, $skill->getId());
     $this->assertEquals($errorCount, count($errors));
 }
 /**
  * Test case for the Urlid property (Type: String, maxlength = 150, minlength = 2).
  * The test creates an Organisation, setting its Urlid, then checking for validation
  * errors and whether or not the getUrlid method retrieves the set value correctly.
  * Note that the fringe cases array isn't exhaustive, as blimey there are a lot.
  * The most common cases are tested.
  * @dataProvider urlidProvider
  * @param  multiple $urlid       a value from the fringe-cases array
  * @param  expected $expected    the expected value upon using the getter
  * @param  integer  $errorCount  the expected amount of errors for this title
  */
 public function testUrlid($urlid, $expected, $errorCount)
 {
     $this->markTestIncomplete("testing one property at the time");
     try {
         $organisation = $this->baseOrganisation;
         $organisation->setUrlid($urlid);
         $errors = $this->validator->validate($organisation);
     } catch (Exception $e) {
         //nothing needs to be done, this is mainly to sanitize output
     }
     if (isset($expected)) {
         $this->assertEquals($exptected, $organisation->getUrlid());
     }
     $this->assertEquals($errorCount, count($errors));
 }