5
5
namespace PhpSchool \PhpWorkshop \Check ;
6
6
7
7
use InvalidArgumentException ;
8
+ use PhpSchool \PhpWorkshop \Exception \RuntimeException ;
8
9
use PhpSchool \PhpWorkshop \Exercise \ExerciseInterface ;
9
10
use PhpSchool \PhpWorkshop \Exercise \ExerciseType ;
11
+ use PhpSchool \PhpWorkshop \Exercise \ProvidesSolution ;
10
12
use PhpSchool \PhpWorkshop \ExerciseCheck \FileComparisonExerciseCheck ;
11
13
use PhpSchool \PhpWorkshop \ExerciseCheck \FunctionRequirementsExerciseCheck ;
12
14
use PhpSchool \PhpWorkshop \Input \Input ;
@@ -32,7 +34,7 @@ public function getName(): string
32
34
/**
33
35
* Simply check that the file exists.
34
36
*
35
- * @param ExerciseInterface $exercise The exercise to check against.
37
+ * @param ExerciseInterface&ProvidesSolution $exercise The exercise to check against.
36
38
* @param Input $input The command line arguments passed to the command.
37
39
* @return ResultInterface The result of the check.
38
40
*/
@@ -47,7 +49,7 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
47
49
$ referenceFile = $ exercise ->getSolution ()->getBaseDirectory () . '/ ' . ltrim ($ file , '/ ' );
48
50
49
51
if (!file_exists ($ referenceFile )) {
50
- throw new Exception ( ' Reference file does not exit ' );
52
+ throw new RuntimeException ( sprintf ( ' File: "%s" does not exist in solution folder ' , $ file ) );
51
53
}
52
54
53
55
if (!file_exists ($ studentFile )) {
@@ -57,8 +59,8 @@ public function check(ExerciseInterface $exercise, Input $input): ResultInterfac
57
59
);
58
60
}
59
61
60
- $ actual = file_get_contents ($ studentFile );
61
- $ expected = file_get_contents ($ referenceFile );
62
+ $ actual = ( string ) file_get_contents ($ studentFile );
63
+ $ expected = ( string ) file_get_contents ($ referenceFile );
62
64
63
65
if ($ expected !== $ actual ) {
64
66
return new FileComparisonFailure ($ this , $ file , $ expected , $ actual );
0 commit comments