如何确保PHPUnit中的数组相等?

I'm testing a website's dropdown menu to sort by Names.

$nameSort = array();
    $numOfNames = $this->getXpathCount("//td[@class='entry']");
    for($count = 1; $count <= $numOfNames; $count ++) {
        $get = $this->getText("xpath=(//td/a[contains(@href, '')])[$count]");
        array_push($nameSort, $get);
    }
    $test = sort($entrySort);
    $this->assertEquals($entrySort, $test);

But it says "There was 1 failure:

NameTest::testNameTab true does not match expected type "array".

Your problem is that sort returns a boolean and sorts the array in place.

As an example:

$arr = array(1,5,3); 
var_dump(sort($arr)); 
var_dump($arr);

That will result in this:

bool(true)
array(3) {
  [0]=>
  int(1)
  [1]=>
  int(3)
  [2]=>
  int(5)
}

You probably want this (or something like it):

sort($nameSort);
$this->assertEquals($entrySort, $nameSort);