public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('new_toy.php', '$_POST');
     $result->assertVariableEquals('name', 'Fluffy Pig Stuffed Animal');
     $result->assertVariableEquals('description', 'Your dog will *love* to chew and destroy this adorable pig!');
     $result->assertInputContains('new_toy.php', 'var_dump');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'file_get_contents');
     $result->assertInputContains('index.php', 'json_decode');
     $result->assertElementContains('h3', 'Bacon Bone');
     $result->assertElementContains('h4', 'Bacon-colored');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertFunctionExists('get_great_pet_toys');
     $result->assertInputContains('lib/functions.php', 'get_great_pet_toys(');
     $result->assertInputContains('index.php', 'require');
     $result->assertElementContains('h3', 'Bacon Bone');
 }
 public function grade(CodingExecutionResult $result)
 {
     $expected = 'our pets are purrfectly pawesome!';
     $result->assertInputContains('index.php', 'strrev(');
     $result->assertInputContains('index.php', 'strtolower(');
     $result->assertOutputContains($expected);
 }
 public function grade(CodingExecutionResult $result)
 {
     $expected = 'Puppies';
     $result->assertOutputContains($expected);
     $result->assertElementContains('h2', $expected);
     $result->assertInputContains('index.php', 'echo');
     $result->assertInputContains('index.php', '$whatILove');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'if');
     $result->assertInputContains('index.php', 'array_key_exists');
     // make sure they're still printing
     $result->assertOutputContains('no color', 'The `Bacon Bone` doesn\'t have a color, so it *should* say "no color" for that toy.');
     $result->assertElementContains('h4', 'Yellow');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'file_put_contents');
     $result->assertInputContains('index.php', 'doglife.txt');
     $result->assertInputContains('index.php', 'Dogs rule!');
     $result->assertInputContains('index.php', 'file_get_contents');
     $result->assertElementContains('h2', 'Dogs rule!');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'if');
     $result->assertElementContains('h4', 'Surprise Color');
     $result->assertElementContains('h4', 'Yellow', 'The Tennis ball is printing as `Surprise Color!`, but it *should* be `Yellow`. There\'s a more subtle mistake in the first part of the `if` statement...');
     $result->assertElementContains('h4', 'no color');
 }
 public function grade(CodingExecutionResult $result)
 {
     $expected = 'Puppy';
     $result->assertOutputContains($expected);
     $result->assertElementContains('h2', $expected);
     $result->assertInputContains('homepage.twig', 'whatIWantForXmas');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'if');
     $result->assertElementContains('h4', 'Yellow');
     $result->assertElementContains('h4', 'Multiple Colors');
     $result->assertElementContains('h4', 'no color');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertFunctionExists('get_great_pet_toys');
     $result->assertInputContains('index.php', 'get_great_pet_toys(');
     $result->assertElementContains('h4', 'Yellow');
     $result->assertElementContains('h4', 'Multiple Colors');
     $result->assertElementContains('h3', 'Bacon Bone');
 }
 public function grade(CodingExecutionResult $result)
 {
     $expected = 'I luv kittens';
     $result->assertOutputContains($expected);
     $result->assertElementContains('h2', $expected);
     $result->assertVariableEquals('airpupTag', $expected);
     $result->assertInputContains('index.php', 'echo');
 }
 public function grade(CodingExecutionResult $result)
 {
     $expected = 'I luv puppies';
     $result->assertInputContains('index.php', 'rand(');
     $result->assertOutputContains($expected);
     $text = trim($result->getCrawler()->filter('h3 span')->text());
     if (!is_numeric($text)) {
         throw new GradingException(sprintf('Are you printing the random number inside the span tag? I see "%s"', $text));
     }
     if ($text > 200 || $text < 100) {
         throw new GradingException(sprintf('Make sure the rand() function only returns numbers between 100 and 200', $text));
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'foreach');
     $result->assertElementContains('h3', 'Kitty');
     $result->assertElementContains('h3', 'Tiger');
     $result->assertElementContains('h3', 'Jay');
     $buttonCount = substr_count($result->getOutput(), '<button>');
     if ($buttonCount == 0) {
         throw new GradingException('Don\'t forget to add a `<button>Schedule me</button>` inside the `foreach` for each walker!');
     }
     if ($buttonCount == 1) {
         throw new GradingException('I only see 1 `<button>` - make sure to include this *inside* the `foreach` loop so that 3 are printed');
     }
     if ($buttonCount != 3) {
         throw new GradingException('There should be 3 `<button>` element exactly');
     }
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('new_toy.php', '$_SERVER');
     $result->assertInputContains('new_toy.php', 'REQUEST_METHOD');
     $result->assertInputContains('new_toy.php', 'POST', 'Are you checking that the request method equals POST?');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('new_toy.php', '$_SERVER');
     $result->assertInputContains('new_toy.php', 'HTTP_USER_AGENT');
     $result->assertOutputContains('Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('new_toy.php', 'json_encode', 'Use `json_encode()` in `new_toy.php` to encode the toys array before saving it');
     $result->assertInputContains('new_toy.php', 'file_put_contents', 'Use `file_put_contents()` in `new_toy.php` to save the new JSON string');
     $result->assertInputContains('new_toy.php', 'var_dump', '`var_dump()` the file contents of `toys.json` after saving the new toy');
     $result->assertInputContains('new_toy.php', 'get_great_pet_toys', 'Call `get_great_pet_toys()` first to get the existing toys');
     $result->assertOutputContains('Bacon Bone', 'I don\'t see `Bacon Bone` in `toys.json` - double-check that you\'re keeping the original pets, not replacing them entirely.');
     $result->assertOutputContains('Fluffy Pig Stuffed Animal', 'I don\'t see the new "Fluffy Pig" toy in `toys.json`. Are you adding it to the toys array before calling `json_encode()` and saving the file?');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', "\$pets[2]['bio']");
     $result->assertElementContains('h1', 'Breakfast is my favorite!');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertVariableEquals('waggyPig[breed]', 'bichon');
     $result->assertInputContains('index.php', '$waggyPig[', 'Add the `breed` key *after* the `$waggyPig` variable is created using the `[\'breed\']` syntax');
     $result->assertElementContains('.breed', 'bichon');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'count');
     $result->assertElementContains('h4', 3, 'I don\'t see the number 3 inside the `<h4>` tag. Are you printing the `count()` there?');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('index.php', 'var_dump(');
     $result->assertOutputContains('Kitty', 'Tiger', 'Jay');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('functions.php', 'save_toys(', 'Put the `save_toys` function into `functions.php` for organization');
     $result->assertInputContains('new_toy.php', 'save_toys(', 'Be sure to call the `save_toys()` function from within `new_toy.php`');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('aboutUs.php', 'header(', 'Use the `header()` function to redirect');
     $result->assertInputContains('aboutUs.php', 'Location:', 'Set the `Location:` header to `/about.php`');
 }
 public function grade(CodingExecutionResult $result)
 {
     $result->assertInputContains('layout/header.php', '<html>');
     $result->assertInputContains('layout/footer.php', '</html>');
     $result->assertInputContains('index.php', '$airpupTagLine =', 'Keep the `$airpupTagLine = ...` code inside `index.php`: that\'s code that is used for just *this* page, and shouldn\'t be in the header');
     $result->assertInputContains('index.php', 'require', 'Don\'t forget to require the `header.php` and `footer.php` files in `index.php` so that it still has the nice layout');
     $result->assertOutputContains('<html>', 'Don\'t forget to require the `header.php` file in `aboutUs.php` so that it has the nice layout');
     $result->assertOutputContains('</html>', 'Don\'t forget to require the `footer.php` file in `aboutUs.php` so that it has the nice layout');
 }