{"action":"created","comment":{"url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/comments/101759640","pull_request_review_id":22498618,"id":101759640,"diff_hunk":"@@ -6,34 +6,78 @@\n \n class VersionTest extends AlgoliaSearchTestCase\n {\n-    public function testVersion()\n+    public function tearDown()\n+    {\n+        Version::$custom_value = '';\n+        Version::clearUserAgentSuffixesAndPrefixes();\n+    }\n+\n+\n+    public function testVersionAddOnePrefixAndOneSuffix()\n     {\n         $userAgent = Version::getUserAgent();\n         $this->assertRegExp('/^Algolia for PHP \\(\\d+\\.\\d+\\.\\d+\\)$/', $userAgent);\n \n         Version::addPrefixUserAgentSegment('Prefix integration', '0.0.8');\n         Version::addSuffixUserAgentSegment('Suffix platform', '1.2.3');\n \n-        // Should be \"Prefix 0.0.8; Algolia for PHP (X.Y.Z); Suffix platform (1.2.3)\"\n         $userAgent = Version::getUserAgent();\n-        $this->assertRegExp('/^Prefix integration \\(0\\.0\\.8\\); Algolia for PHP \\(\\d+\\.\\d+\\.\\d+\\); Suffix platform \\(1\\.2\\.3\\)$/', $userAgent);\n+        $this->assertEquals('Prefix integration (0.0.8); Algolia for PHP ('.Version::VALUE.'); Suffix platform (1.2.3)', $userAgent);\n+    }\n \n+    public function testVersionAddTwoPrefixAndTwoSuffix()\n+    {\n+        Version::addPrefixUserAgentSegment('Prefix integration', '0.0.8');\n+        Version::addSuffixUserAgentSegment('Suffix platform', '1.2.3');\n         Version::addPrefixUserAgentSegment('Another prefix', '5.6.7');\n         Version::addSuffixUserAgentSegment('Different suffix', '7.8.9');\n \n-        // Should be \"Another prefix (5.6.7); Prefix 0.0.8; Algolia for PHP (X.Y.Z); Suffix platform (1.2.3); Different suffix (7.8.9)\"\n         $userAgent = Version::getUserAgent();\n-        $this->assertRegExp('/^Another prefix \\(5\\.6\\.7\\); Prefix integration \\(0\\.0\\.8\\); Algolia for PHP \\(\\d+\\.\\d+\\.\\d+\\); Suffix platform \\(1\\.2\\.3\\); Different suffix \\(7\\.8\\.9\\)$/', $userAgent);\n+        $this->assertEquals('Another prefix (5.6.7); Prefix integration (0.0.8); Algolia for PHP ('.Version::VALUE.'); Suffix platform (1.2.3); Different suffix (7.8.9)', $userAgent);\n \n         // Should be \"X.Y.Z\"\n         $version = Version::get();\n         $this->assertRegExp('/^\\d+\\.\\d+\\.\\d+$/', $version);\n+    }\n \n+    public function testVersionAddTwoPrefixAndTwoSuffixAndCustomValue()\n+    {\n+        Version::addPrefixUserAgentSegment('Prefix integration', '0.0.8');\n+        Version::addSuffixUserAgentSegment('Suffix platform', '1.2.3');\n+        Version::addPrefixUserAgentSegment('Another prefix', '5.6.7');\n+        Version::addSuffixUserAgentSegment('Different suffix', '7.8.9');\n         Version::$custom_value = ' custom_value';\n \n         $this->assertStringEndsWith(' custom_value', Version::getUserAgent());\n \n         // Shoul be \"X.Y.Z custom_value\"\n         $this->assertRegExp('/^\\d+\\.\\d+\\.\\d+ custom_value$/', Version::get());\n     }\n+\n+    public function testVersionDuplicatesPrefix()\n+    {\n+        Version::addPrefixUserAgentSegment('Another prefix', '5.6.7');\n+        Version::addPrefixUserAgentSegment('Another prefix', '5.6.7');\n+\n+        $userAgent = Version::getUserAgent();\n+        $this->assertEquals('Another prefix (5.6.7); Algolia for PHP (1.15.0)', $userAgent);\n+    }\n+\n+    public function testVersionDuplicatesSuffix()\n+    {\n+        Version::addSuffixUserAgentSegment('Another suffix', '5.6.7');\n+        Version::addSuffixUserAgentSegment('Another suffix', '5.6.7');\n+\n+        $userAgent = Version::getUserAgent();\n+        $this->assertEquals('Algolia for PHP (1.15.0); Another suffix (5.6.7)', $userAgent);\n+    }\n+\n+    public function testVersionTwoPrefix()\n+    {\n+        Version::addPrefixUserAgentSegment('prefix', '5.6.7');\n+        Version::addPrefixUserAgentSegment('Another prefix', '5.6.7');\n+\n+        $userAgent = Version::getUserAgent();\n+        $this->assertEquals('Another prefix (5.6.7); prefix (5.6.7); Algolia for PHP (1.15.0)', $userAgent);","path":"tests/AlgoliaSearch/Tests/VersionTest.php","position":null,"original_position":81,"commit_id":"bd081334734c192af0f0a7efa7e8bd2d57b7283c","original_commit_id":"6292e61c79c95f3e7ca0f04b948b0799a8abc4db","user":{"login":"maxiloc","id":1689007,"avatar_url":"https://avatars.githubusercontent.com/u/1689007?v=3","gravatar_id":"","url":"https://api.github.com/users/maxiloc","html_url":"https://github.com/maxiloc","followers_url":"https://api.github.com/users/maxiloc/followers","following_url":"https://api.github.com/users/maxiloc/following{/other_user}","gists_url":"https://api.github.com/users/maxiloc/gists{/gist_id}","starred_url":"https://api.github.com/users/maxiloc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxiloc/subscriptions","organizations_url":"https://api.github.com/users/maxiloc/orgs","repos_url":"https://api.github.com/users/maxiloc/repos","events_url":"https://api.github.com/users/maxiloc/events{/privacy}","received_events_url":"https://api.github.com/users/maxiloc/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2017-02-17T13:50:59Z","updated_at":"2017-02-17T13:51:00Z","html_url":"https://github.com/algolia/algoliasearch-client-php/pull/272#discussion_r101759640","pull_request_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272","_links":{"self":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/comments/101759640"},"html":{"href":"https://github.com/algolia/algoliasearch-client-php/pull/272#discussion_r101759640"},"pull_request":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272"}}},"pull_request":{"url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272","id":106732551,"html_url":"https://github.com/algolia/algoliasearch-client-php/pull/272","diff_url":"https://github.com/algolia/algoliasearch-client-php/pull/272.diff","patch_url":"https://github.com/algolia/algoliasearch-client-php/pull/272.patch","issue_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/272","number":272,"state":"open","locked":false,"title":"Fix duplicate user agent and allow more than one user agent prefix","user":{"login":"maxiloc","id":1689007,"avatar_url":"https://avatars.githubusercontent.com/u/1689007?v=3","gravatar_id":"","url":"https://api.github.com/users/maxiloc","html_url":"https://github.com/maxiloc","followers_url":"https://api.github.com/users/maxiloc/followers","following_url":"https://api.github.com/users/maxiloc/following{/other_user}","gists_url":"https://api.github.com/users/maxiloc/gists{/gist_id}","starred_url":"https://api.github.com/users/maxiloc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxiloc/subscriptions","organizations_url":"https://api.github.com/users/maxiloc/orgs","repos_url":"https://api.github.com/users/maxiloc/repos","events_url":"https://api.github.com/users/maxiloc/events{/privacy}","received_events_url":"https://api.github.com/users/maxiloc/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-02-17T13:27:00Z","updated_at":"2017-02-17T13:51:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f4854d1b56cf9acc620c21c89811d4ceb43e107c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272/commits","review_comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272/comments","review_comment_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/comments{/number}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/272/comments","statuses_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/statuses/bd081334734c192af0f0a7efa7e8bd2d57b7283c","head":{"label":"algolia:fix-user-agent","ref":"fix-user-agent","sha":"bd081334734c192af0f0a7efa7e8bd2d57b7283c","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":10172371,"name":"algoliasearch-client-php","full_name":"algolia/algoliasearch-client-php","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/algoliasearch-client-php","description":"Algolia Search API Client for PHP","fork":false,"url":"https://api.github.com/repos/algolia/algoliasearch-client-php","forks_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/forks","keys_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/teams","hooks_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/hooks","issue_events_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/events","assignees_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/tags","blobs_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/languages","stargazers_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/stargazers","contributors_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/contributors","subscribers_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/subscribers","subscription_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/subscription","commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/merges","archive_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/downloads","issues_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/labels{/name}","releases_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/releases{/id}","deployments_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/deployments","created_at":"2013-05-20T12:37:37Z","updated_at":"2017-02-13T00:27:35Z","pushed_at":"2017-02-17T13:50:45Z","git_url":"git://github.com/algolia/algoliasearch-client-php.git","ssh_url":"git@github.com:algolia/algoliasearch-client-php.git","clone_url":"https://github.com/algolia/algoliasearch-client-php.git","svn_url":"https://github.com/algolia/algoliasearch-client-php","homepage":null,"size":1178,"stargazers_count":133,"watchers_count":133,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":53,"mirror_url":null,"open_issues_count":9,"forks":53,"open_issues":9,"watchers":133,"default_branch":"master"}},"base":{"label":"algolia:master","ref":"master","sha":"83e27cc753a7e3f3b5e080ef750ac30e5b89ce1c","user":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"repo":{"id":10172371,"name":"algoliasearch-client-php","full_name":"algolia/algoliasearch-client-php","owner":{"login":"algolia","id":2034458,"avatar_url":"https://avatars.githubusercontent.com/u/2034458?v=3","gravatar_id":"","url":"https://api.github.com/users/algolia","html_url":"https://github.com/algolia","followers_url":"https://api.github.com/users/algolia/followers","following_url":"https://api.github.com/users/algolia/following{/other_user}","gists_url":"https://api.github.com/users/algolia/gists{/gist_id}","starred_url":"https://api.github.com/users/algolia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/algolia/subscriptions","organizations_url":"https://api.github.com/users/algolia/orgs","repos_url":"https://api.github.com/users/algolia/repos","events_url":"https://api.github.com/users/algolia/events{/privacy}","received_events_url":"https://api.github.com/users/algolia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/algolia/algoliasearch-client-php","description":"Algolia Search API Client for PHP","fork":false,"url":"https://api.github.com/repos/algolia/algoliasearch-client-php","forks_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/forks","keys_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/keys{/key_id}","collaborators_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/teams","hooks_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/hooks","issue_events_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/events{/number}","events_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/events","assignees_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/assignees{/user}","branches_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/branches{/branch}","tags_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/tags","blobs_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/refs{/sha}","trees_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/trees{/sha}","statuses_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/statuses/{sha}","languages_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/languages","stargazers_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/stargazers","contributors_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/contributors","subscribers_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/subscribers","subscription_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/subscription","commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/commits{/sha}","git_commits_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/git/commits{/sha}","comments_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/comments{/number}","issue_comment_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/comments{/number}","contents_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/contents/{+path}","compare_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/compare/{base}...{head}","merges_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/merges","archive_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/downloads","issues_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues{/number}","pulls_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls{/number}","milestones_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/milestones{/number}","notifications_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/labels{/name}","releases_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/releases{/id}","deployments_url":"https://api.github.com/repos/algolia/algoliasearch-client-php/deployments","created_at":"2013-05-20T12:37:37Z","updated_at":"2017-02-13T00:27:35Z","pushed_at":"2017-02-17T13:50:45Z","git_url":"git://github.com/algolia/algoliasearch-client-php.git","ssh_url":"git@github.com:algolia/algoliasearch-client-php.git","clone_url":"https://github.com/algolia/algoliasearch-client-php.git","svn_url":"https://github.com/algolia/algoliasearch-client-php","homepage":null,"size":1178,"stargazers_count":133,"watchers_count":133,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":53,"mirror_url":null,"open_issues_count":9,"forks":53,"open_issues":9,"watchers":133,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272"},"html":{"href":"https://github.com/algolia/algoliasearch-client-php/pull/272"},"issue":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/272"},"comments":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/issues/272/comments"},"review_comments":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272/comments"},"review_comment":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/pulls/272/commits"},"statuses":{"href":"https://api.github.com/repos/algolia/algoliasearch-client-php/statuses/bd081334734c192af0f0a7efa7e8bd2d57b7283c"}}}}
{"actor":{"display_login":"maxiloc"}}