From 95ec0a82b2a571647528ac07dd398d4f3612acd6 Mon Sep 17 00:00:00 2001 From: faissaloux Date: Tue, 7 Nov 2023 17:35:42 +0100 Subject: [PATCH 1/2] fix html in tests descriptions and datasets --- src/Concerns/Testable.php | 1 + tests/Unit/DatasetsTests.php | 10 ++++++++++ tests/Unit/TestName.php | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Concerns/Testable.php b/src/Concerns/Testable.php index e8d00588..b9000ce8 100644 --- a/src/Concerns/Testable.php +++ b/src/Concerns/Testable.php @@ -193,6 +193,7 @@ trait Testable $method = TestSuite::getInstance()->tests->get(self::$__filename)->getMethod($this->name()); $description = $this->dataName() ? $method->description.' with '.$this->dataName() : $method->description; + $description = htmlspecialchars(html_entity_decode($description), ENT_NOQUOTES); if ($method->repetitions > 1) { $matches = []; diff --git a/tests/Unit/DatasetsTests.php b/tests/Unit/DatasetsTests.php index 79cc44a6..543c30ae 100644 --- a/tests/Unit/DatasetsTests.php +++ b/tests/Unit/DatasetsTests.php @@ -99,3 +99,13 @@ it('shows the correct description for arrays with many elements', function () { expect($descriptions[0])->toBe('([1, 2, 3, …])'); }); + +it('shows the correct description of datasets with html', function () { + $descriptions = array_keys(DatasetsRepository::resolve([ + [ + '
', + ], + ], __FILE__)); + + expect($descriptions[0])->toBe('(\'
\')'); +}); diff --git a/tests/Unit/TestName.php b/tests/Unit/TestName.php index e18544d3..b65be16f 100644 --- a/tests/Unit/TestName.php +++ b/tests/Unit/TestName.php @@ -20,7 +20,7 @@ $names = [ '卜竹弓一十山' => '__pest_evaluable_卜竹弓一十山', 'アゴデヸ' => '__pest_evaluable_アゴデヸ', '!p8VrB' => '__pest_evaluable__p8VrB', - '&xe6VeKWF#n4' => '__pest_evaluable__xe6VeKWF_n4', + '&xe6VeKWF#n4' => '__pest_evaluable__amp_xe6VeKWF_n4', '%%HurHUnw7zM!' => '__pest_evaluable___HurHUnw7zM_', 'rundeliekend' => '__pest_evaluable_rundeliekend', 'g%%c!Jt9$fy#Kf' => '__pest_evaluable_g__c_Jt9_fy_Kf', @@ -33,7 +33,7 @@ $names = [ 'Каролин' => '__pest_evaluable_Каролин', 'অ্যান্টার্কটিকা' => '__pest_evaluable_অ্যান্টার্কটিকা', 'Frýdek-Místek"' => '__pest_evaluable_Frýdek_Místek_', - 'Allingåbro&' => '__pest_evaluable_Allingåbro_', + 'Allingåbro&' => '__pest_evaluable_Allingåbro_amp_', 'Κεντροαφρικανική Δημοκρατία' => '__pest_evaluable_Κεντροαφρικανική_Δημοκρατία', 'آذربایجان غربی' => '__pest_evaluable_آذربایجان_غربی', 'זימבבואה' => '__pest_evaluable_זימבבואה', From 16768fca9f4206b59fc9afa2be6b6968efe77cbb Mon Sep 17 00:00:00 2001 From: faissaloux Date: Tue, 7 Nov 2023 17:46:00 +0100 Subject: [PATCH 2/2] update snapshots/paralell test --- tests/.snapshots/success.txt | 3 ++- tests/Visual/Parallel.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/.snapshots/success.txt b/tests/.snapshots/success.txt index 2c5ecebe..ffe59bb4 100644 --- a/tests/.snapshots/success.txt +++ b/tests/.snapshots/success.txt @@ -1194,6 +1194,7 @@ ✓ it show the correct description for mixed named and not-named datasets ✓ it shows the correct description for long texts with newlines ✓ it shows the correct description for arrays with many elements + ✓ it shows the correct description of datasets with html PASS Tests\Unit\Expectations\OppositeExpectation ✓ it throw expectation failed exception with string argument @@ -1352,4 +1353,4 @@ WARN Tests\Visual\Version - visual snapshot of help command output - Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 962 passed (2280 assertions) \ No newline at end of file + Tests: 2 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 19 skipped, 963 passed (2281 assertions) \ No newline at end of file diff --git a/tests/Visual/Parallel.php b/tests/Visual/Parallel.php index 0828a61b..3bf79db1 100644 --- a/tests/Visual/Parallel.php +++ b/tests/Visual/Parallel.php @@ -16,7 +16,7 @@ $run = function () { test('parallel', function () use ($run) { expect($run('--exclude-group=integration')) - ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 951 passed (2265 assertions)') + ->toContain('Tests: 1 deprecated, 4 warnings, 5 incomplete, 2 notices, 13 todos, 15 skipped, 952 passed (2266 assertions)') ->toContain('Parallel: 3 processes'); })->skipOnWindows();