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); }); }
public function test_validate_before_with_date_and_format() { $now = '1394-9-13'; $tomorrow = '1394-9-14'; $yesterday = '1394-9-12'; $this->assertFalse($this->validator->validateBefore('foo', $tomorrow, [$now, 'Y-m-d'])); $this->assertTrue($this->validator->validateBefore('foo', $yesterday, [$now, 'Y-m-d'])); $this->assertFalse($this->validator->validateBefore('foo', $now, [$now, 'Y-m-d'])); $this->assertFalse($this->validator->validateBefore('foo', 'bar', [$now, 'Y-m-d'])); }