u01jmg3 / ics-parser

Parser for iCalendar Events • PHP 8+, 7 (≥ 7.4), 5 (≥ 5.6)
MIT License
439 stars 144 forks source link

Upgrade to phpunit 9 #309

Closed tacman closed 2 years ago

tacman commented 2 years ago

This fixes #308, so that tests can be run using php8.1

There are 3 tests that were removed (commented out).

// $this->assertAttributeEquals($expectedDateString, 'dtstart', $event, $message . 'dtstart mismatch (timestamp is okay)');

I'm sure there's a better way to do those tests, there's no exact replacement. See a description here:

https://thephp.cc/articles/migrating-to-phpunit-9

kktsvetkov commented 2 years ago

I tried to run the tests locally, but I get a ton of crap because of the old PHPUnit:

kt@kt-ThinkPad-T460:~/Projects/johngrogg.ics-parser$ php vendor/bin/phpunit 
PHP Warning:  Private methods cannot be final as they are never overridden by other classes in /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/Util/Configuration.php on line 162
PHP Stack trace:
PHP   1. {main}() /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main($exit = *uninitialized*) /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/phpunit:52
PHP   3. PHPUnit_TextUI_Command->run($argv = [0 => 'vendor/bin/phpunit'], $exit = TRUE) /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/TextUI/Command.php:116
PHP   4. PHPUnit_TextUI_Command->handleArguments($argv = [0 => 'vendor/bin/phpunit']) /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/TextUI/Command.php:127
PHP   5. Composer\Autoload\ClassLoader->loadClass($class = 'PHPUnit_Util_Configuration') /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/TextUI/Command.php:718
PHP   6. Composer\Autoload\includeFile($file = '/home/kt/Projects/johngrogg.ics-parser/vendor/composer/../phpunit/phpunit/src/Util/Configuration.php') /home/kt/Projects/johngrogg.ics-parser/vendor/composer/ClassLoader.php:428
PHP Fatal error:  Cannot acquire reference to $GLOBALS in /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/Util/Configuration.php on line 504
PHP Stack trace:
PHP   1. {main}() /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main($exit = *uninitialized*) /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/phpunit:52
PHP   3. PHPUnit_TextUI_Command->run($argv = [0 => 'vendor/bin/phpunit'], $exit = TRUE) /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/TextUI/Command.php:116
PHP   4. PHPUnit_TextUI_Command->handleArguments($argv = [0 => 'vendor/bin/phpunit']) /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/TextUI/Command.php:127
PHP   5. Composer\Autoload\ClassLoader->loadClass($class = 'PHPUnit_Util_Configuration') /home/kt/Projects/johngrogg.ics-parser/vendor/phpunit/phpunit/src/TextUI/Command.php:718
PHP   6. Composer\Autoload\includeFile($file = '/home/kt/Projects/johngrogg.ics-parser/vendor/composer/../phpunit/phpunit/src/Util/Configuration.php') /home/kt/Projects/johngrogg.ics-parser/vendor/composer/ClassLoader.php:428

@tacman I managed to get the tests running by upgrading PHPUnit and replacing these

$this->assertAttributeEquals($expectedDateString, 'dtstart', $event, $message . 'dtstart mismatch (timestamp is okay)');

with these

$this->assertEquals($expectedDateString, $event->dtstart, $message . 'dtstart mismatch (timestamp is okay)');
u01jmg3 commented 2 years ago

See 63866d7, fd145ae