PHPackages                             raphhh/pumpkin - 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. raphhh/pumpkin

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

raphhh/pumpkin
==============

A helper for mocks and database resources in PHPUnit

2.0.0(10y ago)210MITPHPPHP &gt;=5.4

Since Jun 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Raphhh/pumpkin)[ Packagist](https://packagist.org/packages/raphhh/pumpkin)[ Docs](http://labs.raphaellefebvre.be/pumpkin)[ RSS](/packages/raphhh-pumpkin/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

README
======

[](#readme)

[![Latest Stable Version](https://camo.githubusercontent.com/d309fe61e4c5c8216fa842d9d1fe4c3d6a697dfabb1b08f9019999d810b04bf4/68747470733a2f2f706f7365722e707567782e6f72672f7261706868682f70756d706b696e2f762f737461626c652e737667)](https://packagist.org/packages/raphhh/pumpkin)[![Build Status](https://camo.githubusercontent.com/29cbe19921ffa7a47bb6f8a285f4acb9bf5c4475a6dfef430a83dc283a74d5d6/68747470733a2f2f7472617669732d63692e6f72672f5261706868682f70756d706b696e2e706e67)](https://travis-ci.org/Raphhh/pumpkin)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/29cc741c01dcb9a2d8db860add7f2afda6a5b49faf1c4451d520ebe815d394e1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5261706868682f70756d706b696e2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Raphhh/pumpkin/)[![Code Coverage](https://camo.githubusercontent.com/ad20b629d7b521de6b3fe83e74c82abb8216ba56667013de8c4dde7418b0445c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5261706868682f70756d706b696e2f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Raphhh/pumpkin/)

What is Pumpkin?
----------------

[](#what-is-pumpkin)

Pumpkin helps you to organize the storage of your mocks for PHPUnit. It gives mocks objects and database resources when you execute a test.

How to start?
-------------

[](#how-to-start)

You just have to add the Pumpkin package in your composer.json and update your project.

```
$ composer require raphhh/pumpkin

```

What can I do?
--------------

[](#what-can-i-do)

### Get the current test

[](#get-the-current-test)

Usually, when you use PHPUnit, you create a new test class extending `\PHPUnit_Framework_TestCase`. Instead, with Pumpkin, you have to extend `\Pumpkin\TestCase`.

`\Pumpkin\TestCase` extends `\PHPUnit_Framework_TestCase`, so you have the same interface as if you use PHPUnit.

But you can also know the current test with `\Pumpkin\TestCase::getTest(`). You receive a `\Pumpkin\Test\Test` object which reflects the current method of the test.

The current test is the method executed by PHPUnit and containing your assertions. Typically, this is a test\* method.

For example

```
class FooTest extends Pumpkin\TestCase
{

    function testA(){
        $this->getTest()->getReflectedTestMethod()->getName(); //FooTest::testA
    }

    function testB(){
        $this->getTest()->getReflectedTestMethod()->getName(); //FooTest::testB
    }
}
```

With this method you can reflected the method of the executed test, retrieve annotations, ... anything!

Note that if you do not want to extend `\Pumpkin\TestCase`, you can also directly extend `\PHPUnit_Framework_TestCase` and use the trait `\Pumpkin\Test\TestCaseTrait`.

### Get mocks of the current test

[](#get-mocks-of-the-current-test)

You can retrieve mocks of a the current test. Mocks objects must be user objects. They are declared in a specific file for the current test.

The file is located in the following path:

```
/fixtures/mocks/{ClassTestName}/{methodName}.php

```

This path can start from the test directory or from a parent one.

You can declare as many mocks as you want in this file.

For example:

```
//Mocks
// /fixtures/mocks/FooTest/testA.php

class Mock1{}

class mock2{}
```

```
// Test case

class FooTest extends Pumpkin\TestCase
{

    function testA(){
        $this->getMocks(); //returns [Mock1, Mock2]
    }

}
```

### Reset the database with specific data for the current test

[](#reset-the-database-with-specific-data-for-the-current-test)

When you want to mock databases with PHPUnit, you need to use `\PHPUnit_Extensions_Database_TestCase`. Instead, with Pumpkin, you have to extend `\Pumpkin\Database\TestCase`.

\\Pumpkin\\Database\\TestCase extends `\PHPUnit_Extensions_Database_TestCase`, so you have the same interface as if you use PHPUnit.

Note that if you do not want to extend `\Pumpkin\Database\TestCase`, you can also directly extend `\PHPUnit_Extensions_Database_TestCase` and use the trait `\Pumpkin\Test\Database\TestCaseTrait`.

#### The annotations

[](#the-annotations)

But you can also specify the tables you want to load for the current test. This is done in the comments of the current test, with the @db tag.

```
// Test case
use Pumpkin\Database\Annotation as db;

class FooTest extends Pumpkin\Database\TestCase
{

    /**
     * @db("my_database.my_table")
     * @db("my_other_database.my_other_table")
     */
    function testA(){
       //my_database.my_table and my_other_database.my_other_table data will be load when this test will be executed
    }

}
```

#### The data file

[](#the-data-file)

The data are stored in a file with the following path:

```
/fixtures/databases/{databaseName}/data/{tableName}.csv

```

Currently, Pumpkin support only csv files, but it can be evolved in future.

Your data can be specific for the current test, or be common with several tests. Everything is determined by the data file path. If you want specific data, you have to locate the data file in the directory of your test. If you want common data, you have to locate the data file in a common directory of your tests.

#### The database config

[](#the-database-config)

If you want to load your mocked data, you have to allow PHPUnit to access to your database. With Pumpkin you have just to specify your config in the phpunit.xml.

For example

```

    ... other phpunit config

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~283 days

Total

3

Last Release

3793d ago

Major Versions

1.1.0 → 2.0.02015-12-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/5fd55d984cf31c25f875f5636331a20f8be77e9443f2fd17fbccf1f9c4fe7a4c?d=identicon)[raphhh](/maintainers/raphhh)

---

Top Contributors

[![Raphhh](https://avatars.githubusercontent.com/u/5206490?v=4)](https://github.com/Raphhh "Raphhh (80 commits)")

---

Tags

phpunitpumpkin

### Embed Badge

![Health badge](/badges/raphhh-pumpkin/health.svg)

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

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[johnkary/phpunit-speedtrap

Find and report on slow tests in your PHPUnit test suite

78137.2M122](/packages/johnkary-phpunit-speedtrap)[spatie/phpunit-snapshot-assertions

Snapshot testing with PHPUnit

69417.9M510](/packages/spatie-phpunit-snapshot-assertions)[phpspec/prophecy-phpunit

Integrating the Prophecy mocking library in PHPUnit test cases

19254.9M1.4k](/packages/phpspec-prophecy-phpunit)[yoast/phpunit-polyfills

Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests

18338.5M841](/packages/yoast-phpunit-polyfills)[ergebnis/phpunit-slow-test-detector

Provides facilities for detecting slow tests in phpunit/phpunit.

1468.1M72](/packages/ergebnis-phpunit-slow-test-detector)

PHPackages © 2026

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