kissifrot / php-ixr

This is a fork of the original Incutio PHP XML-RPC library (IXR) SVN repo hosted on Google Code
http://scripts.incutio.com/xmlrpc/
Other
5 stars 6 forks source link

phpunit tests failing with phpunit11 #11

Open tenzap opened 1 month ago

tenzap commented 1 month ago

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 commented 1 month ago

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