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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
|
From: =?utf-8?q?David_Pr=C3=A9vot?= <david@tilapin.org>
Date: Wed, 26 Feb 2025 08:53:48 +0100
Subject: Modernize PHPUnit syntax
---
tests/integration/ToIdnTest.php | 30 ++++++++++--------------------
tests/integration/ToUnicodeTest.php | 19 ++++++++-----------
tests/unit/NamePrepTest.php | 12 +++++-------
3 files changed, 23 insertions(+), 38 deletions(-)
diff --git a/tests/integration/ToIdnTest.php b/tests/integration/ToIdnTest.php
index 6f9eab6..19db9cc 100644
--- a/tests/integration/ToIdnTest.php
+++ b/tests/integration/ToIdnTest.php
@@ -6,20 +6,19 @@ use Algo26\IdnaConvert\Exception\InvalidCharacterException;
use Algo26\IdnaConvert\Exception\InvalidIdnVersionException;
use Algo26\IdnaConvert\Exception\Std3AsciiRulesViolationException;
use Algo26\IdnaConvert\ToIdn;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
-/**
- * @covers \Algo26\IdnaConvert\ToIdn
- */
+#[CoversClass('\Algo26\IdnaConvert\ToIdn')]
class ToIdnTest extends TestCase
{
/**
- * @dataProvider providerUtf8
- *
* @throws AlreadyPunycodeException
* @throws InvalidCharacterException
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerUtf8')]
public function testEncodeUtf8($decoded, $expectEncoded): void
{
$idnaConvert = new ToIdn();
@@ -37,12 +36,11 @@ class ToIdnTest extends TestCase
}
/**
- * @dataProvider providerUtf8Idna2003
- *
* @throws AlreadyPunycodeException
* @throws InvalidCharacterException
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerUtf8Idna2003')]
public function testEncodeUtf8Idna2003($decoded, $expectEncoded): void
{
$idnaConvert = new ToIdn(2003);
@@ -60,10 +58,9 @@ class ToIdnTest extends TestCase
}
/**
- * @dataProvider providerEmailAddress
- *
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerEmailAddress')]
public function testEncodeEmailAddress($decoded, $expectEncoded): void
{
$idnaConvert = new ToIdn(2008);
@@ -81,10 +78,9 @@ class ToIdnTest extends TestCase
}
/**
- * @dataProvider providerUrl
- *
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerUrl')]
public function testEncodeUrl($decoded, $expectEncoded): void
{
$idnaConvert = new ToIdn(2008);
@@ -101,9 +97,7 @@ class ToIdnTest extends TestCase
);
}
- /**
- * @dataProvider providerAlreadyPunycode
- */
+ #[DataProvider('providerAlreadyPunycode')]
public function testThrowsAlreadyPunycodeException($decoded, $idnVersion): void
{
self::expectException(AlreadyPunycodeException::class);
@@ -112,9 +106,7 @@ class ToIdnTest extends TestCase
$idnaConvert->convert($decoded);
}
- /**
- * @dataProvider providerInvalidCharacter
- */
+ #[DataProvider('providerInvalidCharacter')]
public function testThrowsInvalidCharacterException($sequence): void
{
self::expectException(InvalidCharacterException::class);
@@ -123,9 +115,7 @@ class ToIdnTest extends TestCase
$idnaConvert->convert($sequence);
}
- /**
- * @dataProvider providerStd3AsciiRulesViolation
- */
+ #[DataProvider('providerStd3AsciiRulesViolation')]
public function testThrowsStd3AsciiRulesException($sequence): void
{
self::expectException(Std3AsciiRulesViolationException::class);
diff --git a/tests/integration/ToUnicodeTest.php b/tests/integration/ToUnicodeTest.php
index 184d2a2..17cb652 100644
--- a/tests/integration/ToUnicodeTest.php
+++ b/tests/integration/ToUnicodeTest.php
@@ -4,17 +4,17 @@ namespace Algo26\IdnaConvert\Test\integration;
use Algo26\IdnaConvert\Exception\InvalidCharacterException;
use Algo26\IdnaConvert\Exception\InvalidIdnVersionException;
use Algo26\IdnaConvert\ToUnicode;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
-/**
- * @covers \Algo26\IdnaConvert\ToUnicode
- */
+#[CoversClass('\Algo26\IdnaConvert\ToUnicode')]
class ToUnicodeTest extends TestCase
{
/**
- * @dataProvider providerUtf8
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerUtf8')]
public function testDecodeUtf8($encoded, $expectDecoded)
{
$idnaConvert = new ToUnicode();
@@ -30,9 +30,8 @@ class ToUnicodeTest extends TestCase
)
);
}
- /**
- * @dataProvider providerException
- */
+
+ #[DataProvider('providerException')]
public function testDecodeUtf8Exception($encoded)
{
self::expectException(InvalidCharacterException::class);
@@ -42,10 +41,9 @@ class ToUnicodeTest extends TestCase
}
/**
- * @dataProvider providerEmailAddress
- *
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerEmailAddress')]
public function testDecodeEmailAddress($encoded, $expectDecoded)
{
$idnaConvert = new ToUnicode();
@@ -63,10 +61,9 @@ class ToUnicodeTest extends TestCase
}
/**
- * @dataProvider providerUrl
- *
* @throws InvalidIdnVersionException
*/
+ #[DataProvider('providerUrl')]
public function testDecodeUrl($encoded, $expectDecoded)
{
$idnaConvert = new ToUnicode();
diff --git a/tests/unit/NamePrepTest.php b/tests/unit/NamePrepTest.php
index 4b22747..79918e0 100644
--- a/tests/unit/NamePrepTest.php
+++ b/tests/unit/NamePrepTest.php
@@ -6,11 +6,11 @@ use Algo26\IdnaConvert\Exception\InvalidCharacterException;
use Algo26\IdnaConvert\Exception\InvalidIdnVersionException;
use Algo26\IdnaConvert\NamePrep\NamePrep;
use Algo26\IdnaConvert\TranscodeUnicode\TranscodeUnicode;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
-/**
- * @covers \Algo26\IdnaConvert\NamePrep\NamePrep
- */
+#[CoversClass('\Algo26\IdnaConvert\NamePrep\NamePrep')]
class NamePrepTest extends TestCase
{
/** @var TranscodeUnicode */
@@ -34,9 +34,8 @@ class NamePrepTest extends TestCase
/**
* @param array|string $from provided original string
* @param array|string $expectedTo expected result
- *
- * @dataProvider providerMapping2003
*/
+ #[DataProvider('providerMapping2003')]
public function testSuccess2003($from, $expectedTo)
{
if (!is_array($from)) {
@@ -61,9 +60,8 @@ class NamePrepTest extends TestCase
/**
* @param array|string $sequence as UTF-8 string or UCS-4 array
- *
- * @dataProvider providerProhibited
*/
+ #[DataProvider('providerProhibited')]
public function testProhibited($sequence)
{
if (!is_array($sequence)) {
|