1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
From: Joe Nahmias <jello@debian.org>
Date: Wed, 29 Oct 2025 23:50:03 -0400
Subject: make tests work with PHPUnit 12, rather than skipping
---
test/ParsedownTest.php | 40 ++++++++--------------------------------
1 file changed, 8 insertions(+), 32 deletions(-)
diff --git a/test/ParsedownTest.php b/test/ParsedownTest.php
index 5306f16..f47d179 100644
--- a/test/ParsedownTest.php
+++ b/test/ParsedownTest.php
@@ -2,41 +2,16 @@
require 'SampleExtensions.php';
-use PHPUnit\Framework\Attributes\RequiresPhpunit;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class ParsedownTest extends TestCase
{
- private $dirs, $Parsedown;
-
- /**
- * @return array
- */
- protected function initDirs()
- {
- $dirs []= dirname(__FILE__).'/data/';
-
- return $dirs;
- }
-
- /**
- * @return Parsedown
- */
- protected function initParsedown()
+ #[DataProvider('data')]
+ function test_(string $test, string $dir)
{
$Parsedown = new TestParsedown();
- return $Parsedown;
- }
-
- /**
- * @dataProvider data
- * @param $test
- * @param $dir
- */
- #[RequiresPhpunit('< 11')]
- function test_($test, $dir)
- {
$markdown = file_get_contents($dir . $test . '.md');
$expectedMarkup = file_get_contents($dir . $test . '.html');
@@ -44,9 +19,9 @@ class ParsedownTest extends TestCase
$expectedMarkup = str_replace("\r\n", "\n", $expectedMarkup);
$expectedMarkup = str_replace("\r", "\n", $expectedMarkup);
- $this->Parsedown->setSafeMode(substr($test, 0, 3) === 'xss');
+ $Parsedown->setSafeMode(substr($test, 0, 3) === 'xss');
- $actualMarkup = $this->Parsedown->text($markdown);
+ $actualMarkup = $Parsedown->text($markdown);
$this->assertEquals($expectedMarkup, $actualMarkup);
}
@@ -85,11 +60,12 @@ class ParsedownTest extends TestCase
$this->assertEquals($expectedSafeMarkup, $actualSafeMarkup);
}
- function data()
+ public static function data(): array
{
$data = array();
+ $dirs []= dirname(__FILE__).'/data/';
- foreach ($this->dirs as $dir)
+ foreach ($dirs as $dir)
{
$Folder = new DirectoryIterator($dir);
|