{"action":"created","comment":{"url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/comments/37978127","id":37978127,"diff_hunk":"@@ -0,0 +1,627 @@\n+<?php\n+\n+namespace Clearbooks\\LabsMysql\\User;\n+\n+use Clearbooks\\LabsMysql\\Release\\MysqlReleaseGateway;\n+use Clearbooks\\LabsMysql\\Toggle\\Entity\\Toggle;\n+use Clearbooks\\LabsMysql\\Toggle\\MysqlActivatableToggleGateway;\n+use Clearbooks\\Labs\\User\\UseCase\\ToggleStatusModifier;\n+use Doctrine\\DBAL\\Configuration;\n+use Doctrine\\DBAL\\Connection;\n+use Doctrine\\DBAL\\DriverManager;\n+use PHPUnit_Framework_TestCase;\n+\n+/**\n+ * Created by PhpStorm.\n+ * User: Vovaxs\n+ * Date: 18/08/2015\n+ * Time: 11:57\n+ */\n+class MysqlUserToggleServiceTest extends PHPUnit_Framework_TestCase\n+{\n+\n+    /**\n+     * @var Connection $connection\n+     */\n+    private $connection;\n+\n+    /**\n+     * @var MysqlToggleStatusModifierService\n+     */\n+    private $gateway;\n+\n+    /**\n+     * @throws InvalidArgumentException\n+     */\n+    private function deleteAddedReleases()\n+    {\n+        $this->connection->delete( '`release`', [ '*' ] );\n+    }\n+\n+    /**\n+     * @throws InvalidArgumentException\n+     */\n+    private function deleteAddedToggles()\n+    {\n+        $this->connection->delete( '`toggle`', [ '*' ] );\n+    }\n+\n+    /**\n+     * @throws InvalidArgumentException\n+     */\n+    private function deleteAddedUserActivatedToggles()\n+    {\n+        $this->connection->delete( '`user_activated_toggle`', [ '*' ] );\n+    }\n+\n+\n+    /**\n+     * @throws InvalidArgumentException\n+     */\n+    private function deleteAddedGroupActivatedToggles()\n+    {\n+        $this->connection->delete( '`group_activated_toggle`', [ '*' ] );\n+    }\n+\n+    /**\n+     * @param string $releaseName\n+     * @param string $url\n+     * @return string\n+     */\n+    private function addRelease( $releaseName, $url )\n+    {\n+        ( new MysqlReleaseGateway( $this->connection ) )->addRelease( $releaseName, $url );\n+        return $this->connection->lastInsertId( \"`release`\" );\n+    }\n+\n+    /**\n+     * @param string $name\n+     * @param string $releaseId\n+     * @param bool $isActive\n+     * @param int $toggle_type\n+     * @return string\n+     */\n+    private function addToggle( $name, $releaseId, $isActive = false, $toggle_type = 1 )\n+    {\n+        $this->addToggleToDatabase( $name, $releaseId, $isActive, $toggle_type );\n+        return $this->connection->lastInsertId( \"`toggle`\" );\n+    }\n+\n+    /**\n+     * @param string $name\n+     * @param string $releaseId\n+     * @param bool $isActive\n+     * @param int $toggle_type\n+     * @return int\n+     */\n+    public function addToggleToDatabase( $name, $releaseId, $isActive, $toggle_type )\n+    {\n+        return $this->connection->insert( \"`toggle`\",\n+            [ 'name' => $name, 'release_id' => $releaseId, 'toggle_type' => $toggle_type, 'is_active' => $isActive ] );\n+    }\n+\n+    /**\n+     * @param string $toggle_id\n+     * @param string $user_id\n+     * @param bool $status\n+     */\n+    private function addUserActivatedToggle( $toggle_id, $user_id, $status = false )\n+    {\n+        $this->connection->insert( \"`user_activated_toggle`\",\n+            [ 'user_id' => $user_id, 'toggle_id' => $toggle_id, 'is_active' => $status ] );\n+    }\n+\n+    /**\n+     * @param string $toggle_id\n+     * @param string $user_id\n+     * @param bool $status\n+     */\n+    private function addGroupActivatedToggle( $toggle_id, $user_id, $status = false )\n+    {\n+        $this->connection->insert( \"`group_activated_toggle`\",\n+            [ 'group_id' => $user_id, 'toggle_id' => $toggle_id, 'active' => $status ] );\n+    }\n+\n+    /**\n+     * @param string $toggle_id\n+     * @param string $user_id\n+     * @return array\n+     */\n+    private function getUserActivatedToggleEntry( $toggle_id, $user_id )\n+    {\n+        $data = $this->connection->fetchAssoc( 'SELECT * FROM `user_activated_toggle` WHERE toggle_id = ? AND user_id = ?',\n+            [ $toggle_id, $user_id ] );\n+        if ( empty( $data ) ) {\n+            return [ ];\n+        }\n+        $entery = [ 1 => $data[ 'toggle_id' ], 2 => $data[ 'user_id' ], 3 => $data[ 'is_active' ] ];\n+        return $entery;","path":"test/User/MysqlToggleStatusModifierServiceTest.php","position":138,"original_position":138,"commit_id":"f294c731c712e4ac6754ce2771e19b92a44221bc","original_commit_id":"f294c731c712e4ac6754ce2771e19b92a44221bc","user":{"login":"danielburnley","id":976254,"avatar_url":"https://avatars.githubusercontent.com/u/976254?v=3","gravatar_id":"","url":"https://api.github.com/users/danielburnley","html_url":"https://github.com/danielburnley","followers_url":"https://api.github.com/users/danielburnley/followers","following_url":"https://api.github.com/users/danielburnley/following{/other_user}","gists_url":"https://api.github.com/users/danielburnley/gists{/gist_id}","starred_url":"https://api.github.com/users/danielburnley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielburnley/subscriptions","organizations_url":"https://api.github.com/users/danielburnley/orgs","repos_url":"https://api.github.com/users/danielburnley/repos","events_url":"https://api.github.com/users/danielburnley/events{/privacy}","received_events_url":"https://api.github.com/users/danielburnley/received_events","type":"User","site_admin":false},"body":"entry*","created_at":"2015-08-26T13:03:14Z","updated_at":"2015-08-26T13:03:14Z","html_url":"https://github.com/clearbooks/labs-mysql/pull/5#discussion_r37978127","pull_request_url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/comments/37978127"},"html":{"href":"https://github.com/clearbooks/labs-mysql/pull/5#discussion_r37978127"},"pull_request":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5","id":42809640,"html_url":"https://github.com/clearbooks/labs-mysql/pull/5","diff_url":"https://github.com/clearbooks/labs-mysql/pull/5.diff","patch_url":"https://github.com/clearbooks/labs-mysql/pull/5.patch","issue_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues/5","number":5,"state":"open","locked":false,"title":"Labs 67 mysql user toggle service","user":{"login":"VolodymyrSergeyev","id":13553024,"avatar_url":"https://avatars.githubusercontent.com/u/13553024?v=3","gravatar_id":"","url":"https://api.github.com/users/VolodymyrSergeyev","html_url":"https://github.com/VolodymyrSergeyev","followers_url":"https://api.github.com/users/VolodymyrSergeyev/followers","following_url":"https://api.github.com/users/VolodymyrSergeyev/following{/other_user}","gists_url":"https://api.github.com/users/VolodymyrSergeyev/gists{/gist_id}","starred_url":"https://api.github.com/users/VolodymyrSergeyev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/VolodymyrSergeyev/subscriptions","organizations_url":"https://api.github.com/users/VolodymyrSergeyev/orgs","repos_url":"https://api.github.com/users/VolodymyrSergeyev/repos","events_url":"https://api.github.com/users/VolodymyrSergeyev/events{/privacy}","received_events_url":"https://api.github.com/users/VolodymyrSergeyev/received_events","type":"User","site_admin":false},"body":"Makes and satisfies all the tests for MysqlUserToggleService.\r\nModifies the tables.sql to add user_activated_toggle table.","created_at":"2015-08-19T12:44:37Z","updated_at":"2015-08-26T13:03:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3f9482cc15ae38b7d4ebfe90527cb1a9b553d32e","assignee":{"login":"danielburnley","id":976254,"avatar_url":"https://avatars.githubusercontent.com/u/976254?v=3","gravatar_id":"","url":"https://api.github.com/users/danielburnley","html_url":"https://github.com/danielburnley","followers_url":"https://api.github.com/users/danielburnley/followers","following_url":"https://api.github.com/users/danielburnley/following{/other_user}","gists_url":"https://api.github.com/users/danielburnley/gists{/gist_id}","starred_url":"https://api.github.com/users/danielburnley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielburnley/subscriptions","organizations_url":"https://api.github.com/users/danielburnley/orgs","repos_url":"https://api.github.com/users/danielburnley/repos","events_url":"https://api.github.com/users/danielburnley/events{/privacy}","received_events_url":"https://api.github.com/users/danielburnley/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5/commits","review_comments_url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5/comments","review_comment_url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/comments{/number}","comments_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues/5/comments","statuses_url":"https://api.github.com/repos/clearbooks/labs-mysql/statuses/f294c731c712e4ac6754ce2771e19b92a44221bc","head":{"label":"clearbooks:LABS-67_MysqlUserToggleService","ref":"LABS-67_MysqlUserToggleService","sha":"f294c731c712e4ac6754ce2771e19b92a44221bc","user":{"login":"clearbooks","id":976249,"avatar_url":"https://avatars.githubusercontent.com/u/976249?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbooks","html_url":"https://github.com/clearbooks","followers_url":"https://api.github.com/users/clearbooks/followers","following_url":"https://api.github.com/users/clearbooks/following{/other_user}","gists_url":"https://api.github.com/users/clearbooks/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbooks/subscriptions","organizations_url":"https://api.github.com/users/clearbooks/orgs","repos_url":"https://api.github.com/users/clearbooks/repos","events_url":"https://api.github.com/users/clearbooks/events{/privacy}","received_events_url":"https://api.github.com/users/clearbooks/received_events","type":"Organization","site_admin":false},"repo":{"id":39497123,"name":"labs-mysql","full_name":"clearbooks/labs-mysql","owner":{"login":"clearbooks","id":976249,"avatar_url":"https://avatars.githubusercontent.com/u/976249?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbooks","html_url":"https://github.com/clearbooks","followers_url":"https://api.github.com/users/clearbooks/followers","following_url":"https://api.github.com/users/clearbooks/following{/other_user}","gists_url":"https://api.github.com/users/clearbooks/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbooks/subscriptions","organizations_url":"https://api.github.com/users/clearbooks/orgs","repos_url":"https://api.github.com/users/clearbooks/repos","events_url":"https://api.github.com/users/clearbooks/events{/privacy}","received_events_url":"https://api.github.com/users/clearbooks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clearbooks/labs-mysql","description":"Labs MySQL storage backend","fork":false,"url":"https://api.github.com/repos/clearbooks/labs-mysql","forks_url":"https://api.github.com/repos/clearbooks/labs-mysql/forks","keys_url":"https://api.github.com/repos/clearbooks/labs-mysql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clearbooks/labs-mysql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clearbooks/labs-mysql/teams","hooks_url":"https://api.github.com/repos/clearbooks/labs-mysql/hooks","issue_events_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues/events{/number}","events_url":"https://api.github.com/repos/clearbooks/labs-mysql/events","assignees_url":"https://api.github.com/repos/clearbooks/labs-mysql/assignees{/user}","branches_url":"https://api.github.com/repos/clearbooks/labs-mysql/branches{/branch}","tags_url":"https://api.github.com/repos/clearbooks/labs-mysql/tags","blobs_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/refs{/sha}","trees_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clearbooks/labs-mysql/statuses/{sha}","languages_url":"https://api.github.com/repos/clearbooks/labs-mysql/languages","stargazers_url":"https://api.github.com/repos/clearbooks/labs-mysql/stargazers","contributors_url":"https://api.github.com/repos/clearbooks/labs-mysql/contributors","subscribers_url":"https://api.github.com/repos/clearbooks/labs-mysql/subscribers","subscription_url":"https://api.github.com/repos/clearbooks/labs-mysql/subscription","commits_url":"https://api.github.com/repos/clearbooks/labs-mysql/commits{/sha}","git_commits_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/commits{/sha}","comments_url":"https://api.github.com/repos/clearbooks/labs-mysql/comments{/number}","issue_comment_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues/comments{/number}","contents_url":"https://api.github.com/repos/clearbooks/labs-mysql/contents/{+path}","compare_url":"https://api.github.com/repos/clearbooks/labs-mysql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clearbooks/labs-mysql/merges","archive_url":"https://api.github.com/repos/clearbooks/labs-mysql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clearbooks/labs-mysql/downloads","issues_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues{/number}","pulls_url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls{/number}","milestones_url":"https://api.github.com/repos/clearbooks/labs-mysql/milestones{/number}","notifications_url":"https://api.github.com/repos/clearbooks/labs-mysql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clearbooks/labs-mysql/labels{/name}","releases_url":"https://api.github.com/repos/clearbooks/labs-mysql/releases{/id}","created_at":"2015-07-22T09:20:20Z","updated_at":"2015-08-14T09:51:40Z","pushed_at":"2015-08-26T11:22:26Z","git_url":"git://github.com/clearbooks/labs-mysql.git","ssh_url":"git@github.com:clearbooks/labs-mysql.git","clone_url":"https://github.com/clearbooks/labs-mysql.git","svn_url":"https://github.com/clearbooks/labs-mysql","homepage":null,"size":416,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"base":{"label":"clearbooks:master","ref":"master","sha":"e4571e53b1add82f6373ec4a567e4a9dca144ef0","user":{"login":"clearbooks","id":976249,"avatar_url":"https://avatars.githubusercontent.com/u/976249?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbooks","html_url":"https://github.com/clearbooks","followers_url":"https://api.github.com/users/clearbooks/followers","following_url":"https://api.github.com/users/clearbooks/following{/other_user}","gists_url":"https://api.github.com/users/clearbooks/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbooks/subscriptions","organizations_url":"https://api.github.com/users/clearbooks/orgs","repos_url":"https://api.github.com/users/clearbooks/repos","events_url":"https://api.github.com/users/clearbooks/events{/privacy}","received_events_url":"https://api.github.com/users/clearbooks/received_events","type":"Organization","site_admin":false},"repo":{"id":39497123,"name":"labs-mysql","full_name":"clearbooks/labs-mysql","owner":{"login":"clearbooks","id":976249,"avatar_url":"https://avatars.githubusercontent.com/u/976249?v=3","gravatar_id":"","url":"https://api.github.com/users/clearbooks","html_url":"https://github.com/clearbooks","followers_url":"https://api.github.com/users/clearbooks/followers","following_url":"https://api.github.com/users/clearbooks/following{/other_user}","gists_url":"https://api.github.com/users/clearbooks/gists{/gist_id}","starred_url":"https://api.github.com/users/clearbooks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/clearbooks/subscriptions","organizations_url":"https://api.github.com/users/clearbooks/orgs","repos_url":"https://api.github.com/users/clearbooks/repos","events_url":"https://api.github.com/users/clearbooks/events{/privacy}","received_events_url":"https://api.github.com/users/clearbooks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/clearbooks/labs-mysql","description":"Labs MySQL storage backend","fork":false,"url":"https://api.github.com/repos/clearbooks/labs-mysql","forks_url":"https://api.github.com/repos/clearbooks/labs-mysql/forks","keys_url":"https://api.github.com/repos/clearbooks/labs-mysql/keys{/key_id}","collaborators_url":"https://api.github.com/repos/clearbooks/labs-mysql/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/clearbooks/labs-mysql/teams","hooks_url":"https://api.github.com/repos/clearbooks/labs-mysql/hooks","issue_events_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues/events{/number}","events_url":"https://api.github.com/repos/clearbooks/labs-mysql/events","assignees_url":"https://api.github.com/repos/clearbooks/labs-mysql/assignees{/user}","branches_url":"https://api.github.com/repos/clearbooks/labs-mysql/branches{/branch}","tags_url":"https://api.github.com/repos/clearbooks/labs-mysql/tags","blobs_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/refs{/sha}","trees_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/trees{/sha}","statuses_url":"https://api.github.com/repos/clearbooks/labs-mysql/statuses/{sha}","languages_url":"https://api.github.com/repos/clearbooks/labs-mysql/languages","stargazers_url":"https://api.github.com/repos/clearbooks/labs-mysql/stargazers","contributors_url":"https://api.github.com/repos/clearbooks/labs-mysql/contributors","subscribers_url":"https://api.github.com/repos/clearbooks/labs-mysql/subscribers","subscription_url":"https://api.github.com/repos/clearbooks/labs-mysql/subscription","commits_url":"https://api.github.com/repos/clearbooks/labs-mysql/commits{/sha}","git_commits_url":"https://api.github.com/repos/clearbooks/labs-mysql/git/commits{/sha}","comments_url":"https://api.github.com/repos/clearbooks/labs-mysql/comments{/number}","issue_comment_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues/comments{/number}","contents_url":"https://api.github.com/repos/clearbooks/labs-mysql/contents/{+path}","compare_url":"https://api.github.com/repos/clearbooks/labs-mysql/compare/{base}...{head}","merges_url":"https://api.github.com/repos/clearbooks/labs-mysql/merges","archive_url":"https://api.github.com/repos/clearbooks/labs-mysql/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/clearbooks/labs-mysql/downloads","issues_url":"https://api.github.com/repos/clearbooks/labs-mysql/issues{/number}","pulls_url":"https://api.github.com/repos/clearbooks/labs-mysql/pulls{/number}","milestones_url":"https://api.github.com/repos/clearbooks/labs-mysql/milestones{/number}","notifications_url":"https://api.github.com/repos/clearbooks/labs-mysql/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/clearbooks/labs-mysql/labels{/name}","releases_url":"https://api.github.com/repos/clearbooks/labs-mysql/releases{/id}","created_at":"2015-07-22T09:20:20Z","updated_at":"2015-08-14T09:51:40Z","pushed_at":"2015-08-26T11:22:26Z","git_url":"git://github.com/clearbooks/labs-mysql.git","ssh_url":"git@github.com:clearbooks/labs-mysql.git","clone_url":"https://github.com/clearbooks/labs-mysql.git","svn_url":"https://github.com/clearbooks/labs-mysql","homepage":null,"size":416,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5"},"html":{"href":"https://github.com/clearbooks/labs-mysql/pull/5"},"issue":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/issues/5"},"comments":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5/comments"},"review_comment":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/pulls/5/commits"},"statuses":{"href":"https://api.github.com/repos/clearbooks/labs-mysql/statuses/f294c731c712e4ac6754ce2771e19b92a44221bc"}}}}