{"action":"created","comment":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/38819941","id":38819941,"diff_hunk":"@@ -0,0 +1,260 @@\n+<?php\n+\n+/*\n+ * This file is part of the PHP CS utility.\n+ *\n+ * (c) Fabien Potencier <fabien@symfony.com>\n+ *\n+ * This source file is subject to the MIT license that is bundled\n+ * with this source code in the file LICENSE.\n+ */\n+\n+namespace Symfony\\CS\\Tests;\n+\n+use Symfony\\Component\\Filesystem\\Filesystem;\n+use Symfony\\CS\\ErrorsManager;\n+use Symfony\\CS\\FileCacheManager;\n+use Symfony\\CS\\Fixer;\n+use Symfony\\CS\\FixerInterface;\n+\n+/**\n+ * Integration test helper.\n+ *\n+ * @author SpacePossum\n+ */\n+abstract class AbstractIntegrationTest extends \\PHPUnit_Framework_TestCase\n+{\n+    /**\n+     * @dataProvider getTests\n+     */\n+    public function testIntegration($testFileName, $testTitle, $fixers, $input, $expected = null)\n+    {\n+        $this->doTestIntegration($testFileName, $testTitle, $fixers, $input, $expected);\n+    }\n+\n+    public function getTests()\n+    {\n+        $fixturesDir = realpath($this->getFixturesDir());\n+        $this->assertTrue(is_dir($fixturesDir), sprintf('Given fixture dir \"%s\" is not a directory.', $fixturesDir));\n+\n+        $tests = array();\n+\n+        foreach (new \\RecursiveIteratorIterator(new \\RecursiveDirectoryIterator($fixturesDir), \\RecursiveIteratorIterator::LEAVES_ONLY) as $file) {\n+            if (!preg_match('/\\.test$/', $file)) {\n+                continue;\n+            }\n+\n+            $test = file_get_contents($file->getRealpath());\n+            $fileName = $file->getFileName();\n+            if (preg_match('/--TEST--[\\r\\n](.*?)\\s--CONFIG--[\\r\\n](.*?)\\s--INPUT--[\\r\\n](.*?[\\r\\n]*)(?:[\\r\\n]--EXPECT--\\s(.*)|$)/s', $test, $match)) {\n+                $testTitle = $match[1];\n+                $config = $this->getFixersFromConfig($fileName, $match[2]);\n+                $input = $match[3];\n+                $expected = isset($match[4]) ? $match[4] : null;\n+                $tests[] = array($fileName, $testTitle, $config, $input, $expected);\n+            } else {\n+                throw new InvalidArgumentException(sprintf('Test \"%s\" is not valid.', $fileName));\n+            }\n+        }\n+\n+        $this->assertNotEmpty($tests, sprintf('No tests found in fixtures dir \"%s\".', $fixturesDir));\n+\n+        return $tests;\n+    }\n+\n+    /**\n+     * Returns the full path to directory which contains the tests.\n+     *\n+     * @return string\n+     */\n+    abstract protected function getFixturesDir();\n+\n+    /**\n+     * Returns the full path to directory where the tests will writes the temporary file.\n+     *\n+     * @return string\n+     */\n+    abstract protected function getTempDir();\n+\n+    /**\n+     * @param string           $testFileName\n+     * @param string           $testTitle\n+     * @param FixerInterface[] $fixers\n+     * @param string           $input\n+     * @param string|null      $expected\n+     */\n+    protected function doTestIntegration($testFileName, $testTitle, $fixers, $input, $expected = null)\n+    {\n+        $errorsManager = new ErrorsManager();\n+        $fixer = new Fixer();\n+        $fixer->setErrorsManager($errorsManager);\n+        $fs = new Filesystem();\n+\n+        $dir = $this->getTempDir();\n+        $tmpDir = new \\SplFileInfo($dir);\n+        if (!$tmpDir->isDir()) {\n+            $fs->mkdir($tmpDir);\n+        }\n+\n+        $this->assertTrue($tmpDir->isDir(), sprintf('Given temp dir \"%s\" is not a directory.', $dir));\n+        $this->assertTrue($tmpDir->isWritable(), sprintf('Given temp dir \"%s\" is not writable.', $dir));\n+\n+        $tmpFile = $tmpDir->getRealPath().'/tmp.php';\n+        $this->assertNotFalse(@file_put_contents($tmpFile, $input), sprintf('Failed to write to tmp. file \"%s\".', $tmpFile));\n+\n+        $changed = $fixer->fixFile(new \\SplFileInfo($tmpFile), $fixers, false, true, new FileCacheManager(false, null, $fixers));\n+\n+        if (null !== $expected) {\n+            // read back the changed file content\n+            $newContent = file_get_contents($tmpFile);","path":"Symfony/CS/Tests/AbstractIntegrationTest.php","position":109,"original_position":109,"commit_id":"619acdcc628718190f981146dd4dae24b4eb7a6b","original_commit_id":"619acdcc628718190f981146dd4dae24b4eb7a6b","user":{"login":"keradus","id":2716794,"avatar_url":"https://avatars.githubusercontent.com/u/2716794?v=3","gravatar_id":"","url":"https://api.github.com/users/keradus","html_url":"https://github.com/keradus","followers_url":"https://api.github.com/users/keradus/followers","following_url":"https://api.github.com/users/keradus/following{/other_user}","gists_url":"https://api.github.com/users/keradus/gists{/gist_id}","starred_url":"https://api.github.com/users/keradus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/keradus/subscriptions","organizations_url":"https://api.github.com/users/keradus/orgs","repos_url":"https://api.github.com/users/keradus/repos","events_url":"https://api.github.com/users/keradus/events{/privacy}","received_events_url":"https://api.github.com/users/keradus/received_events","type":"User","site_admin":false},"body":"This shouldn't be needed. One IO operation more","created_at":"2015-09-06T10:23:51Z","updated_at":"2015-09-06T10:23:51Z","html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1384#discussion_r38819941","pull_request_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384","_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments/38819941"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1384#discussion_r38819941"},"pull_request":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384"}}},"pull_request":{"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384","id":44289322,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1384","diff_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1384.diff","patch_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1384.patch","issue_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1384","number":1384,"state":"open","locked":false,"title":"[1.11] Add intergration tests.","user":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"body":"A 1.11 version of;\r\nhttps://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1375\r\nBiggest diff is the caused by the diff. ways the errormanager is connected to the fixer in the branches.","created_at":"2015-09-05T19:57:50Z","updated_at":"2015-09-06T10:23:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"044a1aef1115b076af8d19e5ea7d8aac342d47c7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384/commits","review_comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384/comments","review_comment_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1384/comments","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/619acdcc628718190f981146dd4dae24b4eb7a6b","head":{"label":"SpacePossum:1_11_feature_add_intergration_tests","ref":"1_11_feature_add_intergration_tests","sha":"619acdcc628718190f981146dd4dae24b4eb7a6b","user":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"repo":{"id":29018102,"name":"PHP-CS-Fixer","full_name":"SpacePossum/PHP-CS-Fixer","owner":{"login":"SpacePossum","id":10462973,"avatar_url":"https://avatars.githubusercontent.com/u/10462973?v=3","gravatar_id":"","url":"https://api.github.com/users/SpacePossum","html_url":"https://github.com/SpacePossum","followers_url":"https://api.github.com/users/SpacePossum/followers","following_url":"https://api.github.com/users/SpacePossum/following{/other_user}","gists_url":"https://api.github.com/users/SpacePossum/gists{/gist_id}","starred_url":"https://api.github.com/users/SpacePossum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SpacePossum/subscriptions","organizations_url":"https://api.github.com/users/SpacePossum/orgs","repos_url":"https://api.github.com/users/SpacePossum/repos","events_url":"https://api.github.com/users/SpacePossum/events{/privacy}","received_events_url":"https://api.github.com/users/SpacePossum/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/SpacePossum/PHP-CS-Fixer","description":"Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible)","fork":true,"url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/issues/comments{/number}","contents_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/SpacePossum/PHP-CS-Fixer/releases{/id}","created_at":"2015-01-09T13:46:11Z","updated_at":"2015-04-14T09:59:34Z","pushed_at":"2015-09-05T19:52:55Z","git_url":"git://github.com/SpacePossum/PHP-CS-Fixer.git","ssh_url":"git@github.com:SpacePossum/PHP-CS-Fixer.git","clone_url":"https://github.com/SpacePossum/PHP-CS-Fixer.git","svn_url":"https://github.com/SpacePossum/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":3664,"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":"FriendsOfPHP:1.11","ref":"1.11","sha":"850336ea602f7fac2d9131f31eec03670d6049e5","user":{"login":"FriendsOfPHP","id":5947812,"avatar_url":"https://avatars.githubusercontent.com/u/5947812?v=3","gravatar_id":"","url":"https://api.github.com/users/FriendsOfPHP","html_url":"https://github.com/FriendsOfPHP","followers_url":"https://api.github.com/users/FriendsOfPHP/followers","following_url":"https://api.github.com/users/FriendsOfPHP/following{/other_user}","gists_url":"https://api.github.com/users/FriendsOfPHP/gists{/gist_id}","starred_url":"https://api.github.com/users/FriendsOfPHP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FriendsOfPHP/subscriptions","organizations_url":"https://api.github.com/users/FriendsOfPHP/orgs","repos_url":"https://api.github.com/users/FriendsOfPHP/repos","events_url":"https://api.github.com/users/FriendsOfPHP/events{/privacy}","received_events_url":"https://api.github.com/users/FriendsOfPHP/received_events","type":"Organization","site_admin":false},"repo":{"id":4344257,"name":"PHP-CS-Fixer","full_name":"FriendsOfPHP/PHP-CS-Fixer","owner":{"login":"FriendsOfPHP","id":5947812,"avatar_url":"https://avatars.githubusercontent.com/u/5947812?v=3","gravatar_id":"","url":"https://api.github.com/users/FriendsOfPHP","html_url":"https://github.com/FriendsOfPHP","followers_url":"https://api.github.com/users/FriendsOfPHP/followers","following_url":"https://api.github.com/users/FriendsOfPHP/following{/other_user}","gists_url":"https://api.github.com/users/FriendsOfPHP/gists{/gist_id}","starred_url":"https://api.github.com/users/FriendsOfPHP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FriendsOfPHP/subscriptions","organizations_url":"https://api.github.com/users/FriendsOfPHP/orgs","repos_url":"https://api.github.com/users/FriendsOfPHP/repos","events_url":"https://api.github.com/users/FriendsOfPHP/events{/privacy}","received_events_url":"https://api.github.com/users/FriendsOfPHP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer","description":"Analyzes some PHP source code and tries to fix coding standards issues (PSR-1 and PSR-2 compatible)","fork":false,"url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer","forks_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/forks","keys_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/teams","hooks_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/hooks","issue_events_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/events{/number}","events_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/events","assignees_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/assignees{/user}","branches_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/branches{/branch}","tags_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/tags","blobs_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/refs{/sha}","trees_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/{sha}","languages_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/languages","stargazers_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/stargazers","contributors_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/contributors","subscribers_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/subscribers","subscription_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/subscription","commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/commits{/sha}","git_commits_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/git/commits{/sha}","comments_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/comments{/number}","issue_comment_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/comments{/number}","contents_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/contents/{+path}","compare_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/merges","archive_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/downloads","issues_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues{/number}","pulls_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls{/number}","milestones_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/milestones{/number}","notifications_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/labels{/name}","releases_url":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/releases{/id}","created_at":"2012-05-16T06:42:23Z","updated_at":"2015-09-05T16:16:12Z","pushed_at":"2015-09-05T19:57:51Z","git_url":"git://github.com/FriendsOfPHP/PHP-CS-Fixer.git","ssh_url":"git@github.com:FriendsOfPHP/PHP-CS-Fixer.git","clone_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer.git","svn_url":"https://github.com/FriendsOfPHP/PHP-CS-Fixer","homepage":"cs.sensiolabs.org","size":13188,"stargazers_count":2495,"watchers_count":2495,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":406,"mirror_url":null,"open_issues_count":89,"forks":406,"open_issues":89,"watchers":2495,"default_branch":"1.11"}},"_links":{"self":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384"},"html":{"href":"https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/1384"},"issue":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1384"},"comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/issues/1384/comments"},"review_comments":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384/comments"},"review_comment":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/pulls/1384/commits"},"statuses":{"href":"https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/statuses/619acdcc628718190f981146dd4dae24b4eb7a6b"}}}}