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

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

hmoragrega/phpspec-data-provider
================================

An extension to allow data provider on PhpSpec

1.0.4(7y ago)04.5k[1 issues](https://github.com/hmoragrega/phpspec-data-provider/issues)MITPHPPHP &gt;=7.1

Since Mar 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/hmoragrega/phpspec-data-provider)[ Packagist](https://packagist.org/packages/hmoragrega/phpspec-data-provider)[ RSS](/packages/hmoragrega-phpspec-data-provider/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

PhpSpec Data Provider
=====================

[](#phpspec-data-provider)

[![Build Status](https://camo.githubusercontent.com/3edf81bb066e00c07dc39f4311fac10ca2905553fb030875a97a8bf445142fc8/68747470733a2f2f7472617669732d63692e6f72672f686d6f726167726567612f706870737065632d646174612d70726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hmoragrega/phpspec-data-provider)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/49cb6c13539234df7f424aed9ea9ea604db51cf5ac82620dbf7be1cc606879d3/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f686d6f726167726567612f706870737065632d646174612d70726f76696465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/hmoragrega/phpspec-data-provider/?branch=master)

This extension allows to use data provider functions with PhpSpec

*Disclaimer: This is a restart of *

Requirements
------------

[](#requirements)

This extension requires `phpspec >=4`

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

[](#installation)

Require the package with composer

```
$ composer require --dev hmoragrega/phpspec-data-provider

```

Add the extension to the `phpspec.yml` configuration file

```
extensions:
  HMoragrega\PhpSpec\DataProvider\DataProviderExtension: ~

```

How to use
----------

[](#how-to-use)

A data provider method should return an array of data, where every row will be use to execute the test where the data provider is used with the given parameters

```
/**
 * @dataProvider itCanConvertAStringToLowercaseDataProvider
 *
 * @param string $input     String to convert to lowercase
 * @param string $expected  Expected output
 */
function it_can_convert_a_string_to_lowercase($input, $expected)
{
    $this->lowercase($input)->shouldReturn($expected);
}

function itCanConvertAStringToLowercaseDataProvider(): array
{
    return [
        ["already lowercase",  "foo",       "foo"],
        ["first capital",      "Foo",       "foo"],
        ["camel case",         "FooBar",    "foobar"],
        ["respect spaces",     "Foo Bar",   "foo bar"],
        ["unicode characters", "Foo ⌘ Bar", "foo ⌘ bar"],
    ];
}
```

When executed this would generate an output like:

```
  80  ✔ can convert a string to lowercase
  80  ✔ 1) it can convert a string to lowercase: already lowercase
  80  ✔ 2) it can convert a string to lowercase: first capital
  80  ✔ 3) it can convert a string to lowercase: camel case
  80  ✔ 4) it can convert a string to lowercase: respect spaces
  80  ✔ 5) it can convert a string to lowercase: unicode characters

```

**NOTE:** You can omit the first extra parameter, although every example title will be the same

```
/**
 * @dataProvider itCanConvertAStringToUppercaseDataProvider
 *
 * @param string $input     String to convert to uppercase
 * @param string $expected  Expected output
 */
function it_can_convert_a_string_to_uppercase($input, $expected)
{
    $this->uppercase($input)->shouldReturn($expected);
}

function itCanConvertAStringToUppercaseDataProvider(): array
{
    return [
        ["foo", "FOO"],
        ["bar", "BAR"],
    ];
}
```

```
  61  ✔ can convert a string to uppercase
  61  ✔ 1) it can convert a string to uppercase
  61  ✔ 2) it can convert a string to uppercase

```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

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

Total

5

Last Release

2617d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/40a1b7e4ea4e02af5c8922705e0883cbdd5b44d12bbefb27a290e2cf40043c36?d=identicon)[hmoragrega](/maintainers/hmoragrega)

---

Top Contributors

[![hmoragrega](https://avatars.githubusercontent.com/u/3494001?v=4)](https://github.com/hmoragrega "hmoragrega (20 commits)")

### Embed Badge

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

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

###  Alternatives

[bossa/phpspec2-expect

Helper that decorates any SUS with a phpspec lazy object wrapper

741.8M87](/packages/bossa-phpspec2-expect)[benconstable/phpspec-laravel

Test your Laravel applications with PhpSpec

144347.1k15](/packages/benconstable-phpspec-laravel)[akeneo/phpspec-skip-example-extension

Skip your PhpSpec examples through annotations

34978.5k11](/packages/akeneo-phpspec-skip-example-extension)[friends-of-phpspec/phpspec-code-coverage

Generate Code Coverage reports for PhpSpec tests

202.6M125](/packages/friends-of-phpspec-phpspec-code-coverage)[ciaranmcnulty/phpspec-typehintedmethods

Extension for phpspec to enhance generated methods

3089.3k31](/packages/ciaranmcnulty-phpspec-typehintedmethods)[rmiller/behat-spec

Behat and PhpSpec integration

5321.7k8](/packages/rmiller-behat-spec)

PHPackages © 2026

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