2017 © Pedro Peláez
 

library phpspec-data-provider-extension

Extension that allows to use data provider in phpspec

image

kanel/phpspec-data-provider-extension

Extension that allows to use data provider in phpspec

  • Tuesday, December 12, 2017
  • by elkaadka
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3,033 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 78 % Grown

The README.md

PhpSpec data provider extension

build, (*1)

This extension allows you to create data providers for examples in specs., (*2)

It was largely inspired from coduo/phpspec-data-provider-extension and adapted to handle phpspec 4 and default values of parameters, (*3)

Installation

composer require kanel/phpspec-data-provider-extension

Usage

Enable extension in phpspec.yml file, (*4)

extensions:
    Kanel\PhpSpec\DataProvider\Extension: ~

Write a spec:, (*5)

<?php

namespace spec\Kanel\PhpSpec\Test;

use Kanel\PhpSpec\Test\Increment;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;

class IncrementSpec extends ObjectBehavior
{
    /**
     * Example of a dataprovider with default values
     * @dataProvider getTestSuite
     */
    public function it_should_be_able_to_increment_values($input, $output = 1)
    {
        $this->plusOne($input)->shouldBe($output);
    }

    public function getTestSuite()  {
        return [
            [0],
            [1, 2],
            [3, 4],
            [5, 6],
        ];
    }
}

Write class for spec:, (*6)

<?php

namespace Kanel\PhpSpec\Test;

class Increment
{
        public function plusOne(int $i): int {
            return $i + 1;
        }
}

Run php spec, (*7)

$ console bin/phpspec run -f pretty

You should get following output:, (*8)

    Kanel\PhpSpec\Test\Increment


  15  ✔ should be able to increment values (129ms)
  15  ✔ 2) it should be able to increment values
  15  ✔ 3) it should be able to increment values
  15  ✔ 4) it should be able to increment values


1 specs
4 examples (4 passed)

The Versions

12/12 2017

dev-master

9999999-dev

Extension that allows to use data provider in phpspec

  Sources   Download

MIT

The Requires

 

by Adil El Kanabi

12/12 2017

1.0.0

1.0.0.0

Extension that allows to use data provider in phpspec

  Sources   Download

MIT

The Requires

 

by Adil El Kanabi