Wykonuję zadanie na stronie codewars. Polecenie to znaleźć w zadanej tablicy najmniejszą wartość.
Wydaje mi się, że powinno być poprawnie, ale test je odrzuca. Proszę o pomoc
function smallestInteger ($arr) {
$smallest = $arr[0];
for ($i = 0 ; $i < count($arr); $i++)
{
if ($arr[i] < $smallest)
{
$smallest = $arr[i];
}
}
echo $smallest;
}
class smallest extends TestCase
{
public function test() {
$this->assertEquals(smallestInteger([3, 5, 10, 1, 4, 55]), 1);
$this->assertEquals(smallestInteger([0]), 0);
}
}
testPositive
Failed asserting that 1 matches expected null.
Completed in 0.44ms
** testNegative**
Failed asserting that -55 matches expected null.
Completed in 0.21ms