函数测试验证器:与其他属性进行比较
基于示例 sillthan.htthan.html为我自己的验证器@ASSERT \量编写功能调查。 $金额应根据$货币进行验证。
我的问题是,如何在函数测试中设置$货币的值?我已经查看了包装符号/验证器的测试,但找不到线索。我已经为验证器编写了函数测试。但是我没有任何要求。
有人可以给我提示还是向我展示一个例子。
例子:
class Entity
{
/**
* @var \string
* @Assert\Currency()
*/
protected $currency;
/**
* @var \float
* @Assert\Amount(propertyPath="currency")
*/
protected $amount;
}
based on the example LessThan.html#propertypath I would like to write a FunctionalTest for my own validator @Assert\Amount. $amount is to be validated depending on $currency.
My question is, how can I set the value for $currency in the FunctionalTest for the Amount Validator? I have looked at the tests of the package symfony/validator but can't find a clue. I have already written FunctionalTests for validators. But I am not getting anywhere with this requirement.
Could someone give me a hint or show me an example.
Example:
class Entity
{
/**
* @var \string
* @Assert\Currency()
*/
protected $currency;
/**
* @var \float
* @Assert\Amount(propertyPath="currency")
*/
protected $amount;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决方案。我验证了完整的实体,并查看了验证器中的对象,并找到了完整的实体。
当我考虑如何测试时,我进行了一些研究,并发现了其他相同的测试。我不知道这是否是最好的解决方案,但是我现在可以编写测试。
CondectValidatTestCase
约束
验证器
I have found a solution. I validated the complete entity and looked at the object in the validator and found the complete entity.
When I thought about how to test it, I did some research and found other tests that did the same. I don't know if this is the best solution, but I can now write my tests.
ConstraintValidatorTestCase
Constraint
Validator