From 33ff68b2e04c97c6f9f24e7950aada0e3cbeec6f Mon Sep 17 00:00:00 2001 From: William DURAND Date: Thu, 19 Apr 2012 17:05:59 +0200 Subject: [PATCH] Fixed tests --- Extractor/ApiDocExtractor.php | 7 +++---- Tests/Formatter/MarkdownFormatterTest.php | 5 +++++ Tests/Formatter/SimpleFormatterTest.php | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Extractor/ApiDocExtractor.php b/Extractor/ApiDocExtractor.php index f2d60a0..ad8c0d7 100644 --- a/Extractor/ApiDocExtractor.php +++ b/Extractor/ApiDocExtractor.php @@ -180,7 +180,7 @@ class ApiDocExtractor protected function getData(ApiDoc $annotation, Route $route, \ReflectionMethod $method) { if (null === $annotation->getDescription()) { - $comments = explode('\n', $this->getDocComment($method)); + $comments = explode("\n", $this->getDocComment($method)); // just set the first line $annotation->setDescription($comments[0]); } @@ -194,11 +194,10 @@ class ApiDocExtractor // let's clean the doc block $comment = str_replace('/**', '', $comment); - $comment = str_replace('*/', '', $comment); $comment = str_replace('*', '', $comment); + $comment = str_replace('*/', '', $comment); $comment = str_replace("\r", '', trim($comment)); - $comment = preg_replace("#\n[ \t]+#i", "\n", trim($comment)); - $comment = str_replace("\n", "\\n", trim($comment)); + $comment = preg_replace("#^\n[ \t]+[*]?#i", "\n", trim($comment)); $comment = preg_replace("#[\t ]+#i", ' ', trim($comment)); $comment = str_replace("\"", "\\\"", $comment); diff --git a/Tests/Formatter/MarkdownFormatterTest.php b/Tests/Formatter/MarkdownFormatterTest.php index b2afdb0..798289f 100644 --- a/Tests/Formatter/MarkdownFormatterTest.php +++ b/Tests/Formatter/MarkdownFormatterTest.php @@ -105,6 +105,11 @@ _Action without HTTP verb_ ### `ANY` /any ### _Action without HTTP verb_ + + +### `ANY` /my-commented ### + +_This method is useful to test if the getDocComment works._ MARKDOWN; $this->assertEquals($expected, $result); diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php index fc131e5..95a3ad0 100644 --- a/Tests/Formatter/SimpleFormatterTest.php +++ b/Tests/Formatter/SimpleFormatterTest.php @@ -145,6 +145,15 @@ class SimpleFormatterTest extends WebTestCase ), 'description' => 'Action without HTTP verb', ), + 2 => + array( + 'method' => 'ANY', + 'uri' => '/my-commented', + 'requirements' => + array( + ), + 'description' => 'This method is useful to test if the getDocComment works.', + ), ), );