{"action":"created","comment":{"url":"https://api.github.com/repos/phpspec/phpspec/pulls/comments/23133613","id":23133613,"diff_hunk":"@@ -0,0 +1,161 @@\n+<?php\n+\n+/*\n+ * This file is part of PhpSpec, A php toolset to drive emergent\n+ * design by specification.\n+ *\n+ * (c) Marcello Duarte <marcello.duarte@gmail.com>\n+ * (c) Konstantin Kudryashov <ever.zet@gmail.com>\n+ *\n+ * For the full copyright and license information, please view the LICENSE\n+ * file that was distributed with this source code.\n+ */\n+\n+namespace PhpSpec\\Formatter;\n+\n+use PhpSpec\\Event\\SuiteEvent;\n+use PhpSpec\\Event\\SpecificationEvent;\n+use PhpSpec\\Event\\ExampleEvent;\n+use Symfony\\Component\\Yaml\\Yaml;\n+\n+class TapFormatter extends ConsoleFormatter\n+{\n+\n+    const VERSION = 'TAP version 13';\n+\n+    const OK = 'ok %d';\n+\n+    const NOT_OK = 'not ok %d';\n+\n+    const DESC = ' - %s: %s';\n+\n+    const SKIP = ' # SKIP %s';\n+\n+    const TODO = ' # TODO %s';\n+\n+    const PLAN = '1..%d';\n+\n+    const MESSAGE = \"---\\nmessage: %s\\n...\";\n+\n+    const SEVERITY = \"\\n---\\nseverity: %s\\n...\";\n+\n+    /**\n+     * @var int\n+     */\n+    private $examplesCount = 0;\n+\n+    /**\n+     * @var string\n+     */\n+    private $currentSpecificationTitle;\n+\n+    /**\n+     * @param SuiteEvent $event\n+     */\n+    public function beforeSuite(SuiteEvent $event)\n+    {\n+        $this->getIO()->writeln(self::VERSION);\n+    }\n+\n+    /**\n+     * @param SpecificationEvent $event\n+     */\n+    public function beforeSpecification(SpecificationEvent $event)\n+    {\n+        $this->currentSpecificationTitle = $event->getSpecification()->getTitle();\n+    }\n+\n+    /**\n+     * @param ExampleEvent $event\n+     */\n+    public function afterExample(ExampleEvent $event)\n+    {\n+        $this->examplesCount++;\n+        $desc = sprintf(\n+            self::DESC,\n+            $this->currentSpecificationTitle,\n+            preg_replace('/^its? /', '', $event->getExample()->getTitle())\n+        );\n+\n+        switch ($event->getResult()) {\n+            case ExampleEvent::PASSED:\n+                $result = sprintf(self::OK, $this->examplesCount) . $desc;\n+                break;\n+            case ExampleEvent::PENDING:\n+                $message = $this->getResultData($event, $event->getResult());\n+                $result = sprintf(self::NOT_OK, $this->examplesCount) . $desc . $message;\n+                break;\n+            case ExampleEvent::SKIPPED:\n+                $message = sprintf(self::SKIP, $this->getResultData($event));\n+                $result = sprintf(self::OK, $this->examplesCount) . $desc . $message;\n+                break;\n+            case ExampleEvent::BROKEN:\n+            case ExampleEvent::FAILED:\n+                $message = $this->getResultData($event, $event->getResult());\n+                $result = sprintf(self::NOT_OK, $this->examplesCount) . $desc . \"\\n\" . $message;\n+                break;\n+        }\n+\n+        $this->getIO()->writeln($result);\n+    }\n+\n+    /**\n+     * @param SuiteEvent $event\n+     */\n+    public function afterSuite(SuiteEvent $event)\n+    {\n+        $this->getIO()->writeln(sprintf(\n+            self::PLAN,\n+            $this->getStatisticsCollector()->getEventsCount()\n+        ));\n+    }\n+\n+    /**\n+     * Format message as two-space indented YAML when needed outside of a\n+     * SKIP or TODO directive.\n+     *\n+     * @param ExampleEvent $event\n+     * @param int $result\n+     * @return string\n+     */\n+    private function getResultData(ExampleEvent $event, $result = null)\n+    {\n+        if (null === $result) {\n+            return $this->stripNewlines($event->getException()->getMessage());\n+        }\n+        $message = $event->getException()->getMessage();\n+        switch ($result) {\n+            case ExampleEvent::PENDING:\n+                $message = sprintf(self::TODO, $this->stripNewlines($message))\n+                    . $this->indent(sprintf(self::SEVERITY, Yaml::dump('todo')));","path":"src/PhpSpec/Formatter/TapFormatter.php","position":130,"original_position":130,"commit_id":"3cb5a349358be5b690d5881bbda12b8a05fa00b9","original_commit_id":"3cb5a349358be5b690d5881bbda12b8a05fa00b9","user":{"login":"padraic","id":19780,"avatar_url":"https://avatars.githubusercontent.com/u/19780?v=3","gravatar_id":"","url":"https://api.github.com/users/padraic","html_url":"https://github.com/padraic","followers_url":"https://api.github.com/users/padraic/followers","following_url":"https://api.github.com/users/padraic/following{/other_user}","gists_url":"https://api.github.com/users/padraic/gists{/gist_id}","starred_url":"https://api.github.com/users/padraic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/padraic/subscriptions","organizations_url":"https://api.github.com/users/padraic/orgs","repos_url":"https://api.github.com/users/padraic/repos","events_url":"https://api.github.com/users/padraic/events{/privacy}","received_events_url":"https://api.github.com/users/padraic/received_events","type":"User","site_admin":false},"body":"It a correct usage. The Yaml class must have a bad phpdoc ref.","created_at":"2015-01-18T14:20:49Z","updated_at":"2015-01-18T14:20:49Z","html_url":"https://github.com/phpspec/phpspec/pull/611#discussion_r23133613","pull_request_url":"https://api.github.com/repos/phpspec/phpspec/pulls/611","_links":{"self":{"href":"https://api.github.com/repos/phpspec/phpspec/pulls/comments/23133613"},"html":{"href":"https://github.com/phpspec/phpspec/pull/611#discussion_r23133613"},"pull_request":{"href":"https://api.github.com/repos/phpspec/phpspec/pulls/611"}}},"pull_request":{"url":"https://api.github.com/repos/phpspec/phpspec/pulls/611","id":27539251,"html_url":"https://github.com/phpspec/phpspec/pull/611","diff_url":"https://github.com/phpspec/phpspec/pull/611.diff","patch_url":"https://github.com/phpspec/phpspec/pull/611.patch","issue_url":"https://api.github.com/repos/phpspec/phpspec/issues/611","number":611,"state":"open","locked":false,"title":"Implement a Test Anything Protocol (TAP) formatter","user":{"login":"padraic","id":19780,"avatar_url":"https://avatars.githubusercontent.com/u/19780?v=3","gravatar_id":"","url":"https://api.github.com/users/padraic","html_url":"https://github.com/padraic","followers_url":"https://api.github.com/users/padraic/followers","following_url":"https://api.github.com/users/padraic/following{/other_user}","gists_url":"https://api.github.com/users/padraic/gists{/gist_id}","starred_url":"https://api.github.com/users/padraic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/padraic/subscriptions","organizations_url":"https://api.github.com/users/padraic/orgs","repos_url":"https://api.github.com/users/padraic/repos","events_url":"https://api.github.com/users/padraic/events{/privacy}","received_events_url":"https://api.github.com/users/padraic/received_events","type":"User","site_admin":false},"body":"Who doesn't like nice machine friendly output that isn't XML? ;)\r\n\r\nThis is a basic implementation of TAP 13: https://testanything.org/tap-version-13-specification.html Intention is to ease integration with Humbug which is a TAP consumer and save me from the horror that is JUnit.","created_at":"2015-01-16T21:49:46Z","updated_at":"2015-01-18T14:20:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"28ce22f57b031765529e7f57880d83c2d80ba772","assignee":null,"milestone":{"url":"https://api.github.com/repos/phpspec/phpspec/milestones/6","labels_url":"https://api.github.com/repos/phpspec/phpspec/milestones/6/labels","id":859834,"number":6,"title":"2.2","description":null,"creator":{"login":"ciaranmcnulty","id":237866,"avatar_url":"https://avatars.githubusercontent.com/u/237866?v=3","gravatar_id":"","url":"https://api.github.com/users/ciaranmcnulty","html_url":"https://github.com/ciaranmcnulty","followers_url":"https://api.github.com/users/ciaranmcnulty/followers","following_url":"https://api.github.com/users/ciaranmcnulty/following{/other_user}","gists_url":"https://api.github.com/users/ciaranmcnulty/gists{/gist_id}","starred_url":"https://api.github.com/users/ciaranmcnulty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ciaranmcnulty/subscriptions","organizations_url":"https://api.github.com/users/ciaranmcnulty/orgs","repos_url":"https://api.github.com/users/ciaranmcnulty/repos","events_url":"https://api.github.com/users/ciaranmcnulty/events{/privacy}","received_events_url":"https://api.github.com/users/ciaranmcnulty/received_events","type":"User","site_admin":false},"open_issues":4,"closed_issues":5,"state":"open","created_at":"2014-11-10T09:26:49Z","updated_at":"2015-01-18T11:22:25Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/phpspec/phpspec/pulls/611/commits","review_comments_url":"https://api.github.com/repos/phpspec/phpspec/pulls/611/comments","review_comment_url":"https://api.github.com/repos/phpspec/phpspec/pulls/comments/{number}","comments_url":"https://api.github.com/repos/phpspec/phpspec/issues/611/comments","statuses_url":"https://api.github.com/repos/phpspec/phpspec/statuses/3cb5a349358be5b690d5881bbda12b8a05fa00b9","head":{"label":"padraic:tap","ref":"tap","sha":"3cb5a349358be5b690d5881bbda12b8a05fa00b9","user":{"login":"padraic","id":19780,"avatar_url":"https://avatars.githubusercontent.com/u/19780?v=3","gravatar_id":"","url":"https://api.github.com/users/padraic","html_url":"https://github.com/padraic","followers_url":"https://api.github.com/users/padraic/followers","following_url":"https://api.github.com/users/padraic/following{/other_user}","gists_url":"https://api.github.com/users/padraic/gists{/gist_id}","starred_url":"https://api.github.com/users/padraic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/padraic/subscriptions","organizations_url":"https://api.github.com/users/padraic/orgs","repos_url":"https://api.github.com/users/padraic/repos","events_url":"https://api.github.com/users/padraic/events{/privacy}","received_events_url":"https://api.github.com/users/padraic/received_events","type":"User","site_admin":false},"repo":{"id":29363174,"name":"phpspec","full_name":"padraic/phpspec","owner":{"login":"padraic","id":19780,"avatar_url":"https://avatars.githubusercontent.com/u/19780?v=3","gravatar_id":"","url":"https://api.github.com/users/padraic","html_url":"https://github.com/padraic","followers_url":"https://api.github.com/users/padraic/followers","following_url":"https://api.github.com/users/padraic/following{/other_user}","gists_url":"https://api.github.com/users/padraic/gists{/gist_id}","starred_url":"https://api.github.com/users/padraic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/padraic/subscriptions","organizations_url":"https://api.github.com/users/padraic/orgs","repos_url":"https://api.github.com/users/padraic/repos","events_url":"https://api.github.com/users/padraic/events{/privacy}","received_events_url":"https://api.github.com/users/padraic/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/padraic/phpspec","description":"SpecBDD Framework for PHP","fork":true,"url":"https://api.github.com/repos/padraic/phpspec","forks_url":"https://api.github.com/repos/padraic/phpspec/forks","keys_url":"https://api.github.com/repos/padraic/phpspec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/padraic/phpspec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/padraic/phpspec/teams","hooks_url":"https://api.github.com/repos/padraic/phpspec/hooks","issue_events_url":"https://api.github.com/repos/padraic/phpspec/issues/events{/number}","events_url":"https://api.github.com/repos/padraic/phpspec/events","assignees_url":"https://api.github.com/repos/padraic/phpspec/assignees{/user}","branches_url":"https://api.github.com/repos/padraic/phpspec/branches{/branch}","tags_url":"https://api.github.com/repos/padraic/phpspec/tags","blobs_url":"https://api.github.com/repos/padraic/phpspec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/padraic/phpspec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/padraic/phpspec/git/refs{/sha}","trees_url":"https://api.github.com/repos/padraic/phpspec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/padraic/phpspec/statuses/{sha}","languages_url":"https://api.github.com/repos/padraic/phpspec/languages","stargazers_url":"https://api.github.com/repos/padraic/phpspec/stargazers","contributors_url":"https://api.github.com/repos/padraic/phpspec/contributors","subscribers_url":"https://api.github.com/repos/padraic/phpspec/subscribers","subscription_url":"https://api.github.com/repos/padraic/phpspec/subscription","commits_url":"https://api.github.com/repos/padraic/phpspec/commits{/sha}","git_commits_url":"https://api.github.com/repos/padraic/phpspec/git/commits{/sha}","comments_url":"https://api.github.com/repos/padraic/phpspec/comments{/number}","issue_comment_url":"https://api.github.com/repos/padraic/phpspec/issues/comments/{number}","contents_url":"https://api.github.com/repos/padraic/phpspec/contents/{+path}","compare_url":"https://api.github.com/repos/padraic/phpspec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/padraic/phpspec/merges","archive_url":"https://api.github.com/repos/padraic/phpspec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/padraic/phpspec/downloads","issues_url":"https://api.github.com/repos/padraic/phpspec/issues{/number}","pulls_url":"https://api.github.com/repos/padraic/phpspec/pulls{/number}","milestones_url":"https://api.github.com/repos/padraic/phpspec/milestones{/number}","notifications_url":"https://api.github.com/repos/padraic/phpspec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/padraic/phpspec/labels{/name}","releases_url":"https://api.github.com/repos/padraic/phpspec/releases{/id}","created_at":"2015-01-16T19:03:52Z","updated_at":"2015-01-16T19:03:54Z","pushed_at":"2015-01-17T21:01:24Z","git_url":"git://github.com/padraic/phpspec.git","ssh_url":"git@github.com:padraic/phpspec.git","clone_url":"https://github.com/padraic/phpspec.git","svn_url":"https://github.com/padraic/phpspec","homepage":"http://www.phpspec.net","size":3069,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"phpspec:master","ref":"master","sha":"214e2b666c711373ea0c513ec403509f87c2e5c9","user":{"login":"phpspec","id":416702,"avatar_url":"https://avatars.githubusercontent.com/u/416702?v=3","gravatar_id":"","url":"https://api.github.com/users/phpspec","html_url":"https://github.com/phpspec","followers_url":"https://api.github.com/users/phpspec/followers","following_url":"https://api.github.com/users/phpspec/following{/other_user}","gists_url":"https://api.github.com/users/phpspec/gists{/gist_id}","starred_url":"https://api.github.com/users/phpspec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phpspec/subscriptions","organizations_url":"https://api.github.com/users/phpspec/orgs","repos_url":"https://api.github.com/users/phpspec/repos","events_url":"https://api.github.com/users/phpspec/events{/privacy}","received_events_url":"https://api.github.com/users/phpspec/received_events","type":"Organization","site_admin":false},"repo":{"id":1582219,"name":"phpspec","full_name":"phpspec/phpspec","owner":{"login":"phpspec","id":416702,"avatar_url":"https://avatars.githubusercontent.com/u/416702?v=3","gravatar_id":"","url":"https://api.github.com/users/phpspec","html_url":"https://github.com/phpspec","followers_url":"https://api.github.com/users/phpspec/followers","following_url":"https://api.github.com/users/phpspec/following{/other_user}","gists_url":"https://api.github.com/users/phpspec/gists{/gist_id}","starred_url":"https://api.github.com/users/phpspec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/phpspec/subscriptions","organizations_url":"https://api.github.com/users/phpspec/orgs","repos_url":"https://api.github.com/users/phpspec/repos","events_url":"https://api.github.com/users/phpspec/events{/privacy}","received_events_url":"https://api.github.com/users/phpspec/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/phpspec/phpspec","description":"SpecBDD Framework for PHP","fork":false,"url":"https://api.github.com/repos/phpspec/phpspec","forks_url":"https://api.github.com/repos/phpspec/phpspec/forks","keys_url":"https://api.github.com/repos/phpspec/phpspec/keys{/key_id}","collaborators_url":"https://api.github.com/repos/phpspec/phpspec/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/phpspec/phpspec/teams","hooks_url":"https://api.github.com/repos/phpspec/phpspec/hooks","issue_events_url":"https://api.github.com/repos/phpspec/phpspec/issues/events{/number}","events_url":"https://api.github.com/repos/phpspec/phpspec/events","assignees_url":"https://api.github.com/repos/phpspec/phpspec/assignees{/user}","branches_url":"https://api.github.com/repos/phpspec/phpspec/branches{/branch}","tags_url":"https://api.github.com/repos/phpspec/phpspec/tags","blobs_url":"https://api.github.com/repos/phpspec/phpspec/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/phpspec/phpspec/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/phpspec/phpspec/git/refs{/sha}","trees_url":"https://api.github.com/repos/phpspec/phpspec/git/trees{/sha}","statuses_url":"https://api.github.com/repos/phpspec/phpspec/statuses/{sha}","languages_url":"https://api.github.com/repos/phpspec/phpspec/languages","stargazers_url":"https://api.github.com/repos/phpspec/phpspec/stargazers","contributors_url":"https://api.github.com/repos/phpspec/phpspec/contributors","subscribers_url":"https://api.github.com/repos/phpspec/phpspec/subscribers","subscription_url":"https://api.github.com/repos/phpspec/phpspec/subscription","commits_url":"https://api.github.com/repos/phpspec/phpspec/commits{/sha}","git_commits_url":"https://api.github.com/repos/phpspec/phpspec/git/commits{/sha}","comments_url":"https://api.github.com/repos/phpspec/phpspec/comments{/number}","issue_comment_url":"https://api.github.com/repos/phpspec/phpspec/issues/comments/{number}","contents_url":"https://api.github.com/repos/phpspec/phpspec/contents/{+path}","compare_url":"https://api.github.com/repos/phpspec/phpspec/compare/{base}...{head}","merges_url":"https://api.github.com/repos/phpspec/phpspec/merges","archive_url":"https://api.github.com/repos/phpspec/phpspec/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/phpspec/phpspec/downloads","issues_url":"https://api.github.com/repos/phpspec/phpspec/issues{/number}","pulls_url":"https://api.github.com/repos/phpspec/phpspec/pulls{/number}","milestones_url":"https://api.github.com/repos/phpspec/phpspec/milestones{/number}","notifications_url":"https://api.github.com/repos/phpspec/phpspec/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/phpspec/phpspec/labels{/name}","releases_url":"https://api.github.com/repos/phpspec/phpspec/releases{/id}","created_at":"2011-04-07T12:48:08Z","updated_at":"2015-01-18T14:10:41Z","pushed_at":"2015-01-18T11:31:05Z","git_url":"git://github.com/phpspec/phpspec.git","ssh_url":"git@github.com:phpspec/phpspec.git","clone_url":"https://github.com/phpspec/phpspec.git","svn_url":"https://github.com/phpspec/phpspec","homepage":"http://www.phpspec.net","size":6229,"stargazers_count":675,"watchers_count":675,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":132,"mirror_url":null,"open_issues_count":51,"forks":132,"open_issues":51,"watchers":675,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/phpspec/phpspec/pulls/611"},"html":{"href":"https://github.com/phpspec/phpspec/pull/611"},"issue":{"href":"https://api.github.com/repos/phpspec/phpspec/issues/611"},"comments":{"href":"https://api.github.com/repos/phpspec/phpspec/issues/611/comments"},"review_comments":{"href":"https://api.github.com/repos/phpspec/phpspec/pulls/611/comments"},"review_comment":{"href":"https://api.github.com/repos/phpspec/phpspec/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/phpspec/phpspec/pulls/611/commits"},"statuses":{"href":"https://api.github.com/repos/phpspec/phpspec/statuses/3cb5a349358be5b690d5881bbda12b8a05fa00b9"}}}}