Skip to content

Commit

Permalink
Improve some grading error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
bocharsky-bw committed Oct 19, 2015
1 parent 18eec94 commit 99a8f8c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ public function grade(CodingExecutionResult $result)
{
$featureContextClass = new \ReflectionClass('FeatureContext');
if (!$featureContextClass->hasMethod('afterStepHook')) {
throw new GradingException('Method `afterStepHook()` doesn\'t found in the `FeatureContext` class. Did you create it?');
throw new GradingException('The `afterStepHook()` method wasn\'t found in the `FeatureContext` class.');
}
if (!$featureContextClass->getMethod('afterStepHook')->isPublic()) {
throw new GradingException('Method `afterStepHook()` should be public.');
throw new GradingException('The `afterStepHook()` method should be public.');
}
$afterStepHookMethod = $featureContextClass->getMethod('afterStepHook');
$docComment = $afterStepHookMethod->getDocComment();
Expand All @@ -145,10 +145,10 @@ public function grade(CodingExecutionResult $result)
}
$afterStepHookParameters = $afterStepHookMethod->getParameters();
if (1 !== $afterStepHookMethod->getNumberOfRequiredParameters()) {
throw new GradingException('Method `afterStepHook()` should get one required parameter.');
throw new GradingException('Make sure you give the `afterStepHook()` method exactly one argument.');
}
if (0 !== strcmp('event', $afterStepHookParameters[0]->getName())) {
throw new GradingException('First argument in the `afterStepHook()` method should be named `$event`.');
throw new GradingException('Though you can really call it anything, let\'s call the argument to `afterStepHook()` `$event` for clarity.');
}
}

Expand Down
4 changes: 2 additions & 2 deletions knpu/Challenges/BehatHooksBackground/afterStepHookCoding.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ public function grade(CodingExecutionResult $result)
{
$featureContextClass = new \ReflectionClass('FeatureContext');
if (!$featureContextClass->hasMethod('afterStepHook')) {
throw new GradingException('Method `afterStepHook()` doesn\'t found in the `FeatureContext` class. Did you create it?');
throw new GradingException('The `afterStepHook()` method wasn\'t found in the `FeatureContext` class.');
}
if (!$featureContextClass->getMethod('afterStepHook')->isPublic()) {
throw new GradingException('Method `afterStepHook()` should be public.');
throw new GradingException('The `afterStepHook()` method should be public.');
}
$docComment = $featureContextClass->getMethod('afterStepHook')->getDocComment();
if (false === strpos($docComment, '@AfterStep')) {
Expand Down

0 comments on commit 99a8f8c

Please sign in to comment.