Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Symfony-在单元测试中允许检查($attribute,$subject)_Php_Symfony_Phpunit - Fatal编程技术网

Php Symfony-在单元测试中允许检查($attribute,$subject)

Php Symfony-在单元测试中允许检查($attribute,$subject),php,symfony,phpunit,Php,Symfony,Phpunit,我试图在symfony中创建一个单元测试,以检查由用户“abc”(以createdUserName的形式存储在列中)创建的表中的特定条目是否可供尝试编辑相同条目的其他用户访问 在控制器中,使用isGranted($subject$attribute)返回所需的结果。我试图在一个单元测试文件中实现同样的功能,但不确定如何使用它 我尝试过实例化AuthorizationChecker并调用isgrated方法,但这引发了这个错误 'ArgumentCountError:参数太少,无法正常工作 Sym

我试图在symfony中创建一个单元测试,以检查由用户“abc”(以
createdUserName
的形式存储在列中)创建的表中的特定条目是否可供尝试编辑相同条目的其他用户访问

在控制器中,使用i
sGranted($subject$attribute)
返回所需的结果。我试图在一个单元测试文件中实现同样的功能,但不确定如何使用它

我尝试过实例化
AuthorizationChecker
并调用isgrated方法,但这引发了这个错误

'ArgumentCountError:参数太少,无法正常工作 Symfony\Component\Security\Core\Authorization\AuthorizationChecker::\uu构造()


那么,您向AuthorizationChecker构造函数传递了哪些参数?您是否检查了AuthorizationChecker的文档,以查看其构造函数上需要哪些参数?我没有传递任何参数,假设传递AuthorizationChecker实际需要的3个参数是一种代码过量。我必须从单元测试文件中传递“TokenStorageInterface$tokenStorage,AuthenticationManagerInterface$authenticationManager,AccessDecisionManagerInterface$accessDecisionManager”吗?我检查了供应商文件,找到了这3个参数。我还想知道,在单元测试中测试投票者功能是否正确$结果=$authorizationChecker->isgrated('edit',$entityobject);这就是我到目前为止一直在尝试的。那么,您将哪些参数传递给了
AuthorizationChecker
构造函数?您是否检查了AuthorizationChecker的文档以查看其构造函数上需要哪些参数?我没有传递任何参数,假设传递AuthorizationChecker实际需要的3个参数是代码过度使用。我必须从单元测试文件中传递“TokenStorageInterface$tokenStorage,AuthenticationManagerInterface$authenticationManager,AccessDecisionManagerInterface$accessDecisionManager”吗?我检查了供应商文件,找到了这3个参数。我还想知道,在单元测试中测试投票者功能是否正确$结果=$authorizationChecker->isgrated('edit',$entityobject);这就是我一直在尝试的