%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/geotechnics/api/vendor/spatie/laravel-permission/docs/advanced-usage/
Upload File :
Create Path :
Current File : /var/www/html/geotechnics/api/vendor/spatie/laravel-permission/docs/advanced-usage/unit-testing.md

---
title: Unit testing
weight: 1
---

In your application's tests, if you are not seeding roles and permissions as part of your test `setUp()` then you may run into a chicken/egg situation where roles and permissions aren't registered with the gate (because your tests create them after that gate registration is done). Working around this is simple: In your tests simply add a `setUp()` instruction to re-register the permissions, like this:

```php
    public function setUp()
    {
        // first include all the normal setUp operations
        parent::setUp();

        // now re-register all the roles and permissions
        $this->app->make(\Spatie\Permission\PermissionRegistrar::class)->registerPermissions();
    }
```


Zerion Mini Shell 1.0