Download the PHP package yuraplohov/test-data-provider without Composer
On this page you can find all versions of the php package yuraplohov/test-data-provider. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yuraplohov/test-data-provider
More information about yuraplohov/test-data-provider
Files in yuraplohov/test-data-provider
Package test-data-provider
Short Description Providing test data for autotests from php files with returned arrays, and from any text files
License MIT
Informations about the package test-data-provider
yuraplohov/test-data-provider
The package provides data for autotests from php-files with returned arrays, and from any text files (json, xml, txt...). The package works with PHPUnit, Codeception and Pest frameworks.
Installation
Usage
The package contains one class - Yuraplohov\TestDataProvider\Provider. This class has four public methods:
- basePath(string $basePath): self - sets the base path to the directory with data.
- getPHPUnitCases(array $caseDirs): array - retrieves an array of test cases in PHPUnit framework format.
- getCodeceptionCases(array $caseDirs): array - retrieves an array of test cases in Codeception framework format.
- get(string $path): mixed - retrieves data from a directory, file, or array element in a php-file.
Php files with data for all these methods should be like this:
Also, all three methods can work with any text files (json, xml, txt...). The content of such files is returned as a string without any transformations.
The 'tests' directory structure for getPHPUnitCases() and getCodeceptionCases() methods could be:
- tests
- Example_Test
- ExampleTets.php
- data
- case_1
- input.json
- expected.php
- case_2
- input.json
- expected.php
If the base path is not specified, the 'data' directory must be at the same level as your test class. Directories with cases are placed in the 'data' directory. You can name case directories whatever you want, but the 'data' directory must always be named like this if you don't specify any base path with basePath().
Provider::getPHPUnitCases(array $caseDirs): array
Provider::getCodeceptionCases(array $caseDirs): array
Provider::get(string $path): mixed
This method can be used with any framework and with any structure of the 'data' directory.
Tests directory structure example:
- tests
- Example_Test
- ExampleTets.php
- data
- service
- input.json
- settings.php
- expected.php
Examples of method calling for this structure:
Usage in PHPUnit:
Testing
License
The MIT License (MIT).