ezyang / htmlpurifier

Standards compliant HTML filter written in PHP
http://htmlpurifier.org
GNU Lesser General Public License v2.1
3.07k stars 327 forks source link

Test Suite not compatible with PHP 8 due to changes in the reflection API #278

Closed TimWolla closed 2 years ago

TimWolla commented 3 years ago
$ php tests/index.php 

Deprecated: Method ReflectionParameter::getClass() is deprecated in /pwd/simpletest/reflection_php5.php on line 362

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/reflection_php5.php on line 363

*snip*

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/reflection_php5.php on line 363
All HTML Purifier tests on PHP 8.0.0RC2
Exception 1!
Unexpected PHP Error [Method ReflectionParameter::getClass() is deprecated] severity [8192] in [/pwd/simpletest/reflection_php5.php line 362]
    in testConstruction
    in HTMLPurifier_AttrCollectionsTest
Exception 2!

*snip*

Unexpected PHP Error [Method ReflectionParameter::isArray() is deprecated] severity [8192] in [/pwd/simpletest/reflection_php5.php line 363]
    in test
    in HTMLPurifier_AttrDef_CSS_CompositeTest
Exception 17!
Unexpected PHP Error [require(Net/IDNA2.php): Failed to open stream: No such file or directory] severity [2] in [/pwd/tests/common.php line 16]
    in testIDNA
    in HTMLPurifier_AttrDef_URI_HostTest

Fatal error: Uncaught Error: Failed opening required 'Net/IDNA2.php' (include_path='/pwd/library:/pwd/extras:.:') in /pwd/tests/common.php:16
Stack trace:
#0 /pwd/library/HTMLPurifier/AttrDef/URI/Host.php(110): test_autoload('Net_IDNA2')
#1 /pwd/tests/HTMLPurifier/AttrDefHarness.php(19): HTMLPurifier_AttrDef_URI_Host->validate('\xE4\xB8\xAD\xE6\x96\x87.com.cn', Object(HTMLPurifier_Config), Object(HTMLPurifier_Context))
#2 /pwd/tests/HTMLPurifier/AttrDef/URI/HostTest.php(51): HTMLPurifier_AttrDefHarness->assertDef('\xE4\xB8\xAD\xE6\x96\x87.com.cn', 'xn--fiq228c.com...')
#3 /pwd/simpletest/invoker.php(60): HTMLPurifier_AttrDef_URI_HostTest->testIDNA()
#4 /pwd/simpletest/invoker.php(119): SimpleInvoker->invoke('testIDNA')
#5 /pwd/simpletest/exceptions.php(33): SimpleInvokerDecorator->invoke('testIDNA')
#6 /pwd/simpletest/invoker.php(119): SimpleExceptionTrappingInvoker->invoke('testIDNA')
#7 /pwd/simpletest/errors.php(32): SimpleInvokerDecorator->invoke('testIDNA')
#8 /pwd/simpletest/test_case.php(132): SimpleErrorTrappingInvoker->invoke('testIDNA')
#9 /pwd/simpletest/test_case.php(564): SimpleTestCase->run(Object(HTMLPurifier_SimpleTest_TextReporter))
#10 /pwd/tests/index.php(219): TestSuite->run(Object(HTMLPurifier_SimpleTest_TextReporter))
#11 {main}
  thrown in /pwd/tests/common.php on line 16
ezyang commented 3 years ago

Does it work if you update to master simpletest in https://github.com/simpletest/simpletest

TimWolla commented 3 years ago

I needed to adjust the simpletest location, because:

root@409808dfd5df:/pwd# php tests/index.php 

Warning: require_once(/pwd/simpletest/unit_tester.php): Failed to open stream: No such file or directory in /pwd/tests/common.php on line 44

Fatal error: Uncaught Error: Failed opening required '/pwd/simpletest/unit_tester.php' (include_path='.:') in /pwd/tests/common.php:44
Stack trace:
#0 /pwd/tests/index.php(47): require()
#1 {main}
  thrown in /pwd/tests/common.php on line 44

Unfortunately that didn't help:

root@409808dfd5df:/pwd# php tests/index.php 

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/src/reflection.php on line 413

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/src/reflection.php on line 413

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/src/reflection.php on line 413

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/src/reflection.php on line 413

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/src/reflection.php on line 413

Deprecated: Method ReflectionParameter::isArray() is deprecated in /pwd/simpletest/src/reflection.php on line 413

Fatal error: Abstract function HTMLPurifier_AttrDefTestable::validate() cannot contain body in /pwd/simpletest/src/mock_objects.php(1417) : eval()'d code on line 138
bytestream commented 3 years ago

I sent a PR https://github.com/simpletest/simpletest/pull/77

However, having resolved the abstract method issue, there are still issues with references which are blocking us from testing HTMLPurifier on PHP 8. Testing references in v1.2.0 looks completely broken :grimacing: :

All HTML Purifier tests on PHP 8.0.6
1) [Object: of HTMLPurifier_DefinitionCache_Serializer] and [Object: of HTMLPurifier_DefinitionCache_Serializer] should reference the same object at [/v/tests/HTMLPurifier/DefinitionCacheFactoryTest.php line 52]
        in test_create_recycling
        in HTMLPurifier_DefinitionCacheFactoryTest
2) [Object: of HTMLPurifier_ElementDef] and [Object: of HTMLPurifier_ElementDef] should reference the same object at [/v/tests/HTMLPurifier/HTMLModuleTest.php line 42]
        in test_addElement
        in HTMLPurifier_HTMLModuleTest
3) [Object: of HTMLPurifier_ElementDef] and [Object: of HTMLPurifier_ElementDef] should reference the same object at [/v/tests/HTMLPurifier/HTMLModuleTest.php line 115]
        in test_addBlankElement
        in HTMLPurifier_HTMLModuleTest
4) [Object: of HTMLPurifier] and [Object: of HTMLPurifier] should reference the same object at [/v/tests/HTMLPurifierTest.php line 46]
        in testGetInstance
        in HTMLPurifierTest
Test cases run: 220/220, Passes: 2780, Failures: 4, Exceptions: 0