Skip to content

Commit 379bf0e

Browse files
authored
Merge pull request #37 from inpsyde/issue-36
Provide test fixtures via data provider #36
2 parents 0d79aa6 + 6b2998b commit 379bf0e

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,19 @@ If you do not see `Inpsyde` here, you may need to specify `phpcs.xml` file by se
302302

303303
Now PhpStorm integration is complete, and errors in the code style will be shown in the IDE editor
304304
allowing to detect them without running any commands at all.
305+
306+
# Contribution
307+
308+
## Running tests
309+
310+
To run the tests for this package you need to install its dependencies first:
311+
312+
$ composer install
313+
314+
After that you can run all PHPUnit tests like this:
315+
316+
$ vendor/bin/phpunit
317+
318+
The tests are organized in fixture files. If you want to run a single test use the filter argument:
319+
320+
$ vendor/bin/phpunit --filter function-length-no-blank-lines

tests/cases/FixturesTest.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,24 @@
2727
*/
2828
class FixturesTest extends TestCase
2929
{
30-
public function testAllFixtures()
31-
{
32-
$fixtures = glob(getenv('FIXTURES_PATH') . DIRECTORY_SEPARATOR . '*.php');
33-
$parser = new FixtureContentParser();
34-
$failures = new \SplStack();
3530

31+
public function fixtureProvider(): \Traversable
32+
{
33+
$fixtures = glob(getenv('FIXTURES_PATH').DIRECTORY_SEPARATOR.'*.php');
3634
foreach ($fixtures as $fixtureFile) {
37-
$this->validateFixture($fixtureFile, $parser, $failures);
35+
$testname = pathinfo($fixtureFile, PATHINFO_BASENAME);
36+
yield $testname => ['fixtrueFile' => $fixtureFile];
3837
}
38+
}
39+
40+
/**
41+
* @dataProvider fixtureProvider
42+
*/
43+
public function testAllFixtures(string $fixtureFile)
44+
{
45+
$parser = new FixtureContentParser();
46+
$failures = new \SplStack();
47+
$this->validateFixture($fixtureFile, $parser, $failures);
3948

4049
$previous = null;
4150
/** @var \Throwable $failure */

0 commit comments

Comments
 (0)