You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run unit tests without a database (which isn't unreasonable), I randomly get exceptions when Sentinel fails to find the activations and permissions database tables - which is expected, since there is no database in the first place.
Is there any recommended way to do what I want, that isn't "use a database for testing"?
The boot() method gets called when the application gets booted, so I don't know if there's a way around it - perhaps if the garbage collection code is moved to the closure within SentinelServiceProvider::registerSentinel()? Then garbage collection would only kick in when an actual Sentinel instance is requested somewhere - which is not something I'll ever be doing in my app's unit tests - I might only have mocks of the Sentinel class there, but since this package already has comprehensive tests, I don't want to test Sentinel itself in my app's tests.
Something like this, basically:
protectedfunctionregisterSentinel()
{
$that = $this;
$this->app['sentinel'] = $this->app->share(function($app) use ($that)
{
$that->garbageCollect();
/* rest of the service provider */
}
}
Of course, the call to $this->garbageCollect() within the service provider's boot() method would be removed.
Another solution, which seems to work for me is to have an environment-specific Sentinel configuration file. In other words, I have the file app/config/packages/cartalyst/sentinel/testing/config.php with the following contents:
Am I wrong in feeling that this is a little too hacky? Because, basically, it's like saying "in testing, you have a 0% chance of triggering garbage collection", as opposed to "in testing, don't ever try to perform garbage collection". Or maybe this is okay, and I'm just being obtuse.
Thanks in advance for any comments on this!
The text was updated successfully, but these errors were encountered:
So I'm using Laravel 4.2 with Sentinel 1.0.5, but I can see the same problematic code in the latest version as well, and it's this line in particular:
sentinel/src/Laravel/SentinelServiceProvider.php
Line 46 in 944a69c
When I run unit tests without a database (which isn't unreasonable), I randomly get exceptions when Sentinel fails to find the
activations
andpermissions
database tables - which is expected, since there is no database in the first place.Is there any recommended way to do what I want, that isn't "use a database for testing"?
The
boot()
method gets called when the application gets booted, so I don't know if there's a way around it - perhaps if the garbage collection code is moved to the closure withinSentinelServiceProvider::registerSentinel()
? Then garbage collection would only kick in when an actual Sentinel instance is requested somewhere - which is not something I'll ever be doing in my app's unit tests - I might only have mocks of the Sentinel class there, but since this package already has comprehensive tests, I don't want to test Sentinel itself in my app's tests.Something like this, basically:
Of course, the call to
$this->garbageCollect()
within the service provider'sboot()
method would be removed.Another solution, which seems to work for me is to have an environment-specific Sentinel configuration file. In other words, I have the file
app/config/packages/cartalyst/sentinel/testing/config.php
with the following contents:Am I wrong in feeling that this is a little too hacky? Because, basically, it's like saying "in testing, you have a 0% chance of triggering garbage collection", as opposed to "in testing, don't ever try to perform garbage collection". Or maybe this is okay, and I'm just being obtuse.
Thanks in advance for any comments on this!
The text was updated successfully, but these errors were encountered: