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
sortreturns a boolean and sorts the array in place.As an example:
That will result in this:
You probably want this (or something like it):