-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add code activities for ch2 and ch3 (BDD features and scenarios)
- Loading branch information
1 parent
4e4beaa
commit 776a94b
Showing
2 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace Challenges\BddFeatures; | ||
|
||
use KnpU\ActivityRunner\Activity\MultipleChoice\AnswerBuilder; | ||
use KnpU\ActivityRunner\Activity\MultipleChoiceChallengeInterface; | ||
|
||
class BestBusinessValueMC implements MultipleChoiceChallengeInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getQuestion() | ||
{ | ||
return <<<EOF | ||
For the messaging feature, you and the intern (Bob) are in | ||
a heated debate over how to phrase the business value. | ||
Which if the following is the *best* business value for the | ||
message feature: | ||
EOF; | ||
} | ||
|
||
/** | ||
* @param AnswerBuilder $builder | ||
*/ | ||
public function configureAnswers(AnswerBuilder $builder) | ||
{ | ||
$builder | ||
->addAnswer('In order to type messages and click to send them to scientists.') | ||
->addAnswer('In order to communicate with other scientists.') | ||
->addAnswer('In order to exchange information and resources with other scientists.', true) | ||
->addAnswer('In order to send cat videos.') | ||
; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getExplanation() | ||
{ | ||
return <<<EOF | ||
Business value is subjective. But to help, forget about the technology | ||
and think about the problem that your user role (scientist) wants to | ||
solve. Both "communicate" and "exchange information and resources" | ||
are pretty good business values, but I like the second, because it | ||
contains a few more details about what the scientists actually | ||
want to do. | ||
EOF; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace Challenges\Interfaces; | ||
|
||
use KnpU\ActivityRunner\Activity\CodingChallenge\CodingContext; | ||
use KnpU\ActivityRunner\Activity\CodingChallenge\CorrectAnswer; | ||
use KnpU\ActivityRunner\Activity\CodingChallengeInterface; | ||
use KnpU\ActivityRunner\Activity\CodingChallenge\CodingExecutionResult; | ||
use KnpU\ActivityRunner\Activity\CodingChallenge\FileBuilder; | ||
use KnpU\ActivityRunner\Activity\Exception\GradingException; | ||
|
||
class RegistrationFeatureCoding implements CodingChallengeInterface | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getQuestion() | ||
{ | ||
return <<<EOF | ||
You've assembled a crack team for a brand new project: | ||
a site where paleontologists and other dinosaur scientists | ||
can send each other important scientific messages, along | ||
with the usual cat photos. | ||
Each scientist will need to register to gain access, and | ||
you - knowing that using BDD will create a better product - | ||
are writing a registration feature. Fill in the 4 feature | ||
lines in `registration.feature`. | ||
EOF; | ||
} | ||
|
||
public function getFileBuilder() | ||
{ | ||
$fileBuilder = new FileBuilder(); | ||
$fileBuilder | ||
->addFileContents('registration.feature', <<<EOF | ||
EOF | ||
) | ||
->setEntryPointFilename('registration.feature') | ||
; | ||
|
||
return $fileBuilder; | ||
} | ||
|
||
public function getExecutionMode() | ||
{ | ||
return self::EXECUTION_MODE_PHP_NORMAL; | ||
} | ||
|
||
public function setupContext(CodingContext $context) | ||
{ | ||
} | ||
|
||
public function grade(CodingExecutionResult $result) | ||
{ | ||
throw new GradingException('Oops...'); | ||
} | ||
|
||
public function configureCorrectAnswer(CorrectAnswer $correctAnswer) | ||
{ | ||
$correctAnswer | ||
->setFileContents('registration.feature', <<<EOF | ||
Feature: Registration | ||
In order to send and receive messages from scientists I know | ||
As a scientist | ||
I can register for a new account | ||
EOF | ||
) | ||
; | ||
} | ||
} |