2017 © Pedro Peláez
 

library example

An example of the DataProvider in PHP Unit.

image

data-provider/example

An example of the DataProvider in PHP Unit.

  • Tuesday, September 1, 2015
  • by geshan
  • Repository
  • 1 Watchers
  • 0 Stars
  • 8 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 4 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Data Provider Example

Build

Build Status, (*1)

Code Quality

SensioLabsInsight Scrutinizer Code Quality Code Climate Codacy Badge, (*2)

Code Style

StyleCI, (*3)

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., (*4)


/** * 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., (*5)

Tests

You can run composer update, (*6)


~> composer update --prefer-dist

and then run the tests using the command below on folder where the repo is cloned., (*7)

phpunit --bootstrap=vendor/autoload.php tests

Available in packagist

The package is availabe in packagist. You can use it for reference by adding the followign line to you composer.json file, (*8)

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

What Next?

Issues are put in HuBorad, do have a look., (*9)

Contribution Guide

This is just an example, (*10)

The Versions

01/09 2015

dev-master

9999999-dev

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar

01/08 2015

dev-analysis-XlrKQz

dev-analysis-XlrKQz

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar

27/07 2015

dev-sensiolabs-insight-medal

dev-sensiolabs-insight-medal

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar

17/07 2015

dev-code-coverage-reporting

dev-code-coverage-reporting

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar

17/07 2015

0.0.2

0.0.2.0

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar

17/07 2015

dev-changes

dev-changes

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar

30/08 2014

0.0.1

0.0.1.0

An example of the DataProvider in PHP Unit.

  Sources   Download

MIT

The Development Requires

by Geshan Manandhar