Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phpunit tests failing with phpunit11 #11

Open
tenzap opened this issue Jul 21, 2024 · 1 comment
Open

phpunit tests failing with phpunit11 #11

tenzap opened this issue Jul 21, 2024 · 1 comment

Comments

@tenzap
Copy link

tenzap commented Jul 21, 2024

While trying to run the phpunit tests with phpunit11 there errors/warnings are reported.
It also mentions a deprecation warning for phpunit12

phpunit
PHPUnit 11.1.2 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.2.18
Configuration: /<<PKGBUILDDIR>>/phpunit.xml

There was 1 PHPUnit error:

1) IXR\tests\DataType\DateTest::testParseIso
The data provider specified for IXR\tests\DataType\DateTest::testParseIso is invalid
Data Provider method IXR\tests\DataType\DateTest::provideDates() is not static

/<<PKGBUILDDIR>>/tests/DataType/DateTest.php:47

--

There were 2 PHPUnit test runner warnings:

1) No tests found in class "IXR\tests\DataType\DateTest".

2) Class MessageTest cannot be found in /<<PKGBUILDDIR>>/tests/Message/MessageTest.php

--

There were 2 PHPUnit test runner deprecations:

1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

2) Metadata found in doc-comment for method IXR\tests\DataType\DateTest::testParseIso(). Metadata in doc-comments is deprecated and will no longer be supported in PHPUnit 12. Update your test code to use attributes instead.

No tests executed!

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1070558

@tenzap
Copy link
Author

tenzap commented Jul 21, 2024

Suggested patch for the 1st error:

--- a/tests/DataType/DateTest.php
+++ b/tests/DataType/DateTest.php
@@ -12,7 +12,7 @@
      * @return array
      * @see testParseIso
      */
-    function provideDates()
+    static function provideDates()
     {
         return [
             // full datetime, different formats
@@ -44,10 +44,10 @@
      * @param mixed $input
      * @param int $expect
      */
-    function testParseIso($input, $expect)
+    static function testParseIso($input, $expect)
     {
         $dt = new Date($input);
-        $this->assertEquals($expect, $dt->getTimeStamp());
+        self::assertEquals($expect, $dt->getTimeStamp());
     }
 
 }
--- a/tests/Message/MessageTest.php
+++ b/tests/Message/MessageTest.php
@@ -5,7 +5,7 @@
 use IXR\Message\Message;
 use PHPUnit\Framework\TestCase;
 
-class ixr_library_ixr_message_test extends TestCase
+class MessageTest extends TestCase
 {
 
     function testUntypedValue()

This change still works with phpunit 9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant