PHPackages                             ronappleton/spatie-laravel-permission-mock - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. ronappleton/spatie-laravel-permission-mock

ActiveLibrary[Testing &amp; Quality](/categories/testing)

ronappleton/spatie-laravel-permission-mock
==========================================

Simple package to allow testing of packages with users that have permissions.

0171PHP

Since May 19Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ronappleton/spatie-laravel-permission-mock)[ Packagist](https://packagist.org/packages/ronappleton/spatie-laravel-permission-mock)[ RSS](/packages/ronappleton-spatie-laravel-permission-mock/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

Permission Mock
===============

[](#permission-mock)

Introduction
------------

[](#introduction)

Simple package with a simple premise, to mock permissions in a simple way for feature testing.

If you are wanting to develop a package for laravel that uses permissions and policies, you may want to test that your package works as expected. This package allows you to mock permissions in a simple way.

I found this useful when building a monolithic application using packages that had permissions and policies.

I wanted to keep my tests simple and not have to worry about setting up permissions and policies in my tests. And I wanted to be able to define the permissions in my packages.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require --dev ronappleton/spatie-laravel-permission-mock
```

Usage
-----

[](#usage)

If using normal integer id fields for your models, you can use the following in your tests:

- User
- Role
- Permission

If wanting to use uuids for your models, you can use the following in your tests:

- UserUuid
- RoleUuid
- PermissionUuid

For Uuids you will need to set the following in your tests:

```
use DatabaseMigrations;

protected function setUp(): void
{
    parent::setUp();

    config()->set('mock-permissions.uuids', true);

    $this->artisan('migrate:fresh', ['--database' => 'testing']);
}
```

You can then create permissions and roles in your tests, and assign them to users.

Conclusion
----------

[](#conclusion)

You can now develop a package using permissions and policies and test them knowing your test will cover want you want within the package and you can rely on your code working when your package is pulled into your application.

Note
----

[](#note)

If you want to add whatever to this package simply PR it and ill add it in, please remember tests.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e2afdd94a6f21a4ec2c5df569b80c1d47d6f5d0428f866f55c4bc117856b58b?d=identicon)[Ron Appleton](/maintainers/Ron%20Appleton)

---

Top Contributors

[![ronappleton](https://avatars.githubusercontent.com/u/3792420?v=4)](https://github.com/ronappleton "ronappleton (2 commits)")

### Embed Badge

![Health badge](/badges/ronappleton-spatie-laravel-permission-mock/health.svg)

```
[![Health](https://phpackages.com/badges/ronappleton-spatie-laravel-permission-mock/health.svg)](https://phpackages.com/packages/ronappleton-spatie-laravel-permission-mock)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
