PHPackages                             andizzle/zapper - 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. andizzle/zapper

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

andizzle/zapper
===============

A test package that allows you do db envolved testing properly.

27331PHP

Since Nov 10Pushed 12y ago1 watchersCompare

[ Source](https://github.com/andizzle/zapper)[ Packagist](https://packagist.org/packages/andizzle/zapper)[ RSS](/packages/andizzle-zapper/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (4)Used By (0)

[![Build Status](https://camo.githubusercontent.com/6f4bf19f2622040a1972ef5a092ee3c60841fe69a424bbe2c2cb838675274c40/68747470733a2f2f7472617669732d63692e6f72672f616e64697a7a6c652f5a61707065722e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/andizzle/Zapper)

Zapper - Laravel Test Builder
=============================

[](#zapper---laravel-test-builder)

This is an attempt to make your test process easier when a db is envolved.

What's missing in the current test process?
-------------------------------------------

[](#whats-missing-in-the-current-test-process)

In Laravel 4, you write your tests, put stuff in setUp() and tierDown(), then run phpunit. Which is all fine except that when there is a db involved it's using your dev/staging db. Your test cases pickup existing data and blah blah blah... you know where I'm going.

What can you expect from Zapper?
--------------------------------

[](#what-can-you-expect-from-zapper)

So all zapper does, is gives you an isolated test db where all your test queries can be executed. It builds the test db and drops it afterwards, and ohhh, it does migration (including your packages) and seeding for you.

How to use it?
--------------

[](#how-to-use-it)

Start by adding zapper to your composer.json

```
"require": {
    "andizzle/zapper": "dev-master"
}

```

After composer updates you can start writing your tests:

```

```

To run your tests, run zapper's run command in your laravel project:

```
$ php artisan zapper:run

```

Furthermore, you can specify the test case you want run, without any @group or @filter in your test comments.

```
$ php artisan zapper:run SUITE
$ php artisan zapper:run SUITE.CLASS
$ php artisan zapper:run SUITE.CLASS.METHOD

```

You can still pass any phpunit arguments and parameters as you used to.

TestCase, TransactionTestCase and Others
----------------------------------------

[](#testcase-transactiontestcase-and-others)

Zapper offers two types of testcases for you, testcase and transaction testcase.

They all do the same thing except test case does a rollback of your db, and Transaction truncates and reseeds at the beginning of each testcase.

If your tests requires db transactions then you can use TransactionTestCase, obviously...

Zapper actually reorders your tests so all testcases run before transaction testcases that may alter the database without restoring it to its original state.

Zapper also runs other tests after its TestCase and TransactionTestCase.

Some helper commands
--------------------

[](#some-helper-commands)

There are some commands that zapper uses. They are offered to you as well so you can do what you think fits.

```
zapper:build_db        Create test DB.
zapper:drop_db         Drop the test DB.
zapper:migrate         Migrate schemas.
zapper:run             Run tests.
zapper:truncate        Truncate certain tables.

```

PR if you think it's shitty and feel like improving it.
-------------------------------------------------------

[](#pr-if-you-think-its-shitty-and-feel-like-improving-it)

```
Copyright (C) 2013  Andy Zhang

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see .

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.4% 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/3c3ffcee1e5a974b317b8035277aebe564e4fdbda0222dfed75501ddaa197cb6?d=identicon)[andizzle](/maintainers/andizzle)

---

Top Contributors

[![andizzle](https://avatars.githubusercontent.com/u/864065?v=4)](https://github.com/andizzle "andizzle (64 commits)")[![ossrobot](https://avatars.githubusercontent.com/u/9329082?v=4)](https://github.com/ossrobot "ossrobot (6 commits)")

### Embed Badge

![Health badge](/badges/andizzle-zapper/health.svg)

```
[![Health](https://phpackages.com/badges/andizzle-zapper/health.svg)](https://phpackages.com/packages/andizzle-zapper)
```

###  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)
