You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tester already supports loading from ini which is fine for simple datasets, but can't capture recursive structures, associative arrays and so on. Having these inline in tests is also clumsy and rather inconvenient.
We could for example add a json provider. The modification should be fairly simple, if I specify
@dataProvider foo.json
it would handle the string as file name, read it and then json_decode($data, true).
We can assume that the json is in the format "array of arrays" so the decode will give proper values to be fed to the method without any more fiddling.
Implementation-wise, this should require just a single change to DataProvider::load. I can take a stub at implementing this too.
Right now I use a very simple class JsonProvider and use it like
but having to copy this trivial code all over the test class litters it a lot :/
Additionally, we could support simpleDataProvider interface (with basically just getData method) and then people could annotate with their own implementations:
/** @dataProvider CsvProvider foo.csv */publicfunction test($data)
// OR maybe/** @dataProvider CsvProvider('foo.csv') */
public function test($data)
// OR something else... this is just to start the discussion ^^
I already use 3 implementations of above (JsonProvider is one of them) so I think there is a reasonable chance people would find it useful.
What do you think?
The text was updated successfully, but these errors were encountered:
Tester already supports loading from ini which is fine for simple datasets, but can't capture recursive structures, associative arrays and so on. Having these inline in tests is also clumsy and rather inconvenient.
We could for example add a json provider. The modification should be fairly simple, if I specify
it would handle the string as file name, read it and then
json_decode($data, true)
.We can assume that the json is in the format "array of arrays" so the decode will give proper values to be fed to the method without any more fiddling.
Implementation-wise, this should require just a single change to
DataProvider::load
. I can take a stub at implementing this too.Right now I use a very simple class
JsonProvider
and use it likebut having to copy this trivial code all over the test class litters it a lot :/
Additionally, we could support simple
DataProvider
interface (with basically justgetData
method) and then people could annotate with their own implementations:And possible usages:
I already use 3 implementations of above (
JsonProvider
is one of them) so I think there is a reasonable chance people would find it useful.What do you think?
The text was updated successfully, but these errors were encountered: