diff --git a/tests/Validation/ValidationMacroTest.php b/tests/Validation/ValidationMacroTest.php new file mode 100644 index 000000000000..09bcf04707a0 --- /dev/null +++ b/tests/Validation/ValidationMacroTest.php @@ -0,0 +1,40 @@ +assertSame('regex:/^([0-9\s\-\+\(\)]*)$/', $actualRule); + } + + public function testMacroArguments() + { + Rule::macro('maxLength', function (int $length) { + return "max:{$length}"; + }); + + $actualRule = Rule::maxLength(10); + $this->assertSame('max:10', $actualRule); + } + + public function testMacroDefaultArguments() + { + Rule::macro('maxLength', function ($length = 255) { + return "max:{$length}"; + }); + + $actualRule = Rule::maxLength(); // No argument provided, should use default value + $this->assertSame('max:255', $actualRule); + } +} diff --git a/tests/Validation/ValidationRuleTest.php b/tests/Validation/ValidationRuleTest.php deleted file mode 100644 index 924ab38650a3..000000000000 --- a/tests/Validation/ValidationRuleTest.php +++ /dev/null @@ -1,19 +0,0 @@ -assertSame('regex:/^([0-9\s\-\+\(\)]*)$/', $c); - } -} diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 23bf82651098..51133741082d 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -4486,7 +4486,7 @@ public function testValidateMimetypes() { $trans = $this->getIlluminateArrayTranslator(); - $uploadedFile = [__DIR__.'/ValidationRuleTest.php', '', null, null, true]; + $uploadedFile = [__DIR__.'/ValidationMacroTest.php', '', null, null, true]; $file = $this->getMockBuilder(UploadedFile::class)->onlyMethods(['guessExtension', 'getClientOriginalExtension'])->setConstructorArgs($uploadedFile)->getMock(); $file->expects($this->any())->method('guessExtension')->willReturn('rtf');