/**
  * Now that we have written the functionality to parse
  * links, our tests finally pass. Now I'm not going to
  * write a complete markdown parser, there are plenty
  * of good ones already! Let's implement one more parsing
  * method and then tie them together with some glue.
  *
  * When you're ready, switch to part fourteen.
  */
 public function testLinksCanBeParsed()
 {
     $m = new MarkdownParser();
     $e = 'foo[bar](baz)boo';
     $r = $m->parseLinks($e);
     $this->assertEquals('foo<a href="baz">bar</a>boo', $r);
 }
 /**
  * With the functionality complete, now our test passes
  * and is in the GREEN state. All that's left to do is
  * to die these methods together so that they perform
  * complete(ish) markdown parsing.
  *
  * Switch to part 16.
  */
 public function testImagesCanBeParsed()
 {
     $m = new MarkdownParser();
     $e = 'foo ![bar](baz) boo';
     $r = $m->parseImages($e);
     $this->assertEquals('foo <img src="baz" alt="bar" /> boo', $r);
 }
 /**
  * We should parse each individual markdown syntax
  * individually. So let's start with the bold tag. Text
  * wrapped with double (**) stars should be converted to
  * bold HTML text.
  *
  * First we write a test that fails.
  *
  * Switch to part ten when you're ready to implement
  * the functionality to make this test pass.
  */
 public function testBoldTextCanBeParsed()
 {
     $m = new MarkdownParser();
     $e = 'foo**bar**baz';
     $r = $m->parseBold($e);
     $this->assertEquals('foo<strong>bar</strong>baz', $r);
 }
 /**
  * By parsing images before links we have fixed our
  * little bug, and the test now passes.
  *
  * You know what, though? I'm not all that pleased
  * with our parse method. There's a fair bit of
  * repetition in there.
  *
  * Since our tests are GREEN, maybe now is the time
  * to enter the REFACTOR stage and try to improve our
  * code.
  *
  * Switch to part 19.
  */
 public function testCompleteMarkdownCanBeParsed()
 {
     $m = new MarkdownParser();
     $input = 'The **quick** brown [fox](jumped) over the ![lazy](dog).';
     $expected = 'The <strong>quick</strong> brown <a href="jumped">fox</a>' . ' over the <img src="dog" alt="lazy" />.';
     $r = $m->parse($input);
     $this->assertEquals($expected, $r);
 }