Open
Description
While looking into this forum thread, I found that students cannot output anything to debug their code. Also the test feedback somehow is incomplete:
Code Run
): void {
$class = new LuckyNumbers();
$actual = $class->validate($input);
$this->assertSame('', $actual);
Test Failure
LuckyNumbersTest::testErrorMessageForValidInput with data set #5
Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
-''
+'Must be a whole number larger than 0'
LuckyNumbersTest.php:138
This test file uses @dataProvider
to ease coding of tests, but that must be designed to deliver acceptable test feedback (students must see test input, not "data set #5"). It is best to avoid data providers.
Anyways, there should be test output delivered when using echo
or var_dump()
. And that's missing.
Code submitted:
<?php
class LuckyNumbers
{
public function sumUp(array $digitsOfNumber1, array $digitsOfNumber2): int
{
return \implode($digitsOfNumber1) + \implode($digitsOfNumber2);
}
public function isPalindrome(int $number): bool
{
return (string)$number == \strrev($number);
}
public function validate(string $input): string
{
echo $input;
if ($input == ""){
return "Required field";
}
else if(!is_numeric($input) || intval($input) <= 0 || (intval($input)) != $input){
return "Must be a whole number larger than 0";
}
else return "";
}
}
Metadata
Metadata
Assignees
Labels
No labels