public function testNotEmpty() { $val = new \core\validation\Validation(); $val->setPropertyToValidate('empty', \core\validation\validation::$not_empty); $this->assertFalse($val->validate($this)); $val = new \core\validation\Validation(); $val->setPropertyToValidate('notEmpty', \core\validation\validation::$not_empty); $this->assertTrue($val->validate($this)); }
public function testMinValue() { $validateWithHigherValue = new \core\validation\Validation(); $validateWithHigherValue->setPropertyToValidate('int', \core\validation\validation::$min_value, 50000); $validateWithLowerValue = new \core\validation\Validation(); $validateWithLowerValue->setPropertyToValidate('int', \core\validation\validation::$min_value, 50); $this->assertFalse($validateWithHigherValue->validate($this)); $this->assertTrue($validateWithLowerValue->validate($this)); }
public function testRegex() { $regex = "/\\D/"; $val = new \core\validation\Validation(); $val->setPropertyToValidate('onlyNumberString', \core\validation\validation::$regex, $regex); $this->assertTrue($val->validate($this)); $val = new \core\validation\Validation(); $val->setPropertyToValidate('notOnlyNumbersStrin', \core\validation\validation::$regex, $regex); $this->assertFalse($val->validate($this)); }
public function testSeveralErrorMessagesOnProperty() { $errorMessage = "Ett felmmeddelande som kan läsas ut om det är något fel"; $errorMessage2 = "Ett till meddelande"; $val = new \core\validation\Validation(); $val->setPropertyToValidate('notNumeric', \core\validation\validation::$is_numeric, null, $errorMessage); $val->setPropertyToValidate('notNumeric', \core\validation\validation::$max_value, 1000, $errorMessage2); $val->validate($this); $this->assertEquals($val->getErrorsOnProperty('notNumeric')[0], $errorMessage); $this->assertEquals($val->getErrorsOnProperty('notNumeric')[1], $errorMessage2); }