public function testValidator() { $testData = json_decode(file_get_contents(__DIR__ . '/../../../../../mystique/testdata/length.json'), true); foreach ($testData['data'] as $testPoint) { $validator = new Length($testPoint['options']); $result = $validator->isValid($testPoint['value']); if ($testPoint['result']) { $this->assertTrue($result->getValue()); } else { $this->assertFalse($result->getValue()); } } }
public function testValidator() { $validator = new Length(['min' => 1, 'max' => 5]); $result = $validator->isValid('123456'); $this->assertEquals('Must be between 1 and 5 characters long', $result->getMessages()[0]); }