You can take example in my old laravel-commentable package.
How to test a package that uses another packages db tables and classes
Im working on a package that enhances the https://github.com/lucadegasperi/oauth2-server-laravel package with a few models for clients, scopes and add a few traits.
The package will allow the oauth scopes to be used and managed within the app and not just over oauth.
so things like this can be done:
$user = User::find(1);
$scope = Scope::firstOrCreate([
'id' => 'read_users',
'description' => 'allows reading of users'
]);
$user->scopes()->attach($scope);
//or
$user->addScope($scope);
//and things like
$user->hasScope($scope);
$user->hasScopes([$scopes]);
This is all possible with the package already but not via eloquent.
Now how would i test this with things like:
$this->seeInDatabase([......]);
Ive been doing test cases for packages fine so far, but only really needed to test functionality on instances without needing to access a database, or another packages tables.
Its easy via an actual application that uses the packages as the db and test cases are all setup for this, but im getting stuck on how i would do this from my package independant of an application?
Please or to participate in this conversation.