如何防止phpunit改变dataprovider中的数组结构?

How to prevent phpunit from changing the array structure in dataprovider?

这是我在数据提供者中的内容

'username' => [
    'requried'  => true,
    'min'       => 3,
    'max'       => 16,
]

我希望它保持相同的形式,但 phpunit 将其转换为

[
    "requried" => true,
    "min" => 3,
    "max"=> 16,
]

现在如何预防呢?我需要执行断言,但是因为phpunit是这样转换的,所以实际上是行不通的。

您的数据似乎被解释为数据集的名称,因此忽略了第一个键。检查 doc section

中的示例 2.6

试试类似的东西:

'first scenario' => [ 
   'username' => [
     'requried'  => true,
     'min'       => 3,
     'max'       => 16,
   ]
]

希望对您有所帮助

PS:可能是拼写错误 requried 而不是必需的