{"action":"created","comment":{"url":"https://api.github.com/repos/sellerlabs/beakers/pulls/comments/72691349","id":72691349,"diff_hunk":"@@ -176,4 +177,31 @@ public function testRelations($property, $type, $other)\n                 break;\n         }\n     }\n+\n+\n+    /**\n+     * Tests relationship are connected to correct tables through correct keys.\n+     *\n+     * @param string $property\n+     * @param string $type\n+     * @param string $other\n+     *\n+     * @dataProvider relationsProvider\n+     */\n+    public function testRelationCanLoad($property, $type, $other)\n+    {\n+        $model = $this->make();\n+\n+        switch ($type) {\n+            case RelationType::HAS_ONE:\n+            case RelationType::BELONGS_TO:\n+                $this->assertTrue(is_null($model->$property));","path":"src/SellerLabs/Beakers/Traits/ModelTestTrait.php","position":30,"original_position":30,"commit_id":"bb914586ecb06fce1bb258e0c5b57068c05716af","original_commit_id":"bb914586ecb06fce1bb258e0c5b57068c05716af","user":{"login":"MarkVaughn","id":39970,"avatar_url":"https://avatars.githubusercontent.com/u/39970?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkVaughn","html_url":"https://github.com/MarkVaughn","followers_url":"https://api.github.com/users/MarkVaughn/followers","following_url":"https://api.github.com/users/MarkVaughn/following{/other_user}","gists_url":"https://api.github.com/users/MarkVaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkVaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkVaughn/subscriptions","organizations_url":"https://api.github.com/users/MarkVaughn/orgs","repos_url":"https://api.github.com/users/MarkVaughn/repos","events_url":"https://api.github.com/users/MarkVaughn/events{/privacy}","received_events_url":"https://api.github.com/users/MarkVaughn/received_events","type":"User","site_admin":false},"body":"no, because we are generating an empty model with no relationships. Triggering `$model->$property`  stars a mysql query and if the tables/keys are wrong and exception would be thrown. If the query is valid we expect 0 results meaning instead of an object we are getting null","created_at":"2016-07-28T19:58:18Z","updated_at":"2016-07-28T19:58:18Z","html_url":"https://github.com/sellerlabs/beakers/pull/4#discussion_r72691349","pull_request_url":"https://api.github.com/repos/sellerlabs/beakers/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/sellerlabs/beakers/pulls/comments/72691349"},"html":{"href":"https://github.com/sellerlabs/beakers/pull/4#discussion_r72691349"},"pull_request":{"href":"https://api.github.com/repos/sellerlabs/beakers/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/sellerlabs/beakers/pulls/4","id":79214879,"html_url":"https://github.com/sellerlabs/beakers/pull/4","diff_url":"https://github.com/sellerlabs/beakers/pull/4.diff","patch_url":"https://github.com/sellerlabs/beakers/pull/4.patch","issue_url":"https://api.github.com/repos/sellerlabs/beakers/issues/4","number":4,"state":"open","locked":false,"title":"Tests that when loading a relationship exception is not thrown.","user":{"login":"MarkVaughn","id":39970,"avatar_url":"https://avatars.githubusercontent.com/u/39970?v=3","gravatar_id":"","url":"https://api.github.com/users/MarkVaughn","html_url":"https://github.com/MarkVaughn","followers_url":"https://api.github.com/users/MarkVaughn/followers","following_url":"https://api.github.com/users/MarkVaughn/following{/other_user}","gists_url":"https://api.github.com/users/MarkVaughn/gists{/gist_id}","starred_url":"https://api.github.com/users/MarkVaughn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MarkVaughn/subscriptions","organizations_url":"https://api.github.com/users/MarkVaughn/orgs","repos_url":"https://api.github.com/users/MarkVaughn/repos","events_url":"https://api.github.com/users/MarkVaughn/events{/privacy}","received_events_url":"https://api.github.com/users/MarkVaughn/received_events","type":"User","site_admin":false},"body":"There are cases where the type of relationships are properly but we didn't test if the database resolves them properly. This catches issues like such\r\n\r\n```\r\n1) Tests\\SellerLabs\\Snagshout\\Products\\ProductTest::testRelationCanLoad with data set #1 ('campaigns', 'belongsToMany', 'SellerLabs\\Snagshout\\Campaign...mpaign')\r\nIlluminate\\Database\\QueryException: SQLSTATE[HY000]: General error: 1 no such table: campaign_product (SQL: select \"campaigns\".*, \"campaign_product\".\"product_id\" as \"pivot_product_id\", \"campaign_product\".\"campaign_id\" as \"pivot_campaign_id\" from \"campaigns\" inner join \"campaign_product\" on \"campaigns\".\"id\" = \"campaign_product\".\"campaign_id\" where \"campaigns\".\"deleted_at\" is null and \"campaign_product\".\"product_id\" is null)\r\n```","created_at":"2016-07-28T15:17:22Z","updated_at":"2016-07-28T19:58:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"767a576fbe89896e53487a86a629718cedc37fbf","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sellerlabs/beakers/pulls/4/commits","review_comments_url":"https://api.github.com/repos/sellerlabs/beakers/pulls/4/comments","review_comment_url":"https://api.github.com/repos/sellerlabs/beakers/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sellerlabs/beakers/issues/4/comments","statuses_url":"https://api.github.com/repos/sellerlabs/beakers/statuses/bb914586ecb06fce1bb258e0c5b57068c05716af","head":{"label":"sellerlabs:mark/model-test-load-relations","ref":"mark/model-test-load-relations","sha":"bb914586ecb06fce1bb258e0c5b57068c05716af","user":{"login":"sellerlabs","id":11278378,"avatar_url":"https://avatars.githubusercontent.com/u/11278378?v=3","gravatar_id":"","url":"https://api.github.com/users/sellerlabs","html_url":"https://github.com/sellerlabs","followers_url":"https://api.github.com/users/sellerlabs/followers","following_url":"https://api.github.com/users/sellerlabs/following{/other_user}","gists_url":"https://api.github.com/users/sellerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/sellerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellerlabs/subscriptions","organizations_url":"https://api.github.com/users/sellerlabs/orgs","repos_url":"https://api.github.com/users/sellerlabs/repos","events_url":"https://api.github.com/users/sellerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/sellerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":49454572,"name":"beakers","full_name":"sellerlabs/beakers","owner":{"login":"sellerlabs","id":11278378,"avatar_url":"https://avatars.githubusercontent.com/u/11278378?v=3","gravatar_id":"","url":"https://api.github.com/users/sellerlabs","html_url":"https://github.com/sellerlabs","followers_url":"https://api.github.com/users/sellerlabs/followers","following_url":"https://api.github.com/users/sellerlabs/following{/other_user}","gists_url":"https://api.github.com/users/sellerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/sellerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellerlabs/subscriptions","organizations_url":"https://api.github.com/users/sellerlabs/orgs","repos_url":"https://api.github.com/users/sellerlabs/repos","events_url":"https://api.github.com/users/sellerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/sellerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sellerlabs/beakers","description":"Interfaces and abstracts to share amongst Seller Labs products","fork":false,"url":"https://api.github.com/repos/sellerlabs/beakers","forks_url":"https://api.github.com/repos/sellerlabs/beakers/forks","keys_url":"https://api.github.com/repos/sellerlabs/beakers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sellerlabs/beakers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sellerlabs/beakers/teams","hooks_url":"https://api.github.com/repos/sellerlabs/beakers/hooks","issue_events_url":"https://api.github.com/repos/sellerlabs/beakers/issues/events{/number}","events_url":"https://api.github.com/repos/sellerlabs/beakers/events","assignees_url":"https://api.github.com/repos/sellerlabs/beakers/assignees{/user}","branches_url":"https://api.github.com/repos/sellerlabs/beakers/branches{/branch}","tags_url":"https://api.github.com/repos/sellerlabs/beakers/tags","blobs_url":"https://api.github.com/repos/sellerlabs/beakers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sellerlabs/beakers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sellerlabs/beakers/git/refs{/sha}","trees_url":"https://api.github.com/repos/sellerlabs/beakers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sellerlabs/beakers/statuses/{sha}","languages_url":"https://api.github.com/repos/sellerlabs/beakers/languages","stargazers_url":"https://api.github.com/repos/sellerlabs/beakers/stargazers","contributors_url":"https://api.github.com/repos/sellerlabs/beakers/contributors","subscribers_url":"https://api.github.com/repos/sellerlabs/beakers/subscribers","subscription_url":"https://api.github.com/repos/sellerlabs/beakers/subscription","commits_url":"https://api.github.com/repos/sellerlabs/beakers/commits{/sha}","git_commits_url":"https://api.github.com/repos/sellerlabs/beakers/git/commits{/sha}","comments_url":"https://api.github.com/repos/sellerlabs/beakers/comments{/number}","issue_comment_url":"https://api.github.com/repos/sellerlabs/beakers/issues/comments{/number}","contents_url":"https://api.github.com/repos/sellerlabs/beakers/contents/{+path}","compare_url":"https://api.github.com/repos/sellerlabs/beakers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sellerlabs/beakers/merges","archive_url":"https://api.github.com/repos/sellerlabs/beakers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sellerlabs/beakers/downloads","issues_url":"https://api.github.com/repos/sellerlabs/beakers/issues{/number}","pulls_url":"https://api.github.com/repos/sellerlabs/beakers/pulls{/number}","milestones_url":"https://api.github.com/repos/sellerlabs/beakers/milestones{/number}","notifications_url":"https://api.github.com/repos/sellerlabs/beakers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sellerlabs/beakers/labels{/name}","releases_url":"https://api.github.com/repos/sellerlabs/beakers/releases{/id}","deployments_url":"https://api.github.com/repos/sellerlabs/beakers/deployments","created_at":"2016-01-11T21:09:30Z","updated_at":"2016-01-12T17:24:28Z","pushed_at":"2016-07-28T15:17:22Z","git_url":"git://github.com/sellerlabs/beakers.git","ssh_url":"git@github.com:sellerlabs/beakers.git","clone_url":"https://github.com/sellerlabs/beakers.git","svn_url":"https://github.com/sellerlabs/beakers","homepage":null,"size":36,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"base":{"label":"sellerlabs:master","ref":"master","sha":"8118320dba6a465c6b6eaa4793b06ae35fa6dbdd","user":{"login":"sellerlabs","id":11278378,"avatar_url":"https://avatars.githubusercontent.com/u/11278378?v=3","gravatar_id":"","url":"https://api.github.com/users/sellerlabs","html_url":"https://github.com/sellerlabs","followers_url":"https://api.github.com/users/sellerlabs/followers","following_url":"https://api.github.com/users/sellerlabs/following{/other_user}","gists_url":"https://api.github.com/users/sellerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/sellerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellerlabs/subscriptions","organizations_url":"https://api.github.com/users/sellerlabs/orgs","repos_url":"https://api.github.com/users/sellerlabs/repos","events_url":"https://api.github.com/users/sellerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/sellerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":49454572,"name":"beakers","full_name":"sellerlabs/beakers","owner":{"login":"sellerlabs","id":11278378,"avatar_url":"https://avatars.githubusercontent.com/u/11278378?v=3","gravatar_id":"","url":"https://api.github.com/users/sellerlabs","html_url":"https://github.com/sellerlabs","followers_url":"https://api.github.com/users/sellerlabs/followers","following_url":"https://api.github.com/users/sellerlabs/following{/other_user}","gists_url":"https://api.github.com/users/sellerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/sellerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sellerlabs/subscriptions","organizations_url":"https://api.github.com/users/sellerlabs/orgs","repos_url":"https://api.github.com/users/sellerlabs/repos","events_url":"https://api.github.com/users/sellerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/sellerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sellerlabs/beakers","description":"Interfaces and abstracts to share amongst Seller Labs products","fork":false,"url":"https://api.github.com/repos/sellerlabs/beakers","forks_url":"https://api.github.com/repos/sellerlabs/beakers/forks","keys_url":"https://api.github.com/repos/sellerlabs/beakers/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sellerlabs/beakers/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sellerlabs/beakers/teams","hooks_url":"https://api.github.com/repos/sellerlabs/beakers/hooks","issue_events_url":"https://api.github.com/repos/sellerlabs/beakers/issues/events{/number}","events_url":"https://api.github.com/repos/sellerlabs/beakers/events","assignees_url":"https://api.github.com/repos/sellerlabs/beakers/assignees{/user}","branches_url":"https://api.github.com/repos/sellerlabs/beakers/branches{/branch}","tags_url":"https://api.github.com/repos/sellerlabs/beakers/tags","blobs_url":"https://api.github.com/repos/sellerlabs/beakers/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sellerlabs/beakers/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sellerlabs/beakers/git/refs{/sha}","trees_url":"https://api.github.com/repos/sellerlabs/beakers/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sellerlabs/beakers/statuses/{sha}","languages_url":"https://api.github.com/repos/sellerlabs/beakers/languages","stargazers_url":"https://api.github.com/repos/sellerlabs/beakers/stargazers","contributors_url":"https://api.github.com/repos/sellerlabs/beakers/contributors","subscribers_url":"https://api.github.com/repos/sellerlabs/beakers/subscribers","subscription_url":"https://api.github.com/repos/sellerlabs/beakers/subscription","commits_url":"https://api.github.com/repos/sellerlabs/beakers/commits{/sha}","git_commits_url":"https://api.github.com/repos/sellerlabs/beakers/git/commits{/sha}","comments_url":"https://api.github.com/repos/sellerlabs/beakers/comments{/number}","issue_comment_url":"https://api.github.com/repos/sellerlabs/beakers/issues/comments{/number}","contents_url":"https://api.github.com/repos/sellerlabs/beakers/contents/{+path}","compare_url":"https://api.github.com/repos/sellerlabs/beakers/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sellerlabs/beakers/merges","archive_url":"https://api.github.com/repos/sellerlabs/beakers/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sellerlabs/beakers/downloads","issues_url":"https://api.github.com/repos/sellerlabs/beakers/issues{/number}","pulls_url":"https://api.github.com/repos/sellerlabs/beakers/pulls{/number}","milestones_url":"https://api.github.com/repos/sellerlabs/beakers/milestones{/number}","notifications_url":"https://api.github.com/repos/sellerlabs/beakers/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sellerlabs/beakers/labels{/name}","releases_url":"https://api.github.com/repos/sellerlabs/beakers/releases{/id}","deployments_url":"https://api.github.com/repos/sellerlabs/beakers/deployments","created_at":"2016-01-11T21:09:30Z","updated_at":"2016-01-12T17:24:28Z","pushed_at":"2016-07-28T15:17:22Z","git_url":"git://github.com/sellerlabs/beakers.git","ssh_url":"git@github.com:sellerlabs/beakers.git","clone_url":"https://github.com/sellerlabs/beakers.git","svn_url":"https://github.com/sellerlabs/beakers","homepage":null,"size":36,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sellerlabs/beakers/pulls/4"},"html":{"href":"https://github.com/sellerlabs/beakers/pull/4"},"issue":{"href":"https://api.github.com/repos/sellerlabs/beakers/issues/4"},"comments":{"href":"https://api.github.com/repos/sellerlabs/beakers/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/sellerlabs/beakers/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/sellerlabs/beakers/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sellerlabs/beakers/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/sellerlabs/beakers/statuses/bb914586ecb06fce1bb258e0c5b57068c05716af"}}}}
{"actor":{"display_login":"MarkVaughn"}}