toBeTrue() ->and(Manager::enabled('media'))->toBeTrue() ->and(Manager::enabled('reviews'))->toBeFalse(); }); it('adds no routes, tables or permissions for a module that is off', function () { expect(Route::has('manager.reviews.index'))->toBeFalse() ->and(Schema::hasTable('manager_reviews'))->toBeFalse() ->and(Manager::permissions())->not->toHaveKey('reviews.manage') ->and(collect(Manager::navigation())->pluck('label'))->not->toContain('Reviews'); }); it('adds all of it for a module that is on', function () { expect(Route::has('manager.posts.index'))->toBeTrue() ->and(Schema::hasTable('manager_posts'))->toBeTrue() ->and(Manager::permissions())->toHaveKey('posts.publish'); }); it('lets a super admin in and keeps others out without the permission', function () { $admin = User::create(['name' => 'a', 'email' => 'a@x.nl', 'password' => 'x', 'manager_super_admin' => true]); $other = User::create(['name' => 'b', 'email' => 'b@x.nl', 'password' => 'x']); $this->actingAs($admin)->getJson('/manager/posts')->assertOk(); $this->actingAs($other)->getJson('/manager/posts')->assertForbidden(); }); it('gives a group member the permissions of the group', function () { $user = User::create(['name' => 'c', 'email' => 'c@x.nl', 'password' => 'x']); $group = Group::create(['name' => 'Editors', 'permissions' => ['posts.view']]); $user->managerGroups()->attach($group); $this->actingAs($user)->getJson('/manager/posts')->assertOk(); $this->actingAs($user)->getJson('/manager/pages')->assertForbidden(); });