public function test_validate_after_with_date_but_not_format() { $now = '1394/9/13'; $tomorrow = '1394/9/14'; $yesterday = '1394/9/12'; $this->assertTrue($this->validator->validateAfter('foo', $tomorrow, [$now])); $this->assertFalse($this->validator->validateAfter('foo', $yesterday, [$now])); $this->assertFalse($this->validator->validateAfter('foo', $now, [$now])); $this->assertFalse($this->validator->validateAfter('foo', 'bar', [$now])); }
public function setUp() { parent::setUp(); $this->translator = new Translator(new \Illuminate\Translation\FileLoader(new \Illuminate\Filesystem\Filesystem(), __DIR__ . '/../sample-lang'), 'en'); $this->translator->setLocale('en'); $this->factory = new Factory($this->translator); $validator = new JalaliValidator(); $this->factory->extend('jalali', function ($attribute, $value, $parameter) use($validator) { return $validator->validateJalali($attribute, $value, $parameter); }); $this->factory->extend('jalali_after', function ($attribute, $value, $parameter) use($validator) { return $validator->validateAfter($attribute, $value, $parameter); }); $this->factory->extend('jalali_before', function ($attribute, $value, $parameter) use($validator) { return $validator->validateBefore($attribute, $value, $parameter); }); $this->factory->replacer('jalali', function ($message, $attribute, $rule, $parameter) use($validator) { return $validator->replaceJalali($message, $attribute, $rule, $parameter); }); $this->factory->replacer('jalali_after', function ($message, $attribute, $rule, $parameter) use($validator) { return $validator->replaceAfterOrBefore($message, $attribute, $rule, $parameter); }); $this->factory->replacer('jalali_before', function ($message, $attribute, $rule, $parameter) use($validator) { return $validator->replaceAfterOrBefore($message, $attribute, $rule, $parameter); }); }