PHPackages                             data-provider/example - 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. data-provider/example

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

data-provider/example
=====================

An example of the DataProvider in PHP Unit.

0.0.2(10y ago)0192MITPHP

Since Aug 30Pushed 10y ago1 watchersCompare

[ Source](https://github.com/geshan/dataprovider-example)[ Packagist](https://packagist.org/packages/data-provider/example)[ RSS](/packages/data-provider-example/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (0)

Data Provider Example
=====================

[](#data-provider-example)

Build
-----

[](#build)

[![Build Status](https://camo.githubusercontent.com/5ca1e4888ed04b1796867b2e4a5a97b439f3ae940e385e46101c956fb498c4bf/68747470733a2f2f6170692e7472617669732d63692e6f72672f67657368616e2f6461746170726f76696465722d6578616d706c652e706e67)](https://travis-ci.org/geshan/dataprovider-example)

Code Quality
------------

[](#code-quality)

[![SensioLabsInsight](https://camo.githubusercontent.com/2fd21a946094ea268a134f261e402fca63fe033e85f8e033042b2c080fa92790/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f35366666303962322d373935342d346362322d613664612d3661663836333737353130372f6269672e706e67)](https://insight.sensiolabs.com/projects/56ff09b2-7954-4cb2-a6da-6af863775107)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/5cce56a414cb14b4e3825bea71b3bef6db6a90797b90d1053d2f9fc4d4156e5e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f67657368616e2f6461746170726f76696465722d6578616d706c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/geshan/dataprovider-example/?branch=master)[![Code Climate](https://camo.githubusercontent.com/656aa7040d19f652f486d078b1dc2136396a9de503d8a968d736ac3c576c6aeb/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f67657368616e2f6461746170726f76696465722d6578616d706c652f6261646765732f6770612e737667)](https://codeclimate.com/github/geshan/dataprovider-example)[![Codacy Badge](https://camo.githubusercontent.com/91ccf96dd7f3719e31be662790c6890c4bbc6ce3feba72a5abef6844c25cbad5/68747470733a2f2f7777772e636f646163792e636f6d2f70726f6a6563742f62616467652f3363646266393564363462313439636339323932626637373135306166323736)](https://www.codacy.com/app/geshan/dataprovider-example)

Code Style
----------

[](#code-style)

[![StyleCI](https://camo.githubusercontent.com/84e2a74910022e3d7726eefda324ca83c7d20bfaa6fa40135dfb48e244f2e8f0/68747470733a2f2f7374796c6563692e696f2f7265706f732f31363430333331382f736869656c64)](https://styleci.io/repos/16403318)

Description
-----------

[](#description)

This is a simple example of using data provider in PHP Unit. It can be used to write less test with multiple data sets keeping the code coverage high.

```
    /**
    * Data provider for testCalculateTotal
    * variables are in the order of
    * $paymentMethod, $expectedTotal
    *
    * @return type
    */
    public function paymentMethodProvider()
    {
        return [
            ['Cash', 100.00],
            ['Credit Card', 95.00],
        ];
    }

    /**
     * Test to check if the order total is calculated correctly
     * for given payment method.
     *
     * @param string $paymentMethod
     * @param float $expectedTotal
     *
     * @dataProvider paymentMethodProvider
     */
    public function testCalculateTotal($paymentMethod, $expectedTotal)
    {
        $this->checkout->calculateTotal($paymentMethod);
        $this->assertEquals(
            $this->checkout->getTotal(),
            $expectedTotal,
            sprintf('Testing total calculation for %s.', $paymentMethod)
        );
    }
```

The description of how use data provider in PHP Unit is provided in my [blog post](http://geshan.blogspot.com/2014/02/using-phpunit-data-provider-for-less.html).

Tests
-----

[](#tests)

You can run composer update

```

~> composer update --prefer-dist

```

and then run the tests using the command below on folder where the repo is cloned.

```
phpunit --bootstrap=vendor/autoload.php tests

```

Available in packagist
----------------------

[](#available-in-packagist)

The package is availabe in [packagist](http://bit.ly/1tLI2AC). You can use it for reference by adding the followign line to you composer.json file

```
"data-provider/example" : "0.0.2",

```

What Next?
----------

[](#what-next)

Issues are put in HuBorad, do have a [look](http://bit.ly/1Dkepso).

Contribution Guide
------------------

[](#contribution-guide)

This is just an example

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity57

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 ~321 days

Total

2

Last Release

3957d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/170554?v=4)[Geshan Manandhar](/maintainers/geshan)[@geshan](https://github.com/geshan)

---

Top Contributors

[![geshan](https://avatars.githubusercontent.com/u/170554?v=4)](https://github.com/geshan "geshan (16 commits)")

---

Tags

data-providerpackagistphp-unitphpunitphpunit-testsquality

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/data-provider-example/health.svg)

```
[![Health](https://phpackages.com/badges/data-provider-example/health.svg)](https://phpackages.com/packages/data-provider-example)
```

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