{"action":"created","comment":{"url":"https://api.github.com/repos/cakephp/cakephp/pulls/comments/41107431","id":41107431,"diff_hunk":"@@ -1737,6 +1737,265 @@ public function testSavePrimaryKeyEntityExists()\n         $this->assertSame($entity, $table->save($entity));\n     }\n \n+\n+    /**\n+     * Test that save works with replace saveStrategy and are not deleted once they are not null\n+     *\n+     * @return void\n+     */\n+    public function testSaveReplaceSaveStrategy()\n+    {\n+        $authors = $this->getMock(\n+            'Cake\\ORM\\Table',\n+            ['exists'],\n+            [\n+                [\n+                    'connection' => $this->connection,\n+                    'alias' => 'Authors',\n+                    'table' => 'authors',\n+                ]\n+            ]\n+        );\n+        $authors->hasMany('Articles', ['saveStrategy' => 'replace']);\n+\n+        $entity = $authors->newEntity([\n+            'name' => 'mylux',\n+            'articles' => [\n+                ['title' => 'One Random Post', 'body' => 'The cake is not a lie'],\n+                ['title' => 'Another Random Post', 'body' => 'The cake is nice'],\n+                ['title' => 'One more random post', 'body' => 'The cake is forever']\n+            ]\n+        ], ['associated' => ['Articles']]);\n+\n+        $entity = $authors->save($entity, ['associated' => ['Articles']]);\n+        $sizeArticles = count($entity->articles);\n+        $this->assertEquals($sizeArticles, $authors->Articles->find('all')->where(['author_id' => $entity['id']])->count());\n+\n+        $articleId = $entity->articles[0]->id;\n+        unset($entity->articles[0]);\n+        $entity->dirty('articles', true);\n+        \n+        $authors->save($entity, ['associated' => ['Articles']]);\n+        \n+        $this->assertEquals($sizeArticles - 1, $authors->Articles->find('all')->where(['author_id' => $entity['id']])->count());\n+        $this->assertTrue($authors->Articles->exists(['id' => $articleId]));\n+    }\n+\n+\n+    /**\n+     * Test that save works with append saveStrategy not deleting or setting null anything\n+     *\n+     * @return void\n+     */\n+    public function testSaveAppendSaveStrategy()\n+    {\n+        $authors = $this->getMock(\n+            'Cake\\ORM\\Table',\n+            ['exists'],\n+            [\n+                [\n+                    'connection' => $this->connection,\n+                    'alias' => 'Authors',\n+                    'table' => 'authors',\n+                ]\n+            ]\n+        );\n+        $authors->hasMany('Articles', ['saveStrategy' => 'append']);\n+\n+        $entity = $authors->newEntity([\n+            'name' => 'mylux',\n+            'articles' => [\n+                ['title' => 'One Random Post', 'body' => 'The cake is not a lie'],\n+                ['title' => 'Another Random Post', 'body' => 'The cake is nice'],\n+                ['title' => 'One more random post', 'body' => 'The cake is forever']\n+            ]\n+        ], ['associated' => ['Articles']]);\n+\n+        $entity = $authors->save($entity, ['associated' => ['Articles']]);\n+        $sizeArticles = count($entity->articles);\n+\n+        $this->assertEquals($sizeArticles, $authors->Articles->find('all')->where(['author_id' => $entity['id']])->count());\n+        \n+        $articleId = $entity->articles[0]->id;\n+        unset($entity->articles[0]);\n+        $entity->dirty('articles', true);\n+        \n+        $authors->save($entity, ['associated' => ['Articles']]);\n+        \n+        $this->assertEquals($sizeArticles, $authors->Articles->find('all')->where(['author_id' => $entity['id']])->count());\n+        $this->assertTrue($authors->Articles->exists(['id' => $articleId]));\n+    }\n+    /**\n+     * Test that save has append as the default save strategy\n+     *\n+     * @return void\n+     */\n+    public function testSaveDefaultSaveStrategy()\n+    {\n+        $authors = new Table(\n+            [\n+                'table' => 'authors',\n+                'alias' => 'Authors',\n+                'connection' => $this->connection,\n+                'entityClass' => 'Cake\\ORM\\Entity',\n+            ]\n+        );\n+        $authors->hasMany('Articles', ['saveStrategy' => 'append']);\n+        $this->assertEquals('append', $authors->association('articles')->saveStrategy());\n+    }\n+\n+    /**\n+     * Test that the associated entities are unlinked and deleted when they are dependent\n+     *\n+     * @return void\n+     */\n+    public function testSaveReplaceSaveStrategyDependent()\n+    {\n+        $authors = $this->getMock(\n+            'Cake\\ORM\\Table',\n+            ['exists'],","path":"tests/TestCase/ORM/TableTest.php","position":120,"original_position":120,"commit_id":"6ba93e9869f6e99fe001ed2fa0dd8eaf3bcc069b","original_commit_id":"6ba93e9869f6e99fe001ed2fa0dd8eaf3bcc069b","user":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"body":"Why is exists() being mocked out if you are using fixtures as well?","created_at":"2015-10-05T02:45:17Z","updated_at":"2015-10-05T02:45:17Z","html_url":"https://github.com/cakephp/cakephp/pull/7477#discussion_r41107431","pull_request_url":"https://api.github.com/repos/cakephp/cakephp/pulls/7477","_links":{"self":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/comments/41107431"},"html":{"href":"https://github.com/cakephp/cakephp/pull/7477#discussion_r41107431"},"pull_request":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7477"}}},"pull_request":{"url":"https://api.github.com/repos/cakephp/cakephp/pulls/7477","id":46230728,"html_url":"https://github.com/cakephp/cakephp/pull/7477","diff_url":"https://github.com/cakephp/cakephp/pull/7477.diff","patch_url":"https://github.com/cakephp/cakephp/pull/7477.patch","issue_url":"https://api.github.com/repos/cakephp/cakephp/issues/7477","number":7477,"state":"open","locked":false,"title":"Implemented replace save strategy for hasmany associations","user":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"body":"PR as discussed in #7462 ","created_at":"2015-09-29T02:32:11Z","updated_at":"2015-10-05T02:45:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7f2617c8e1c62588d65d7a105e8eb063518f2a01","assignee":null,"milestone":{"url":"https://api.github.com/repos/cakephp/cakephp/milestones/60","html_url":"https://github.com/cakephp/cakephp/milestones/3.1.1","labels_url":"https://api.github.com/repos/cakephp/cakephp/milestones/60/labels","id":1314897,"number":60,"title":"3.1.1","description":"Bugfixes and minor enhancements for 3.1.x","creator":{"login":"markstory","id":24086,"avatar_url":"https://avatars.githubusercontent.com/u/24086?v=3","gravatar_id":"","url":"https://api.github.com/users/markstory","html_url":"https://github.com/markstory","followers_url":"https://api.github.com/users/markstory/followers","following_url":"https://api.github.com/users/markstory/following{/other_user}","gists_url":"https://api.github.com/users/markstory/gists{/gist_id}","starred_url":"https://api.github.com/users/markstory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markstory/subscriptions","organizations_url":"https://api.github.com/users/markstory/orgs","repos_url":"https://api.github.com/users/markstory/repos","events_url":"https://api.github.com/users/markstory/events{/privacy}","received_events_url":"https://api.github.com/users/markstory/received_events","type":"User","site_admin":false},"open_issues":35,"closed_issues":56,"state":"open","created_at":"2015-09-20T02:24:50Z","updated_at":"2015-10-03T14:13:48Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/cakephp/cakephp/pulls/7477/commits","review_comments_url":"https://api.github.com/repos/cakephp/cakephp/pulls/7477/comments","review_comment_url":"https://api.github.com/repos/cakephp/cakephp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/7477/comments","statuses_url":"https://api.github.com/repos/cakephp/cakephp/statuses/6ba93e9869f6e99fe001ed2fa0dd8eaf3bcc069b","head":{"label":"mylux:issue-7462","ref":"issue-7462","sha":"6ba93e9869f6e99fe001ed2fa0dd8eaf3bcc069b","user":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"repo":{"id":43277823,"name":"cakephp","full_name":"mylux/cakephp","owner":{"login":"mylux","id":11030522,"avatar_url":"https://avatars.githubusercontent.com/u/11030522?v=3","gravatar_id":"","url":"https://api.github.com/users/mylux","html_url":"https://github.com/mylux","followers_url":"https://api.github.com/users/mylux/followers","following_url":"https://api.github.com/users/mylux/following{/other_user}","gists_url":"https://api.github.com/users/mylux/gists{/gist_id}","starred_url":"https://api.github.com/users/mylux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mylux/subscriptions","organizations_url":"https://api.github.com/users/mylux/orgs","repos_url":"https://api.github.com/users/mylux/repos","events_url":"https://api.github.com/users/mylux/events{/privacy}","received_events_url":"https://api.github.com/users/mylux/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mylux/cakephp","description":"CakePHP: The Rapid Development Framework for PHP - Official Repository","fork":true,"url":"https://api.github.com/repos/mylux/cakephp","forks_url":"https://api.github.com/repos/mylux/cakephp/forks","keys_url":"https://api.github.com/repos/mylux/cakephp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mylux/cakephp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mylux/cakephp/teams","hooks_url":"https://api.github.com/repos/mylux/cakephp/hooks","issue_events_url":"https://api.github.com/repos/mylux/cakephp/issues/events{/number}","events_url":"https://api.github.com/repos/mylux/cakephp/events","assignees_url":"https://api.github.com/repos/mylux/cakephp/assignees{/user}","branches_url":"https://api.github.com/repos/mylux/cakephp/branches{/branch}","tags_url":"https://api.github.com/repos/mylux/cakephp/tags","blobs_url":"https://api.github.com/repos/mylux/cakephp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mylux/cakephp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mylux/cakephp/git/refs{/sha}","trees_url":"https://api.github.com/repos/mylux/cakephp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mylux/cakephp/statuses/{sha}","languages_url":"https://api.github.com/repos/mylux/cakephp/languages","stargazers_url":"https://api.github.com/repos/mylux/cakephp/stargazers","contributors_url":"https://api.github.com/repos/mylux/cakephp/contributors","subscribers_url":"https://api.github.com/repos/mylux/cakephp/subscribers","subscription_url":"https://api.github.com/repos/mylux/cakephp/subscription","commits_url":"https://api.github.com/repos/mylux/cakephp/commits{/sha}","git_commits_url":"https://api.github.com/repos/mylux/cakephp/git/commits{/sha}","comments_url":"https://api.github.com/repos/mylux/cakephp/comments{/number}","issue_comment_url":"https://api.github.com/repos/mylux/cakephp/issues/comments{/number}","contents_url":"https://api.github.com/repos/mylux/cakephp/contents/{+path}","compare_url":"https://api.github.com/repos/mylux/cakephp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mylux/cakephp/merges","archive_url":"https://api.github.com/repos/mylux/cakephp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mylux/cakephp/downloads","issues_url":"https://api.github.com/repos/mylux/cakephp/issues{/number}","pulls_url":"https://api.github.com/repos/mylux/cakephp/pulls{/number}","milestones_url":"https://api.github.com/repos/mylux/cakephp/milestones{/number}","notifications_url":"https://api.github.com/repos/mylux/cakephp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mylux/cakephp/labels{/name}","releases_url":"https://api.github.com/repos/mylux/cakephp/releases{/id}","created_at":"2015-09-28T03:25:51Z","updated_at":"2015-09-28T03:26:07Z","pushed_at":"2015-10-04T19:51:56Z","git_url":"git://github.com/mylux/cakephp.git","ssh_url":"git@github.com:mylux/cakephp.git","clone_url":"https://github.com/mylux/cakephp.git","svn_url":"https://github.com/mylux/cakephp","homepage":"http://cakephp.org","size":87650,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"cakephp:master","ref":"master","sha":"ef79994219ea15f9b22fbd2537638c738d5ddc3f","user":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"repo":{"id":656494,"name":"cakephp","full_name":"cakephp/cakephp","owner":{"login":"cakephp","id":23666,"avatar_url":"https://avatars.githubusercontent.com/u/23666?v=3","gravatar_id":"","url":"https://api.github.com/users/cakephp","html_url":"https://github.com/cakephp","followers_url":"https://api.github.com/users/cakephp/followers","following_url":"https://api.github.com/users/cakephp/following{/other_user}","gists_url":"https://api.github.com/users/cakephp/gists{/gist_id}","starred_url":"https://api.github.com/users/cakephp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cakephp/subscriptions","organizations_url":"https://api.github.com/users/cakephp/orgs","repos_url":"https://api.github.com/users/cakephp/repos","events_url":"https://api.github.com/users/cakephp/events{/privacy}","received_events_url":"https://api.github.com/users/cakephp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cakephp/cakephp","description":"CakePHP: The Rapid Development Framework for PHP - Official Repository","fork":false,"url":"https://api.github.com/repos/cakephp/cakephp","forks_url":"https://api.github.com/repos/cakephp/cakephp/forks","keys_url":"https://api.github.com/repos/cakephp/cakephp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cakephp/cakephp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cakephp/cakephp/teams","hooks_url":"https://api.github.com/repos/cakephp/cakephp/hooks","issue_events_url":"https://api.github.com/repos/cakephp/cakephp/issues/events{/number}","events_url":"https://api.github.com/repos/cakephp/cakephp/events","assignees_url":"https://api.github.com/repos/cakephp/cakephp/assignees{/user}","branches_url":"https://api.github.com/repos/cakephp/cakephp/branches{/branch}","tags_url":"https://api.github.com/repos/cakephp/cakephp/tags","blobs_url":"https://api.github.com/repos/cakephp/cakephp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cakephp/cakephp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cakephp/cakephp/git/refs{/sha}","trees_url":"https://api.github.com/repos/cakephp/cakephp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cakephp/cakephp/statuses/{sha}","languages_url":"https://api.github.com/repos/cakephp/cakephp/languages","stargazers_url":"https://api.github.com/repos/cakephp/cakephp/stargazers","contributors_url":"https://api.github.com/repos/cakephp/cakephp/contributors","subscribers_url":"https://api.github.com/repos/cakephp/cakephp/subscribers","subscription_url":"https://api.github.com/repos/cakephp/cakephp/subscription","commits_url":"https://api.github.com/repos/cakephp/cakephp/commits{/sha}","git_commits_url":"https://api.github.com/repos/cakephp/cakephp/git/commits{/sha}","comments_url":"https://api.github.com/repos/cakephp/cakephp/comments{/number}","issue_comment_url":"https://api.github.com/repos/cakephp/cakephp/issues/comments{/number}","contents_url":"https://api.github.com/repos/cakephp/cakephp/contents/{+path}","compare_url":"https://api.github.com/repos/cakephp/cakephp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cakephp/cakephp/merges","archive_url":"https://api.github.com/repos/cakephp/cakephp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cakephp/cakephp/downloads","issues_url":"https://api.github.com/repos/cakephp/cakephp/issues{/number}","pulls_url":"https://api.github.com/repos/cakephp/cakephp/pulls{/number}","milestones_url":"https://api.github.com/repos/cakephp/cakephp/milestones{/number}","notifications_url":"https://api.github.com/repos/cakephp/cakephp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cakephp/cakephp/labels{/name}","releases_url":"https://api.github.com/repos/cakephp/cakephp/releases{/id}","created_at":"2010-05-08T14:38:22Z","updated_at":"2015-10-04T22:43:19Z","pushed_at":"2015-10-04T19:51:56Z","git_url":"git://github.com/cakephp/cakephp.git","ssh_url":"git@github.com:cakephp/cakephp.git","clone_url":"https://github.com/cakephp/cakephp.git","svn_url":"https://github.com/cakephp/cakephp","homepage":"http://cakephp.org","size":185682,"stargazers_count":6087,"watchers_count":6087,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2762,"mirror_url":null,"open_issues_count":146,"forks":2762,"open_issues":146,"watchers":6087,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7477"},"html":{"href":"https://github.com/cakephp/cakephp/pull/7477"},"issue":{"href":"https://api.github.com/repos/cakephp/cakephp/issues/7477"},"comments":{"href":"https://api.github.com/repos/cakephp/cakephp/issues/7477/comments"},"review_comments":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7477/comments"},"review_comment":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cakephp/cakephp/pulls/7477/commits"},"statuses":{"href":"https://api.github.com/repos/cakephp/cakephp/statuses/6ba93e9869f6e99fe001ed2fa0dd8eaf3bcc069b"}}}}