Allows you to mix multiple PhpUnit @dataProvider without duplication
MIT License
We added method DataProvider.entries()
, which can be used to pass both the key and the value from array rows. It's useful for using already existing collections, of which their keys should also be passed to the test cases.
Test cases are being called with two arguments, the first being the key from the array, and the other being the value (regardless of the value type).
More features will be coming, in current beta there are: DataProvider.filter()
, DataProvider.reindex()
, DataProvider.reindexTo()
, DataProvider.flatMap()
and some others.
Published by danon about 1 year ago
We added method DataProvider.map()
, which can be used to map row's values to any other values. It's useful for separating content of the data provider from the form (if the form is non-trivial) and for adapting similar DataProvider
s to be used in more tests.
More features will be coming, in current beta there are: DataProvider.filter()
, DataProvider.reindex()
, DataProvider.reindexTo()
and some others.
Published by danon about 1 year ago
In march this years, we started rewriting the library, inspired by one of our contributors pull requests: https://github.com/t-regx/phpunit-data-provider/pull/54. As always, it appeared to be a weekend job, but took 5 months. We had 3 iterations of revamps of the library, swaping features, checking what works and what doesn't. The orginal gist of the library stays the same of course - seamless usage of PhpUnit data providers, but now with super powers.
This is what we came up with:
DataProvider::list()
DataProvider::join()
DataProvider::zip()
DataProvider::cross()
DataProvider::pairs()
DataProvider::of()
DataProvider::tuples()
DataProvider::dictionary()
Additionally: all DataProvider
accepts iterable
, properly names each row, always preserves duplicates, differentiates between types (int
4
and string
"4"
) and uses helpful exception messages
The changes are released as 3.0.0
and can be used right away.
We're excited to see how the new library will be used!
To use version 3.0.0
, migrating from 2.4.0
or earlier:
\TRegx\DataProvider\
to \TRegx\PhpUnit\DataProviders\
.\TRegx\DataProvider\DataProviders::cross()
to \TRegx\PhpUnit\DataProviders\DataProvider::cross()
.\TRegx\DataProvider\CrossDataProviders::cross()
to \TRegx\PhpUnit\DataProviders\DataProvider::cross()
.array
to iterable
or \TRegx\PhpUnit\DataProviders\DataProvider
.\TRegx\DataProvider\CrossDataProviders::builder()
, use \TRegx\PhpUnit\DataProviders\DataProvider::cross()
Published by danon almost 5 years ago
We created another utility method, DataProviders::pairs()
! that lets you run your phpUnit method with two arguments, for each combination of your data provider elements.
return DataProviders::pairs('png', 'bmp', 'jpg', 'gif');
There's a throughout example in ReadMe.md.
We also dropped support for PHP 5.6 (only PHP 7.0 is supported) and changed the namespace from /TRegx/CrossData
to /TRegx/DataProvider
.
Published by danon almost 5 years ago
Previous design wasn't that good, it was more of a personal tool, for the sake of unit tests for T-Regx, but as I saw it was being used, well it's time for a more proper design of methods :)
This means a complete drop of development of 1.0.0.