{"action":"created","comment":{"url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/comments/25562020","id":25562020,"diff_hunk":"@@ -0,0 +1,125 @@\n+<?php\n+\n+namespace MageTest\\Command\\BuiltIn;\n+\n+use Mage\\Command\\BuiltIn\\UnlockCommand;\n+use MageTest\\TestHelper\\BaseTest;\n+use malkusch\\phpmock\\MockBuilder;\n+\n+/**\n+ * Class UnlockCommandTest\n+ * @package MageTest\\Command\\BuiltIn\n+ * @coversDefaultClass Mage\\Command\\BuiltIn\\UnlockCommand\n+ * @uses malkusch\\phpmock\\MockBuilder\n+ * @uses malkusch\\phpmock\\Mock\n+ * @uses Mage\\Command\\AbstractCommand\n+ * @uses Mage\\Console\n+ * @uses Mage\\Console\\Colors\n+ */\n+class UnlockCommandTest extends BaseTest\n+{\n+    /**\n+     * @var UnlockCommand\n+     */\n+    private $unlockCommand;\n+\n+    public static $isUnlinkCalled;\n+    public static $fileExistsResult;\n+    public static $isFileExists;\n+\n+    /**\n+     * @before\n+     */\n+    public function before()\n+    {\n+        $this->unlockCommand = new UnlockCommand();\n+\n+        self::$isUnlinkCalled = false;\n+        self::$fileExistsResult = false;\n+        self::$isFileExists = false;\n+\n+        $mockBuilder = new MockBuilder();\n+        $fileExistsMock = $mockBuilder\n+            ->setName('file_exists')\n+            ->setNamespace('Mage\\Command\\BuiltIn')\n+            ->setFunction(\n+                function ($filePath) {\n+                    UnlockCommandTest::$fileExistsResult = $filePath;\n+                    return UnlockCommandTest::$isFileExists;\n+                }\n+            )\n+            ->build();\n+        $unlinkMock = $mockBuilder\n+            ->setName('unlink')\n+            ->setNamespace('Mage\\Command\\BuiltIn')\n+            ->setFunction(\n+                function () {\n+                    UnlockCommandTest::$isUnlinkCalled = true;\n+                }\n+            )\n+            ->build();\n+        $getCwdMock = $mockBuilder\n+            ->setNamespace('Mage\\Command\\BuiltIn')\n+            ->setName('getcwd')\n+            ->setFunction(\n+                function () {\n+                    return '';\n+                }\n+            )\n+            ->build();\n+\n+        $fileExistsMock->disable();\n+        $unlinkMock->disable();\n+        $getCwdMock->disable();\n+\n+        $fileExistsMock->enable();\n+        $unlinkMock->enable();\n+        $getCwdMock->enable();\n+\n+        $configMock = $this->getMock('Mage\\Config');\n+        $configMock->expects($this->atLeastOnce())\n+            ->method('getEnvironment')\n+            ->willReturn('production');\n+        $this->unlockCommand->setConfig($configMock);\n+\n+        $this->setUpConsoleStatics();\n+    }\n+\n+    /**\n+     * @covers ::run\n+     */\n+    public function testRun()\n+    {\n+        $expectedOutput = \"\\tUnlocked deployment to production environment\\n\\n\";\n+        $this->expectOutputString($expectedOutput);\n+        $expectedLockFilePath = '/.mage/production.lock';\n+\n+        self::$isFileExists = true;\n+\n+        $actualExitCode = $this->unlockCommand->run();\n+        $expectedExitCode = 0;\n+\n+        $this->assertTrue(self::$isUnlinkCalled);\n+        $this->assertEquals($expectedExitCode, $actualExitCode);\n+        $this->assertEquals($expectedLockFilePath, self::$fileExistsResult);\n+    }\n+\n+    /**\n+     * @covers ::run\n+     */\n+    public function testRunIfFileNotExist()\n+    {\n+        $expectedOutput = \"\\tUnlocked deployment to production environment\\n\\n\";\n+        $this->expectOutputString($expectedOutput);\n+        $expectedLockFilePath = '/.mage/production.lock';\n+\n+        self::$isFileExists = false;\n+\n+        $actualExitCode = $this->unlockCommand->run();\n+        $expectedExitCode = 0;\n+\n+        $this->assertFalse(self::$isUnlinkCalled);\n+        $this->assertEquals($expectedExitCode, $actualExitCode);\n+        $this->assertEquals($expectedLockFilePath, self::$fileExistsResult);\n+    }\n+}","path":"tests/MageTest/Command/BuiltIn/UnlockCommandTest.php","position":125,"original_position":125,"commit_id":"2cb06f7b3b91373e482cf42909d43e5c74721c3d","original_commit_id":"2cb06f7b3b91373e482cf42909d43e5c74721c3d","user":{"login":"eps90","id":1702899,"avatar_url":"https://avatars.githubusercontent.com/u/1702899?v=3","gravatar_id":"","url":"https://api.github.com/users/eps90","html_url":"https://github.com/eps90","followers_url":"https://api.github.com/users/eps90/followers","following_url":"https://api.github.com/users/eps90/following{/other_user}","gists_url":"https://api.github.com/users/eps90/gists{/gist_id}","starred_url":"https://api.github.com/users/eps90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eps90/subscriptions","organizations_url":"https://api.github.com/users/eps90/orgs","repos_url":"https://api.github.com/users/eps90/repos","events_url":"https://api.github.com/users/eps90/events{/privacy}","received_events_url":"https://api.github.com/users/eps90/received_events","type":"User","site_admin":false},"body":"cetrainly :)","created_at":"2015-02-28T22:45:44Z","updated_at":"2015-02-28T22:45:44Z","html_url":"https://github.com/andres-montanez/Magallanes/pull/197#discussion_r25562020","pull_request_url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197","_links":{"self":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/comments/25562020"},"html":{"href":"https://github.com/andres-montanez/Magallanes/pull/197#discussion_r25562020"},"pull_request":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197"}}},"pull_request":{"url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197","id":29773596,"html_url":"https://github.com/andres-montanez/Magallanes/pull/197","diff_url":"https://github.com/andres-montanez/Magallanes/pull/197.diff","patch_url":"https://github.com/andres-montanez/Magallanes/pull/197.patch","issue_url":"https://api.github.com/repos/andres-montanez/Magallanes/issues/197","number":197,"state":"open","locked":false,"title":"Add commands tests","user":{"login":"eps90","id":1702899,"avatar_url":"https://avatars.githubusercontent.com/u/1702899?v=3","gravatar_id":"","url":"https://api.github.com/users/eps90","html_url":"https://github.com/eps90","followers_url":"https://api.github.com/users/eps90/followers","following_url":"https://api.github.com/users/eps90/following{/other_user}","gists_url":"https://api.github.com/users/eps90/gists{/gist_id}","starred_url":"https://api.github.com/users/eps90/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/eps90/subscriptions","organizations_url":"https://api.github.com/users/eps90/orgs","repos_url":"https://api.github.com/users/eps90/repos","events_url":"https://api.github.com/users/eps90/events{/privacy}","received_events_url":"https://api.github.com/users/eps90/received_events","type":"User","site_admin":false},"body":"Hey there!\r\nThis PR introduces tests of few commands including:\r\n* `AbstractCommand`\r\n* `CompileCommand`\r\n* `ListCommand`\r\n* `LockCommand`\r\n* `UnlockCommand`\r\n\r\nThese tests cover the code in 100% (line coverage) without changing current functionality.\r\nFew words about PR:\r\n* I used [malkusch\\php-mock](https://github.com/malkusch/php-mock) for creating mocks of PHP's built-in functions. As far as I know, it uses the fact that PHP interpreter will use the function with the same name from the namespace where it was used in. This library contains some other cool options like making **stubs** on built-in functions but since we're keeping compatibility with PHP 5.3, we can't use them and we can just mock them to avoid unexpected results. Fortunatelly, author created the `php-5.3` branch.\r\n* I had to use `@uses` annotation to point that we use some other classes (like statics, impossible to inject and then mock) and not cover them. Without that annotation PHPUnit run with `--coverage-*` trigger will mark all tests as risky. **Note:** I didn't use this annotation only to suppress warnings. Each test class was tested without them to see if there are no other classes under control. As you can see, each test class contains almost the same `@uses` annotations.\r\n* I had to add setter in `CompileCommand` to mock `Mage\\Compiler` class. This setter is called in (also created by me) constructor, so nothing changed in this class' functionality.\r\n\r\nFor now coverage of the project is **22.36%**. Before creating these tests, it was about 7%.\r\nFeel free to review and discuss! Thanks!","created_at":"2015-02-22T17:36:04Z","updated_at":"2015-02-28T22:45:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5998aeb7fe222e2c0f365531ed4a9e595279d1e4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197/commits","review_comments_url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197/comments","review_comment_url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/andres-montanez/Magallanes/issues/197/comments","statuses_url":"https://api.github.com/repos/andres-montanez/Magallanes/statuses/2cb06f7b3b91373e482cf42909d43e5c74721c3d","head":{"label":"edpauto:command-tests","ref":"command-tests","sha":"2cb06f7b3b91373e482cf42909d43e5c74721c3d","user":{"login":"edpauto","id":6141608,"avatar_url":"https://avatars.githubusercontent.com/u/6141608?v=3","gravatar_id":"","url":"https://api.github.com/users/edpauto","html_url":"https://github.com/edpauto","followers_url":"https://api.github.com/users/edpauto/followers","following_url":"https://api.github.com/users/edpauto/following{/other_user}","gists_url":"https://api.github.com/users/edpauto/gists{/gist_id}","starred_url":"https://api.github.com/users/edpauto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edpauto/subscriptions","organizations_url":"https://api.github.com/users/edpauto/orgs","repos_url":"https://api.github.com/users/edpauto/repos","events_url":"https://api.github.com/users/edpauto/events{/privacy}","received_events_url":"https://api.github.com/users/edpauto/received_events","type":"Organization","site_admin":false},"repo":{"id":23123887,"name":"Magallanes","full_name":"edpauto/Magallanes","owner":{"login":"edpauto","id":6141608,"avatar_url":"https://avatars.githubusercontent.com/u/6141608?v=3","gravatar_id":"","url":"https://api.github.com/users/edpauto","html_url":"https://github.com/edpauto","followers_url":"https://api.github.com/users/edpauto/followers","following_url":"https://api.github.com/users/edpauto/following{/other_user}","gists_url":"https://api.github.com/users/edpauto/gists{/gist_id}","starred_url":"https://api.github.com/users/edpauto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edpauto/subscriptions","organizations_url":"https://api.github.com/users/edpauto/orgs","repos_url":"https://api.github.com/users/edpauto/repos","events_url":"https://api.github.com/users/edpauto/events{/privacy}","received_events_url":"https://api.github.com/users/edpauto/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/edpauto/Magallanes","description":"A PHP Deployment Tool","fork":true,"url":"https://api.github.com/repos/edpauto/Magallanes","forks_url":"https://api.github.com/repos/edpauto/Magallanes/forks","keys_url":"https://api.github.com/repos/edpauto/Magallanes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/edpauto/Magallanes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/edpauto/Magallanes/teams","hooks_url":"https://api.github.com/repos/edpauto/Magallanes/hooks","issue_events_url":"https://api.github.com/repos/edpauto/Magallanes/issues/events{/number}","events_url":"https://api.github.com/repos/edpauto/Magallanes/events","assignees_url":"https://api.github.com/repos/edpauto/Magallanes/assignees{/user}","branches_url":"https://api.github.com/repos/edpauto/Magallanes/branches{/branch}","tags_url":"https://api.github.com/repos/edpauto/Magallanes/tags","blobs_url":"https://api.github.com/repos/edpauto/Magallanes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/edpauto/Magallanes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/edpauto/Magallanes/git/refs{/sha}","trees_url":"https://api.github.com/repos/edpauto/Magallanes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/edpauto/Magallanes/statuses/{sha}","languages_url":"https://api.github.com/repos/edpauto/Magallanes/languages","stargazers_url":"https://api.github.com/repos/edpauto/Magallanes/stargazers","contributors_url":"https://api.github.com/repos/edpauto/Magallanes/contributors","subscribers_url":"https://api.github.com/repos/edpauto/Magallanes/subscribers","subscription_url":"https://api.github.com/repos/edpauto/Magallanes/subscription","commits_url":"https://api.github.com/repos/edpauto/Magallanes/commits{/sha}","git_commits_url":"https://api.github.com/repos/edpauto/Magallanes/git/commits{/sha}","comments_url":"https://api.github.com/repos/edpauto/Magallanes/comments{/number}","issue_comment_url":"https://api.github.com/repos/edpauto/Magallanes/issues/comments{/number}","contents_url":"https://api.github.com/repos/edpauto/Magallanes/contents/{+path}","compare_url":"https://api.github.com/repos/edpauto/Magallanes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/edpauto/Magallanes/merges","archive_url":"https://api.github.com/repos/edpauto/Magallanes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/edpauto/Magallanes/downloads","issues_url":"https://api.github.com/repos/edpauto/Magallanes/issues{/number}","pulls_url":"https://api.github.com/repos/edpauto/Magallanes/pulls{/number}","milestones_url":"https://api.github.com/repos/edpauto/Magallanes/milestones{/number}","notifications_url":"https://api.github.com/repos/edpauto/Magallanes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/edpauto/Magallanes/labels{/name}","releases_url":"https://api.github.com/repos/edpauto/Magallanes/releases{/id}","created_at":"2014-08-19T20:00:21Z","updated_at":"2015-02-24T20:24:48Z","pushed_at":"2015-02-24T20:24:48Z","git_url":"git://github.com/edpauto/Magallanes.git","ssh_url":"git@github.com:edpauto/Magallanes.git","clone_url":"https://github.com/edpauto/Magallanes.git","svn_url":"https://github.com/edpauto/Magallanes","homepage":"http://magephp.com","size":1137,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"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":"andres-montanez:develop","ref":"develop","sha":"9becda4df93de24bab1e7a99c5535a83ef6c3340","user":{"login":"andres-montanez","id":541125,"avatar_url":"https://avatars.githubusercontent.com/u/541125?v=3","gravatar_id":"","url":"https://api.github.com/users/andres-montanez","html_url":"https://github.com/andres-montanez","followers_url":"https://api.github.com/users/andres-montanez/followers","following_url":"https://api.github.com/users/andres-montanez/following{/other_user}","gists_url":"https://api.github.com/users/andres-montanez/gists{/gist_id}","starred_url":"https://api.github.com/users/andres-montanez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andres-montanez/subscriptions","organizations_url":"https://api.github.com/users/andres-montanez/orgs","repos_url":"https://api.github.com/users/andres-montanez/repos","events_url":"https://api.github.com/users/andres-montanez/events{/privacy}","received_events_url":"https://api.github.com/users/andres-montanez/received_events","type":"User","site_admin":false},"repo":{"id":2819518,"name":"Magallanes","full_name":"andres-montanez/Magallanes","owner":{"login":"andres-montanez","id":541125,"avatar_url":"https://avatars.githubusercontent.com/u/541125?v=3","gravatar_id":"","url":"https://api.github.com/users/andres-montanez","html_url":"https://github.com/andres-montanez","followers_url":"https://api.github.com/users/andres-montanez/followers","following_url":"https://api.github.com/users/andres-montanez/following{/other_user}","gists_url":"https://api.github.com/users/andres-montanez/gists{/gist_id}","starred_url":"https://api.github.com/users/andres-montanez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andres-montanez/subscriptions","organizations_url":"https://api.github.com/users/andres-montanez/orgs","repos_url":"https://api.github.com/users/andres-montanez/repos","events_url":"https://api.github.com/users/andres-montanez/events{/privacy}","received_events_url":"https://api.github.com/users/andres-montanez/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andres-montanez/Magallanes","description":"A PHP Deployment Tool","fork":false,"url":"https://api.github.com/repos/andres-montanez/Magallanes","forks_url":"https://api.github.com/repos/andres-montanez/Magallanes/forks","keys_url":"https://api.github.com/repos/andres-montanez/Magallanes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andres-montanez/Magallanes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andres-montanez/Magallanes/teams","hooks_url":"https://api.github.com/repos/andres-montanez/Magallanes/hooks","issue_events_url":"https://api.github.com/repos/andres-montanez/Magallanes/issues/events{/number}","events_url":"https://api.github.com/repos/andres-montanez/Magallanes/events","assignees_url":"https://api.github.com/repos/andres-montanez/Magallanes/assignees{/user}","branches_url":"https://api.github.com/repos/andres-montanez/Magallanes/branches{/branch}","tags_url":"https://api.github.com/repos/andres-montanez/Magallanes/tags","blobs_url":"https://api.github.com/repos/andres-montanez/Magallanes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andres-montanez/Magallanes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andres-montanez/Magallanes/git/refs{/sha}","trees_url":"https://api.github.com/repos/andres-montanez/Magallanes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andres-montanez/Magallanes/statuses/{sha}","languages_url":"https://api.github.com/repos/andres-montanez/Magallanes/languages","stargazers_url":"https://api.github.com/repos/andres-montanez/Magallanes/stargazers","contributors_url":"https://api.github.com/repos/andres-montanez/Magallanes/contributors","subscribers_url":"https://api.github.com/repos/andres-montanez/Magallanes/subscribers","subscription_url":"https://api.github.com/repos/andres-montanez/Magallanes/subscription","commits_url":"https://api.github.com/repos/andres-montanez/Magallanes/commits{/sha}","git_commits_url":"https://api.github.com/repos/andres-montanez/Magallanes/git/commits{/sha}","comments_url":"https://api.github.com/repos/andres-montanez/Magallanes/comments{/number}","issue_comment_url":"https://api.github.com/repos/andres-montanez/Magallanes/issues/comments{/number}","contents_url":"https://api.github.com/repos/andres-montanez/Magallanes/contents/{+path}","compare_url":"https://api.github.com/repos/andres-montanez/Magallanes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andres-montanez/Magallanes/merges","archive_url":"https://api.github.com/repos/andres-montanez/Magallanes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andres-montanez/Magallanes/downloads","issues_url":"https://api.github.com/repos/andres-montanez/Magallanes/issues{/number}","pulls_url":"https://api.github.com/repos/andres-montanez/Magallanes/pulls{/number}","milestones_url":"https://api.github.com/repos/andres-montanez/Magallanes/milestones{/number}","notifications_url":"https://api.github.com/repos/andres-montanez/Magallanes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andres-montanez/Magallanes/labels{/name}","releases_url":"https://api.github.com/repos/andres-montanez/Magallanes/releases{/id}","created_at":"2011-11-21T12:00:33Z","updated_at":"2015-02-28T21:05:25Z","pushed_at":"2015-02-24T20:19:42Z","git_url":"git://github.com/andres-montanez/Magallanes.git","ssh_url":"git@github.com:andres-montanez/Magallanes.git","clone_url":"https://github.com/andres-montanez/Magallanes.git","svn_url":"https://github.com/andres-montanez/Magallanes","homepage":"http://magephp.com","size":2326,"stargazers_count":337,"watchers_count":337,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":88,"mirror_url":null,"open_issues_count":35,"forks":88,"open_issues":35,"watchers":337,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197"},"html":{"href":"https://github.com/andres-montanez/Magallanes/pull/197"},"issue":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/issues/197"},"comments":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/issues/197/comments"},"review_comments":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197/comments"},"review_comment":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/pulls/197/commits"},"statuses":{"href":"https://api.github.com/repos/andres-montanez/Magallanes/statuses/2cb06f7b3b91373e482cf42909d43e5c74721c3d"}}}}