assertSameだと順不同で比較してくれない。
そういう時はassertEqualsCanonicalizingを使えば解決。
phpUnit7.5以降のversionで使用することができます。
使用例
//成功例。配列を順不同で比較してくれる。
$this->assertEqualsCanonicalizing([1,2,3,4],[4,1,3,2]);
//失敗例。他の関数と同じく第3引数でコメントしてくれる
$this->assertEqualsCanonicalizing([1,2,3,4],[4,1,3,3],"失敗しました");
参考:https://www.geeksforgeeks.org/phpunit-assertequalscanonicalizing-function/