kanel/phpspec-data-provider-extension
最新稳定版本:1.0.0
Composer 安装命令:
composer require kanel/phpspec-data-provider-extension
包简介
Extension that allows to use data provider in phpspec
README 文档
README
#PhpSpec data provider extension
This extension allows you to create data providers for examples in specs.
It was largely inspired from coduo/phpspec-data-provider-extension and adapted to handle phpspec 4 and default values of parameters
Installation
composer require kanel/phpspec-data-provider-extension
Usage
Enable extension in phpspec.yml file
extensions:
Kanel\PhpSpec\DataProvider\Extension: ~
Write a spec:
<?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:
<?php namespace Kanel\PhpSpec\Test; class Increment { public function plusOne(int $i): int { return $i + 1; } }
Run php spec
$ console bin/phpspec run -f pretty
You should get following output:
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)
统计信息
- 总下载量: 22.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-12-12