whatwedo/validator-test
Composer 安装命令:
composer require whatwedo/validator-test
包简介
A fluid Validation tester
README 文档
README
Fluid Validator Tester, inspired by zenstruck/browser.
Usage
class AppUserValidatorTest extends KernelTestCase { use ValidationTestTrait; public function testAppUserRegisterGroup(): void { $appUser = new AppUser(); $this->getValidator() ->setGroups(['register']) ->validate($appUser) ->assertCount(4) ->assertNotNullTrue('firstname') ->validate($appUser->setFirstname('mauri')) ->assertNotNullFalse('firstname') ->assertCountViolation(4, NotNull::IS_NULL_ERROR); ->assertHasViolation(NotNull::IS_NULL_ERROR) ->assertHasNoViolation(NotBlank::IS_BLANK_ERROR) ->validate($appUser->setEmail('mauri') ->assertViolationTrue(Email::INVALID_FORMAT_ERROR, 'email') ->validate($appUser->setEmail('mauri@whatwedo.ch')) ->assertViolationFalse(Email::INVALID_FORMAT_ERROR, 'email') ; }
use
$this->getValidator() ->setGroups(['register']) ->validate($appUser) ->use(function (ConstraintViolationListInterface $constraintViolationList) { /*..*/ }) ;
统计信息
- 总下载量: 11.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-08