Skip to content

Commit

Permalink
minor: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kbond committed Oct 9, 2024
1 parent d90bad9 commit c9548fb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"symfony/panther": "^1.1|^2.0.1",
"symfony/phpunit-bridge": "^6.0|^7.0",
"symfony/security-bundle": "^5.4|^6.0|^7.0",
"zenstruck/foundry": "^1.30"
"zenstruck/foundry": "^1.30,<1.35"
},
"suggest": {
"justinrainbow/json-schema": "Json schema validator. Needed to use Json::assertMatchesSchema().",
Expand Down
44 changes: 22 additions & 22 deletions tests/NormalizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public static function namesProvider(): \Generator
$baseTemplate = 'error_'.__METHOD__;

yield 'test name without datasets' => [
'test name' => __METHOD__,
'expected output' => \strtr($baseTemplate, '\\:', '-_').'__0',
'testName' => __METHOD__,
'expectedOutput' => \strtr($baseTemplate, '\\:', '-_').'__0',
];

$datasetTemplate = $baseTemplate.'__data-set-%s__0';
Expand All @@ -55,49 +55,49 @@ public static function namesProvider(): \Generator
$numericOutput = \strtr($numericTemplate, '\\:', '-_');

yield 'phpunit 10 alpha' => [
'test name' => __METHOD__.' with data set "test set"',
'expected output' => $alphaOutput,
'testName' => __METHOD__.' with data set "test set"',
'expectedOutput' => $alphaOutput,
];
yield 'phpunit 10 numeric' => [
'test name' => __METHOD__.' with data set #0',
'expected output' => $numericOutput,
'testName' => __METHOD__.' with data set #0',
'expectedOutput' => $numericOutput,
];
yield 'legacy alpha' => [
'test name' => __METHOD__.' with data set "test set" (test set)',
'expected output' => $alphaOutput,
'testName' => __METHOD__.' with data set "test set" (test set)',
'expectedOutput' => $alphaOutput,
];
yield 'legacy numeric' => [
'test name' => __METHOD__.' with data set #0 (test set)',
'expected output' => $numericOutput,
'testName' => __METHOD__.' with data set #0 (test set)',
'expectedOutput' => $numericOutput,
];
}

public static function edgeCaseTestNames(): \Generator
{
$baseTemplate = \strtr('error_'.__METHOD__.'__data-set-', '\\:', '-_');
yield 'self within moustache' => [
'test name' => __METHOD__.' with data set "te{{self}}st" (test set)',
'expected output' => $baseTemplate.'te-self-st__0',
'testName' => __METHOD__.' with data set "te{{self}}st" (test set)',
'expectedOutput' => $baseTemplate.'te-self-st__0',
];
yield 'double quoted with space' => [
'test name' => __METHOD__.' with data set "_self.env.setCache("uri://host.net:2121") _self.env.loadTemplate("other-host")" (test set)',
'expected output' => $baseTemplate.'_self-env-setCache-uri-host-net-2121-_self-env-loadTemplate-other-host-__0',
'testName' => __METHOD__.' with data set "_self.env.setCache("uri://host.net:2121") _self.env.loadTemplate("other-host")" (test set)',
'expectedOutput' => $baseTemplate.'_self-env-setCache-uri-host-net-2121-_self-env-loadTemplate-other-host-__0',
];
yield 'double quotes in moustache' => [
'test name' => __METHOD__.' with data set "te{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}}st"',
'expected output' => $baseTemplate.'te-_self-env-registerUndefinedFilterCallback-exec-_self-env-getFilter-id-st__0',
'testName' => __METHOD__.' with data set "te{{_self.env.registerUndefinedFilterCallback("exec")}}{{_self.env.getFilter("id")}}st"',
'expectedOutput' => $baseTemplate.'te-_self-env-registerUndefinedFilterCallback-exec-_self-env-getFilter-id-st__0',
];
yield 'escaped simple quote' => [
'test name' => __METHOD__.' with data set "te{{\'/etc/passwd\'|file_excerpt(1,30)}}st"',
'expected output' => $baseTemplate.'te-etc-passwd-file_excerpt-1-30-st__0',
'testName' => __METHOD__.' with data set "te{{\'/etc/passwd\'|file_excerpt(1,30)}}st"',
'expectedOutput' => $baseTemplate.'te-etc-passwd-file_excerpt-1-30-st__0',
];
yield 'single quote for array index access' => [
'test name' => __METHOD__.' with data set "te{{[\'id\']|filter(\'system\')}}st"',
'expected output' => $baseTemplate.'te-id-filter-system-st__0',
'testName' => __METHOD__.' with data set "te{{[\'id\']|filter(\'system\')}}st"',
'expectedOutput' => $baseTemplate.'te-id-filter-system-st__0',
];
yield 'numeric array access' => [
'test name' => __METHOD__.' with data set "te{{[0]|reduce(\'system\',\'id\')}}st"',
'expected output' => $baseTemplate.'te-0-reduce-system-id-st__0',
'testName' => __METHOD__.' with data set "te{{[0]|reduce(\'system\',\'id\')}}st"',
'expectedOutput' => $baseTemplate.'te-0-reduce-system-id-st__0',
];
}
}

0 comments on commit c9548fb

Please sign in to comment.