{"id":16463335,"url":"https://github.com/geshan/dataprovider-example","last_synced_at":"2026-04-14T07:33:11.966Z","repository":{"id":13709362,"uuid":"16403318","full_name":"geshan/dataprovider-example","owner":"geshan","description":"A simple example of PHPUnit data provider.","archived":false,"fork":false,"pushed_at":"2015-09-01T11:34:59.000Z","size":268,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-01T09:15:48.677Z","etag":null,"topics":["data-provider","packagist","php-unit","phpunit","phpunit-tests","quality"],"latest_commit_sha":null,"homepage":"https://geshan.com.np/blog/2014/02/using-phpunit-data-provider-for-less/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/geshan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-31T08:38:37.000Z","updated_at":"2020-10-26T03:02:29.000Z","dependencies_parsed_at":"2022-07-30T16:08:46.528Z","dependency_job_id":null,"html_url":"https://github.com/geshan/dataprovider-example","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/geshan/dataprovider-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geshan%2Fdataprovider-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geshan%2Fdataprovider-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geshan%2Fdataprovider-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geshan%2Fdataprovider-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/geshan","download_url":"https://codeload.github.com/geshan/dataprovider-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/geshan%2Fdataprovider-example/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31786907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T02:24:21.117Z","status":"ssl_error","status_checked_at":"2026-04-14T02:24:20.627Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-provider","packagist","php-unit","phpunit","phpunit-tests","quality"],"created_at":"2024-10-11T11:14:11.315Z","updated_at":"2026-04-14T07:33:11.948Z","avatar_url":"https://github.com/geshan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Data Provider Example\n\n## Build\n\n[![Build Status](https://api.travis-ci.org/geshan/dataprovider-example.png)](https://travis-ci.org/geshan/dataprovider-example)\n\n## Code Quality\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/56ff09b2-7954-4cb2-a6da-6af863775107/big.png)](https://insight.sensiolabs.com/projects/56ff09b2-7954-4cb2-a6da-6af863775107)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/geshan/dataprovider-example/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/geshan/dataprovider-example/?branch=master)\n[![Code Climate](https://codeclimate.com/github/geshan/dataprovider-example/badges/gpa.svg)](https://codeclimate.com/github/geshan/dataprovider-example)\n[![Codacy Badge](https://www.codacy.com/project/badge/3cdbf95d64b149cc9292bf77150af276)](https://www.codacy.com/app/geshan/dataprovider-example)\n\n## Code Style\n\n[![StyleCI](https://styleci.io/repos/16403318/shield)](https://styleci.io/repos/16403318)\n\n## Description\n\nThis is a simple example of using data provider in PHP Unit. It can be used to\nwrite less test with multiple data sets keeping the code coverage high.\n\n```php\n\n    /**\n    * Data provider for testCalculateTotal\n    * variables are in the order of\n    * $paymentMethod, $expectedTotal\n    * \n    * @return type\n    */\n    public function paymentMethodProvider()\n    {\n        return [\n            ['Cash', 100.00],\n            ['Credit Card', 95.00],\n        ];\n    }\n\n    /**\n     * Test to check if the order total is calculated correctly\n     * for given payment method.\n     * \n     * @param string $paymentMethod\n     * @param float $expectedTotal\n     * \n     * @dataProvider paymentMethodProvider\n     */\n    public function testCalculateTotal($paymentMethod, $expectedTotal)\n    {\n        $this-\u003echeckout-\u003ecalculateTotal($paymentMethod);\n        $this-\u003eassertEquals(\n            $this-\u003echeckout-\u003egetTotal(), \n            $expectedTotal,\n            sprintf('Testing total calculation for %s.', $paymentMethod)\n        );\n    }\n\n```\n\nThe description of how use data provider in PHP Unit is provided in my \n[blog post](http://geshan.blogspot.com/2014/02/using-phpunit-data-provider-for-less.html).\n\n\n## Tests\n\nYou can run composer update\n\n```\n\n~\u003e composer update --prefer-dist\n\n```\n\nand then run the tests using the command below on folder where the repo is cloned.\n\n```\nphpunit --bootstrap=vendor/autoload.php tests\n\n```\n\n## Available in packagist\n\nThe package is availabe in [packagist](http://bit.ly/1tLI2AC). You can use it for reference by adding the followign line\nto you composer.json file\n\n```\n\"data-provider/example\" : \"0.0.2\",\n```\n\n## What Next?\n\nIssues are put in HuBorad, do have a [look](http://bit.ly/1Dkepso).\n\n## Contribution Guide\n\nThis is just an example\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeshan%2Fdataprovider-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgeshan%2Fdataprovider-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgeshan%2Fdataprovider-example/lists"}