ValidationRuleTest.php 452 B

12345678910111213141516171819
  1. <?php
  2. namespace Illuminate\Tests\Validation;
  3. use Illuminate\Validation\Rule;
  4. use PHPUnit\Framework\TestCase;
  5. class ValidationRuleTest extends TestCase
  6. {
  7. public function testMacroable()
  8. {
  9. // phone macro : validate a phone number
  10. Rule::macro('phone', function () {
  11. return 'regex:/^([0-9\s\-\+\(\)]*)$/';
  12. });
  13. $c = Rule::phone();
  14. $this->assertSame('regex:/^([0-9\s\-\+\(\)]*)$/', $c);
  15. }
  16. }