{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony/pulls/comments/28099001","id":28099001,"diff_hunk":"@@ -51,117 +52,121 @@ protected function deleteTmpDir()\n         rmdir($this->tmpDir);\n     }\n \n-    public function testTransWithoutCaching()\n+    public function testThatACacheIsUsed()\n     {\n-        $translator = $this->getTranslator($this->getLoader());\n-        $translator->setLocale('fr');\n-        $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));\n-\n-        $this->assertEquals('foo (FR)', $translator->trans('foo'));\n-        $this->assertEquals('bar (EN)', $translator->trans('bar'));\n-        $this->assertEquals('foobar (ES)', $translator->trans('foobar'));\n-        $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0));\n-        $this->assertEquals('no translation', $translator->trans('no translation'));\n-        $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo'));\n-        $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));\n-        $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));\n-        $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));\n-    }\n-\n-    public function testTransWithCaching()\n-    {\n-        // prime the cache\n-        $translator = $this->getTranslator($this->getLoader(), $this->tmpDir);\n-        $translator->setLocale('fr');\n-        $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));\n-\n-        $this->assertEquals('foo (FR)', $translator->trans('foo'));\n-        $this->assertEquals('bar (EN)', $translator->trans('bar'));\n-        $this->assertEquals('foobar (ES)', $translator->trans('foobar'));\n-        $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0));\n-        $this->assertEquals('no translation', $translator->trans('no translation'));\n-        $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo'));\n-        $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));\n-        $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));\n-        $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));\n-\n-        // do it another time as the cache is primed now\n-        $loader = $this->getMock('Symfony\\Component\\Translation\\Loader\\LoaderInterface');\n-        $translator = $this->getTranslator($loader, $this->tmpDir);\n-        $translator->setLocale('fr');\n-        $translator->setFallbackLocales(array('en', 'es', 'pt-PT', 'pt_BR', 'fr.UTF-8', 'sr@latin'));\n-\n-        $this->assertEquals('foo (FR)', $translator->trans('foo'));\n-        $this->assertEquals('bar (EN)', $translator->trans('bar'));\n-        $this->assertEquals('foobar (ES)', $translator->trans('foobar'));\n-        $this->assertEquals('choice 0 (EN)', $translator->transChoice('choice', 0));\n-        $this->assertEquals('no translation', $translator->trans('no translation'));\n-        $this->assertEquals('foobarfoo (PT-PT)', $translator->trans('foobarfoo'));\n-        $this->assertEquals('other choice 1 (PT-BR)', $translator->transChoice('other choice', 1));\n-        $this->assertEquals('foobarbaz (fr.UTF-8)', $translator->trans('foobarbaz'));\n-        $this->assertEquals('foobarbax (sr@latin)', $translator->trans('foobarbax'));\n+        $locale = 'whatever';\n+        $format = 'what-you-like';\n+        $msgid = 'test';\n+\n+        foreach (array(false, true) as $debug) {\n+            // Prime the cache\n+            $translator = new Translator($locale, null, $this->tmpDir);\n+            $translator->addLoader($format, new ArrayLoader());\n+            $translator->addResource($format, array($msgid => 'OK'), $locale);\n+            $translator->trans($msgid);\n+\n+            // Try again and see we get a valid result whilst no loader can be used\n+            $translator = new Translator($locale, null, $this->tmpDir);\n+            $translator->addLoader($format, $this->createFailingLoader());\n+            $translator->addResource($format, array($msgid => 'OK'), $locale);\n+            $this->assertEquals('OK', $translator->trans($msgid), '-> caching does not work in '.($debug ? 'debug' : 'production'));\n+        }","path":"src/Symfony/Component/Translation/Tests/TranslatorCacheTest.php","position":83,"original_position":83,"commit_id":"394accffa209409315d1553466e91fea5ae76b88","original_commit_id":"394accffa209409315d1553466e91fea5ae76b88","user":{"login":"aitboudad","id":1753742,"avatar_url":"https://avatars.githubusercontent.com/u/1753742?v=3","gravatar_id":"","url":"https://api.github.com/users/aitboudad","html_url":"https://github.com/aitboudad","followers_url":"https://api.github.com/users/aitboudad/followers","following_url":"https://api.github.com/users/aitboudad/following{/other_user}","gists_url":"https://api.github.com/users/aitboudad/gists{/gist_id}","starred_url":"https://api.github.com/users/aitboudad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aitboudad/subscriptions","organizations_url":"https://api.github.com/users/aitboudad/orgs","repos_url":"https://api.github.com/users/aitboudad/repos","events_url":"https://api.github.com/users/aitboudad/events{/privacy}","received_events_url":"https://api.github.com/users/aitboudad/received_events","type":"User","site_admin":false},"body":"add ```$this->deleteTmpDir();```","created_at":"2015-04-09T20:24:04Z","updated_at":"2015-04-09T20:24:04Z","html_url":"https://github.com/symfony/symfony/pull/14291#discussion_r28099001","pull_request_url":"https://api.github.com/repos/symfony/symfony/pulls/14291","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments/28099001"},"html":{"href":"https://github.com/symfony/symfony/pull/14291#discussion_r28099001"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14291"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony/pulls/14291","id":32991460,"html_url":"https://github.com/symfony/symfony/pull/14291","diff_url":"https://github.com/symfony/symfony/pull/14291.diff","patch_url":"https://github.com/symfony/symfony/pull/14291.patch","issue_url":"https://api.github.com/repos/symfony/symfony/issues/14291","number":14291,"state":"open","locked":false,"title":"Test case refactoring and simplifications for the Translator class","user":{"login":"mpdude","id":1202333,"avatar_url":"https://avatars.githubusercontent.com/u/1202333?v=3","gravatar_id":"","url":"https://api.github.com/users/mpdude","html_url":"https://github.com/mpdude","followers_url":"https://api.github.com/users/mpdude/followers","following_url":"https://api.github.com/users/mpdude/following{/other_user}","gists_url":"https://api.github.com/users/mpdude/gists{/gist_id}","starred_url":"https://api.github.com/users/mpdude/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpdude/subscriptions","organizations_url":"https://api.github.com/users/mpdude/orgs","repos_url":"https://api.github.com/users/mpdude/repos","events_url":"https://api.github.com/users/mpdude/events{/privacy}","received_events_url":"https://api.github.com/users/mpdude/received_events","type":"User","site_admin":false},"body":"Also see #14280 and #14281.\r\n\r\nThis also tests for the fixes from b5da2ae87606e1f47081d6e6f09dd61ccb6ab501.\r\n\r\n*ping* @aitboudad ","created_at":"2015-04-09T20:10:37Z","updated_at":"2015-04-09T20:24:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"189181dcfec03dafe809a1767ff1b5aa27b2e714","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony/pulls/14291/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony/pulls/14291/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/14291/comments","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/394accffa209409315d1553466e91fea5ae76b88","head":{"label":"webfactory:independent-translator-caches","ref":"independent-translator-caches","sha":"394accffa209409315d1553466e91fea5ae76b88","user":{"login":"webfactory","id":135788,"avatar_url":"https://avatars.githubusercontent.com/u/135788?v=3","gravatar_id":"","url":"https://api.github.com/users/webfactory","html_url":"https://github.com/webfactory","followers_url":"https://api.github.com/users/webfactory/followers","following_url":"https://api.github.com/users/webfactory/following{/other_user}","gists_url":"https://api.github.com/users/webfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/webfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webfactory/subscriptions","organizations_url":"https://api.github.com/users/webfactory/orgs","repos_url":"https://api.github.com/users/webfactory/repos","events_url":"https://api.github.com/users/webfactory/events{/privacy}","received_events_url":"https://api.github.com/users/webfactory/received_events","type":"Organization","site_admin":false},"repo":{"id":3041501,"name":"symfony","full_name":"webfactory/symfony","owner":{"login":"webfactory","id":135788,"avatar_url":"https://avatars.githubusercontent.com/u/135788?v=3","gravatar_id":"","url":"https://api.github.com/users/webfactory","html_url":"https://github.com/webfactory","followers_url":"https://api.github.com/users/webfactory/followers","following_url":"https://api.github.com/users/webfactory/following{/other_user}","gists_url":"https://api.github.com/users/webfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/webfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webfactory/subscriptions","organizations_url":"https://api.github.com/users/webfactory/orgs","repos_url":"https://api.github.com/users/webfactory/repos","events_url":"https://api.github.com/users/webfactory/events{/privacy}","received_events_url":"https://api.github.com/users/webfactory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/webfactory/symfony","description":"The Symfony2 PHP framework","fork":true,"url":"https://api.github.com/repos/webfactory/symfony","forks_url":"https://api.github.com/repos/webfactory/symfony/forks","keys_url":"https://api.github.com/repos/webfactory/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/webfactory/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/webfactory/symfony/teams","hooks_url":"https://api.github.com/repos/webfactory/symfony/hooks","issue_events_url":"https://api.github.com/repos/webfactory/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/webfactory/symfony/events","assignees_url":"https://api.github.com/repos/webfactory/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/webfactory/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/webfactory/symfony/tags","blobs_url":"https://api.github.com/repos/webfactory/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/webfactory/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/webfactory/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/webfactory/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/webfactory/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/webfactory/symfony/languages","stargazers_url":"https://api.github.com/repos/webfactory/symfony/stargazers","contributors_url":"https://api.github.com/repos/webfactory/symfony/contributors","subscribers_url":"https://api.github.com/repos/webfactory/symfony/subscribers","subscription_url":"https://api.github.com/repos/webfactory/symfony/subscription","commits_url":"https://api.github.com/repos/webfactory/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/webfactory/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/webfactory/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/webfactory/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/webfactory/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/webfactory/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/webfactory/symfony/merges","archive_url":"https://api.github.com/repos/webfactory/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/webfactory/symfony/downloads","issues_url":"https://api.github.com/repos/webfactory/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/webfactory/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/webfactory/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/webfactory/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/webfactory/symfony/labels{/name}","releases_url":"https://api.github.com/repos/webfactory/symfony/releases{/id}","created_at":"2011-12-23T17:57:42Z","updated_at":"2014-09-30T06:38:40Z","pushed_at":"2015-04-09T20:15:52Z","git_url":"git://github.com/webfactory/symfony.git","ssh_url":"git@github.com:webfactory/symfony.git","clone_url":"https://github.com/webfactory/symfony.git","svn_url":"https://github.com/webfactory/symfony","homepage":"symfony.com","size":54581,"stargazers_count":1,"watchers_count":1,"language":"PHP","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"symfony:2.7","ref":"2.7","sha":"b5da2ae87606e1f47081d6e6f09dd61ccb6ab501","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":458058,"name":"symfony","full_name":"symfony/symfony","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony","description":"The Symfony PHP framework","fork":false,"url":"https://api.github.com/repos/symfony/symfony","forks_url":"https://api.github.com/repos/symfony/symfony/forks","keys_url":"https://api.github.com/repos/symfony/symfony/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony/teams","hooks_url":"https://api.github.com/repos/symfony/symfony/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony/events","assignees_url":"https://api.github.com/repos/symfony/symfony/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony/tags","blobs_url":"https://api.github.com/repos/symfony/symfony/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony/subscription","commits_url":"https://api.github.com/repos/symfony/symfony/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony/merges","archive_url":"https://api.github.com/repos/symfony/symfony/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony/downloads","issues_url":"https://api.github.com/repos/symfony/symfony/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony/releases{/id}","created_at":"2010-01-04T14:21:21Z","updated_at":"2015-04-09T17:35:09Z","pushed_at":"2015-04-09T20:15:55Z","git_url":"git://github.com/symfony/symfony.git","ssh_url":"git@github.com:symfony/symfony.git","clone_url":"https://github.com/symfony/symfony.git","svn_url":"https://github.com/symfony/symfony","homepage":"symfony.com","size":218264,"stargazers_count":9984,"watchers_count":9984,"language":"PHP","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":3918,"mirror_url":null,"open_issues_count":809,"forks":3918,"open_issues":809,"watchers":9984,"default_branch":"2.7"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14291"},"html":{"href":"https://github.com/symfony/symfony/pull/14291"},"issue":{"href":"https://api.github.com/repos/symfony/symfony/issues/14291"},"comments":{"href":"https://api.github.com/repos/symfony/symfony/issues/14291/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14291/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony/pulls/14291/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony/statuses/394accffa209409315d1553466e91fea5ae76b88"}}}}