{"action":"created","issue":{"url":"https://api.github.com/repos/HipsterJazzbo/Landlord/issues/49","repository_url":"https://api.github.com/repos/HipsterJazzbo/Landlord","labels_url":"https://api.github.com/repos/HipsterJazzbo/Landlord/issues/49/labels{/name}","comments_url":"https://api.github.com/repos/HipsterJazzbo/Landlord/issues/49/comments","events_url":"https://api.github.com/repos/HipsterJazzbo/Landlord/issues/49/events","html_url":"https://github.com/HipsterJazzbo/Landlord/issues/49","id":195080635,"number":49,"title":"Issue on tests","user":{"login":"mariomka","id":1822472,"avatar_url":"https://avatars.githubusercontent.com/u/1822472?v=3","gravatar_id":"","url":"https://api.github.com/users/mariomka","html_url":"https://github.com/mariomka","followers_url":"https://api.github.com/users/mariomka/followers","following_url":"https://api.github.com/users/mariomka/following{/other_user}","gists_url":"https://api.github.com/users/mariomka/gists{/gist_id}","starred_url":"https://api.github.com/users/mariomka/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mariomka/subscriptions","organizations_url":"https://api.github.com/users/mariomka/orgs","repos_url":"https://api.github.com/users/mariomka/repos","events_url":"https://api.github.com/users/mariomka/events{/privacy}","received_events_url":"https://api.github.com/users/mariomka/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-12T20:44:27Z","updated_at":"2016-12-26T23:17:44Z","closed_at":null,"body":"I'm trying to test features that use Landlord but the scope is not applied unless I call ``$landlord->applyTenantScopes(new Model);`` manually before query.\r\n\r\nSimple failed test example:\r\n```php\r\n/** @test **/\r\nfunction scopeTest()\r\n{\r\n    $user = User::create([\r\n        'name' => 'User name',\r\n        'email' =>'test@domain',\r\n        'password' => bcrypt('secret'),\r\n        'remember_token' => str_random(10),\r\n    ]);\r\n\r\n    Landlord::addTenant($user);\r\n\r\n    Account::create([\r\n        'name' => 'Account name',\r\n        'user_id' => $user->id,\r\n    ]);\r\n\r\n    Account::create([\r\n        'name' => 'Account name',\r\n    ]);\r\n\r\n    $count = Account::count();\r\n\r\n    $this->assertEquals(1, $count);\r\n}\r\n```\r\n\r\nI can fix easy the test calling ``applyTenantScopes()`` but I can't fix real tests that are using controllers, repositories..."},"comment":{"url":"https://api.github.com/repos/HipsterJazzbo/Landlord/issues/comments/269248270","html_url":"https://github.com/HipsterJazzbo/Landlord/issues/49#issuecomment-269248270","issue_url":"https://api.github.com/repos/HipsterJazzbo/Landlord/issues/49","id":269248270,"user":{"login":"fgilio","id":6857732,"avatar_url":"https://avatars.githubusercontent.com/u/6857732?v=3","gravatar_id":"","url":"https://api.github.com/users/fgilio","html_url":"https://github.com/fgilio","followers_url":"https://api.github.com/users/fgilio/followers","following_url":"https://api.github.com/users/fgilio/following{/other_user}","gists_url":"https://api.github.com/users/fgilio/gists{/gist_id}","starred_url":"https://api.github.com/users/fgilio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fgilio/subscriptions","organizations_url":"https://api.github.com/users/fgilio/orgs","repos_url":"https://api.github.com/users/fgilio/repos","events_url":"https://api.github.com/users/fgilio/events{/privacy}","received_events_url":"https://api.github.com/users/fgilio/received_events","type":"User","site_admin":false},"created_at":"2016-12-26T23:17:44Z","updated_at":"2016-12-26T23:17:44Z","body":"Hi @mariomka!\r\nI'm having this same issue. Did you manage to solve it?\r\nAlso, how are you using ```$landlord->applyTenantScopes(new Model);``` ?\r\n\r\nThanks!"}}
{"actor":{"display_login":"fgilio"}}