Skip to content

Commit e3e2913

Browse files
committed
Use "test.json / suite description / test case description" notation in data provider to allow a readable test output
1 parent a2a6de3 commit e3e2913

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

tests/Drafts/BaseDraftTestCase.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ private function setUpTests($isValid)
2020

2121
foreach ($filePaths as $path) {
2222
foreach (glob($path . '/*.json') as $file) {
23-
if (!in_array(basename($file), $skippedTests)) {
23+
$filename = basename($file);
24+
if (!in_array($filename, $skippedTests)) {
2425
$suites = json_decode(file_get_contents($file));
2526
foreach ($suites as $suite) {
27+
$suiteDescription = $suite->description;
2628
foreach ($suite->tests as $test) {
29+
$testCaseDescription = $test->description;
2730
if ($isValid === $test->valid) {
28-
$tests[] = array(json_encode($test->data), json_encode($suite->schema));
29-
}
31+
$tests[
32+
$this->createDataSetPath($filename, $suiteDescription, $testCaseDescription)
33+
] = array(json_encode($test->data), json_encode($suite->schema));
34+
}
3035
}
3136
}
3237
}
@@ -61,4 +66,19 @@ protected abstract function getFilePaths();
6166
* @return string[]
6267
*/
6368
protected abstract function getSkippedTests();
69+
70+
/**
71+
* Generates a readable path to Json Schema Test Suite data set under test
72+
*
73+
* @param string $filename
74+
* @param string $suiteDesc
75+
* @param string $testCaseDesc
76+
*
77+
* @return string
78+
*/
79+
private function createDataSetPath($filename, $suiteDesc, $testCaseDesc)
80+
{
81+
$separator = ' / ';
82+
return $filename . $separator . $suiteDesc . $separator . $testCaseDesc;
83+
}
6484
}

0 commit comments

Comments
 (0)