Unsure of the best way to unit test this:
<?php
class Test
{
public static function random(){
return rand(0,9);
}
public static function nonDuplicateRandom($dupes){
$rand = self::random();
while(in_array($rand, $dupes)){
$rand = self::random();
}
return $rand;
}
}
echo Test::nonDuplicateRandom(array(0,1,2,3,4,5));
Should I modify nonDuplicateRandom so it can be passed a $rand value to test against or is there a better way?
Aucun commentaire:
Enregistrer un commentaire