Description: update to work with more recent PHPUnit versions
Author: Joseph Nahmias <joe@nahmias.net>
Forwarded: no
Last-Update: 2022-05-27
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/tests/Otp/GoogleAuthenticatorTest.php
+++ b/tests/Otp/GoogleAuthenticatorTest.php
@@ -3,11 +3,12 @@
 require_once __DIR__ . '/../../src/Otp/GoogleAuthenticator.php';
 
 use Otp\GoogleAuthenticator;
+use PHPUnit\Framework\TestCase;
 
 /**
  * GoogleAuthenticator test case.
  */
-class GoogleAuthenticatorTest extends \PHPUnit_Framework_TestCase
+class GoogleAuthenticatorTest extends TestCase
 {
 	/**
 	 * Tests getQrCodeUrl
@@ -80,9 +81,9 @@ class GoogleAuthenticatorTest extends \P
 	public function testGenerateRandom()
 	{
 	    // contains numbers 2-7 and letters A-Z in large letters, 16 chars long
-	    $this->assertRegExp('/[2-7A-Z]{16}/', GoogleAuthenticator::generateRandom());
+	    $this->assertMatchesRegularExpression('/[2-7A-Z]{16}/', GoogleAuthenticator::generateRandom());
 	
 	    // Can be told to make a longer secret
-	    $this->assertRegExp('/[2-7A-Z]{18}/', GoogleAuthenticator::generateRandom(18));
+	    $this->assertMatchesRegularExpression('/[2-7A-Z]{18}/', GoogleAuthenticator::generateRandom(18));
 	}
 }
--- a/tests/Otp/OtpTest.php
+++ b/tests/Otp/OtpTest.php
@@ -4,11 +4,12 @@ require_once __DIR__ . '/../../src/Otp/O
 require_once __DIR__ . '/../../src/Otp/Otp.php';
 
 use Otp\Otp;
+use PHPUnit\Framework\TestCase;
 
 /**
  * Otp test case.
  */
-class OtpTest extends \PHPUnit_Framework_TestCase
+class OtpTest extends TestCase
 {
 	/**
 	 *
@@ -21,7 +22,7 @@ class OtpTest extends \PHPUnit_Framework
 	/**
 	 * Prepares the environment before running a test.
 	 */
-	protected function setUp()
+	protected function setUp(): void
 	{
 		parent::setUp();
 		
@@ -32,7 +33,7 @@ class OtpTest extends \PHPUnit_Framework
 	/**
 	 * Cleans up the environment after running a test.
 	 */
-	protected function tearDown()
+	protected function tearDown(): void
 	{
 		$this->Otp = null;
 		
@@ -112,12 +113,10 @@ class OtpTest extends \PHPUnit_Framework
 		*/
 	}
 	
-	/**
-	 * @expectedException InvalidArgumentException
-	 * @expectedExceptionMessage Counter must be integer
-	 */
 	public function testHotpInvalidCounter()
 	{
+		$this->expectException(InvalidArgumentException::class);
+		$this->expectExceptionMessage("Counter must be integer");
 		$this->Otp->hotp($this->secret, 'a');
 	}
 
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -1,15 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
-
-<phpunit colors="true">
-    <testsuites>
-        <testsuite name="Otp Test Suite">
-            <directory>tests/Otp/</directory>
-        </testsuite>
-    </testsuites>
-
-    <filter>
-        <whitelist>
-            <directory suffix=".php">src/Otp/</directory>
-        </whitelist>
-    </filter>
+<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
+  <coverage>
+    <include>
+      <directory suffix=".php">src/Otp/</directory>
+    </include>
+  </coverage>
+  <testsuites>
+    <testsuite name="Otp Test Suite">
+      <directory>tests/Otp/</directory>
+    </testsuite>
+  </testsuites>
 </phpunit>
