From dd0205aa88f90d172ab06e1751679a3981c1435b Mon Sep 17 00:00:00 2001
From: Christian Heel <66922325+heelc29@users.noreply.github.com>
Date: Fri, 21 Aug 2026 18:10:32 +0200
Subject: [PATCH 1/3] convert metadata doc-comment to attribute
---
Tests/Cipher/CryptoTest.php | 18 +++++++-----------
Tests/Cipher/OpenSSLTest.php | 18 +++++++-----------
Tests/Cipher/SodiumTest.php | 18 +++++++-----------
Tests/CryptTest.php | 30 +++++++++---------------------
Tests/KeyTest.php | 21 ++++++---------------
5 files changed, 36 insertions(+), 69 deletions(-)
diff --git a/Tests/Cipher/CryptoTest.php b/Tests/Cipher/CryptoTest.php
index 6499e78d..93d63957 100644
--- a/Tests/Cipher/CryptoTest.php
+++ b/Tests/Cipher/CryptoTest.php
@@ -10,13 +10,18 @@
use Defuse\Crypto\Key as DefuseKey;
use Joomla\Crypt\Cipher\Crypto as CryptoCipher;
use Joomla\Crypt\Key;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\TestDox;
+use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Symfony\Polyfill\Util\Binary;
/**
* Test class for \Joomla\Crypt\Cipher\Crypto.
*/
+#[CoversClass(CryptoCipher::class)]
+#[UsesClass(Key::class)]
class CryptoTest extends TestCase
{
/**
@@ -52,14 +57,10 @@ public static function dataStrings(): array
}
/**
- * @testdox Validates data is encrypted and decrypted correctly
- *
* @param string $data The decrypted data to validate
- *
- * @covers \Joomla\Crypt\Cipher\Crypto
- * @uses \Joomla\Crypt\Key
*/
#[DataProvider('dataStrings')]
+ #[TestDox('Validates data is encrypted and decrypted correctly')]
public function testDataEncryptionAndDecryption($data)
{
$cipher = new CryptoCipher();
@@ -76,12 +77,7 @@ public function testDataEncryptionAndDecryption($data)
$this->assertSame($data, $decrypted);
}
- /**
- * @testdox Validates keys are correctly generated
- *
- * @covers \Joomla\Crypt\Cipher\Crypto
- * @uses \Joomla\Crypt\Key
- */
+ #[TestDox('Validates keys are correctly generated')]
public function testGenerateKey()
{
$cipher = new CryptoCipher();
diff --git a/Tests/Cipher/OpenSSLTest.php b/Tests/Cipher/OpenSSLTest.php
index 91dba2b6..3ed367ff 100644
--- a/Tests/Cipher/OpenSSLTest.php
+++ b/Tests/Cipher/OpenSSLTest.php
@@ -9,12 +9,17 @@
use Joomla\Crypt\Cipher\OpenSSL;
use Joomla\Crypt\Key;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\TestDox;
+use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
/**
* Test class for \Joomla\Crypt\Cipher\OpenSSL.
*/
+#[CoversClass(OpenSSL::class)]
+#[UsesClass(Key::class)]
class OpenSSLTest extends TestCase
{
/**
@@ -50,14 +55,10 @@ public static function dataStrings(): array
}
/**
- * @testdox Validates data is encrypted and decrypted correctly
- *
* @param string $data The decrypted data to validate
- *
- * @covers \Joomla\Crypt\Cipher\OpenSSL
- * @uses \Joomla\Crypt\Key
*/
#[DataProvider('dataStrings')]
+ #[TestDox('Validates data is encrypted and decrypted correctly')]
public function testDataEncryptionAndDecryption($data)
{
$cipher = new OpenSSL('1234567890123456', 'aes-128-cbc');
@@ -74,12 +75,7 @@ public function testDataEncryptionAndDecryption($data)
$this->assertSame($data, $decrypted);
}
- /**
- * @testdox Validates keys are correctly generated
- *
- * @covers \Joomla\Crypt\Cipher\OpenSSL
- * @uses \Joomla\Crypt\Key
- */
+ #[TestDox('Validates keys are correctly generated')]
public function testGenerateKey()
{
$passphraseFile = __DIR__ . '/stubs/openssl-passphrase.dat';
diff --git a/Tests/Cipher/SodiumTest.php b/Tests/Cipher/SodiumTest.php
index 0f0e049b..8ab8faf3 100644
--- a/Tests/Cipher/SodiumTest.php
+++ b/Tests/Cipher/SodiumTest.php
@@ -10,13 +10,18 @@
use Joomla\Crypt\Cipher\Sodium;
use Joomla\Crypt\Key;
use ParagonIE\Sodium\Compat;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\TestDox;
+use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\TestCase;
use Symfony\Polyfill\Util\Binary;
/**
* Test class for \Joomla\Crypt\Cipher\Sodium.
*/
+#[CoversClass(Sodium::class)]
+#[UsesClass(Key::class)]
class SodiumTest extends TestCase
{
/**
@@ -52,14 +57,10 @@ public static function dataStrings(): array
}
/**
- * @testdox Validates data is encrypted and decrypted correctly
- *
* @param string $data The decrypted data to validate
- *
- * @covers \Joomla\Crypt\Cipher\Sodium
- * @uses \Joomla\Crypt\Key
*/
#[DataProvider('dataStrings')]
+ #[TestDox('Validates data is encrypted and decrypted correctly')]
public function testDataEncryptionAndDecryption($data)
{
$cipher = new Sodium();
@@ -78,12 +79,7 @@ public function testDataEncryptionAndDecryption($data)
$this->assertSame($data, $decrypted);
}
- /**
- * @testdox Validates keys are correctly generated
- *
- * @covers \Joomla\Crypt\Cipher\Sodium
- * @uses \Joomla\Crypt\Key
- */
+ #[TestDox('Validates keys are correctly generated')]
public function testGenerateKey()
{
$cipher = new Sodium();
diff --git a/Tests/CryptTest.php b/Tests/CryptTest.php
index bf1519df..e1175aca 100644
--- a/Tests/CryptTest.php
+++ b/Tests/CryptTest.php
@@ -10,13 +10,18 @@
use Joomla\Crypt\CipherInterface;
use Joomla\Crypt\Crypt;
use Joomla\Crypt\Key;
+use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
+use PHPUnit\Framework\Attributes\TestDox;
+use PHPUnit\Framework\Attributes\UsesClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
/**
* Test class for \Joomla\Crypt\Crypt.
*/
+#[CoversClass(Crypt::class)]
+#[UsesClass(Key::class)]
class CryptTest extends TestCase
{
/**
@@ -56,11 +61,7 @@ protected function setUp(): void
$this->object = new Crypt($this->cipher, $this->key);
}
- /**
- * @testdox Validates data is encrypted and decrypted correctly
- *
- * @covers \Joomla\Crypt\Crypt
- */
+ #[TestDox('Validates data is encrypted and decrypted correctly')]
public function testDataEncryptionAndDecryption()
{
$decrypted = 'decrypt';
@@ -80,12 +81,7 @@ public function testDataEncryptionAndDecryption()
$this->object->decrypt($encrypted);
}
- /**
- * @testdox Validates keys are correctly generated
- *
- * @covers \Joomla\Crypt\Crypt
- * @uses \Joomla\Crypt\Key
- */
+ #[TestDox('Validates keys are correctly generated')]
public function testGenerateKey()
{
$this->cipher->expects($this->once())
@@ -95,12 +91,7 @@ public function testGenerateKey()
$this->object->generateKey();
}
- /**
- * @testdox Validates a new key can be set
- *
- * @covers \Joomla\Crypt\Crypt
- * @uses \Joomla\Crypt\Key
- */
+ #[TestDox('Validates a new key can be set')]
public function testSetKey()
{
$key = $this->createMock(Key::class);
@@ -130,13 +121,10 @@ public static function dataRandomByteLength(): array
}
/**
- * @testdox Validates a string of random bytes of the requested size is returned
- *
* @param integer $length The length of the random string to generate
- *
- * @covers \Joomla\Crypt\Crypt
*/
#[DataProvider('dataRandomByteLength')]
+ #[TestDox('Validates a string of random bytes of the requested size is returned')]
public function testGenRandomBytes($length)
{
$this->assertSame(
diff --git a/Tests/KeyTest.php b/Tests/KeyTest.php
index e20de7c9..94e88264 100644
--- a/Tests/KeyTest.php
+++ b/Tests/KeyTest.php
@@ -8,11 +8,14 @@
namespace Joomla\Crypt\Tests;
use Joomla\Crypt\Key;
+use PHPUnit\Framework\Attributes\CoversClass;
+use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\TestCase;
/**
* Test class for \Joomla\Crypt\Key.
*/
+#[CoversClass(Key::class)]
class KeyTest extends TestCase
{
/**
@@ -60,31 +63,19 @@ protected function setUp(): void
$this->object = new Key($this->type, $this->private, $this->public);
}
- /**
- * @testdox Validates the private key is returned
- *
- * @covers Joomla\Crypt\Key
- */
+ #[TestDox('Validates the private key is returned')]
public function testGetPrivate()
{
$this->assertSame($this->private, $this->object->getPrivate());
}
- /**
- * @testdox Validates the public key is returned
- *
- * @covers Joomla\Crypt\Key
- */
+ #[TestDox('Validates the public key is returned')]
public function testGetPublic()
{
$this->assertSame($this->public, $this->object->getPublic());
}
- /**
- * @testdox Validates the key type is returned
- *
- * @covers Joomla\Crypt\Key
- */
+ #[TestDox('Validates the key type is returned')]
public function testGetKeyType()
{
$this->assertSame($this->type, $this->object->getType());
From 13af5df8a8a0d731d7058717e315404ca4a60555 Mon Sep 17 00:00:00 2001
From: Christian Heel <66922325+heelc29@users.noreply.github.com>
Date: Fri, 21 Aug 2026 18:25:30 +0200
Subject: [PATCH 2/3] convert mock to stub if no expectations were configured
---
Tests/CryptTest.php | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/Tests/CryptTest.php b/Tests/CryptTest.php
index e1175aca..b73bbf68 100644
--- a/Tests/CryptTest.php
+++ b/Tests/CryptTest.php
@@ -10,6 +10,7 @@
use Joomla\Crypt\CipherInterface;
use Joomla\Crypt\Crypt;
use Joomla\Crypt\Key;
+use PHPUnit\Framework\Attributes\AllowMockObjectsWithoutExpectations;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\TestDox;
@@ -56,7 +57,7 @@ protected function setUp(): void
parent::setUp();
$this->cipher = $this->createMock(CipherInterface::class);
- $this->key = $this->createMock(Key::class);
+ $this->key = $this->createStub(Key::class);
$this->object = new Crypt($this->cipher, $this->key);
}
@@ -86,15 +87,16 @@ public function testGenerateKey()
{
$this->cipher->expects($this->once())
->method('generateKey')
- ->willReturn($this->createMock(Key::class));
+ ->willReturn($this->createStub(Key::class));
$this->object->generateKey();
}
+ #[AllowMockObjectsWithoutExpectations]
#[TestDox('Validates a new key can be set')]
public function testSetKey()
{
- $key = $this->createMock(Key::class);
+ $key = $this->createStub(Key::class);
$this->object->setKey($key);
@@ -123,6 +125,7 @@ public static function dataRandomByteLength(): array
/**
* @param integer $length The length of the random string to generate
*/
+ #[AllowMockObjectsWithoutExpectations]
#[DataProvider('dataRandomByteLength')]
#[TestDox('Validates a string of random bytes of the requested size is returned')]
public function testGenRandomBytes($length)
From 6b427791b28c2506a3c4c8d36a3acbc5164a1075 Mon Sep 17 00:00:00 2001
From: Christian Heel <66922325+heelc29@users.noreply.github.com>
Date: Fri, 21 Aug 2026 18:26:09 +0200
Subject: [PATCH 3/3] migrate configuration
---
phpunit.xml.dist | 7 -------
1 file changed, 7 deletions(-)
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0c1b5156..2ce3a57f 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -5,14 +5,7 @@
Tests
-
-
-
-
- src
-
-