aboutsummaryrefslogtreecommitdiffstats
path: root/tests/phpunit/includes/changes
diff options
context:
space:
mode:
authorDaimona Eaytoy <daimona.wiki@gmail.com>2021-03-25 11:38:39 +0100
committerDaimona Eaytoy <daimona.wiki@gmail.com>2022-10-08 02:03:55 +0200
commit7a494d1fa481b146a77cedc1e691205e3be3ee93 (patch)
tree4ee1cac94270da8da3b59dc14b18ab163aa3081c /tests/phpunit/includes/changes
parent70b4f005b1f4cb3741c09f9a1465bc6e1ecc2fd2 (diff)
downloadmediawikicore-7a494d1fa481b146a77cedc1e691205e3be3ee93.tar.gz
mediawikicore-7a494d1fa481b146a77cedc1e691205e3be3ee93.zip
tests: Upgrade PHPUnit from 8.5+ to 9.5+
* DeprecatedHooksTest: Don't use assertContains(). * Replace uses of deprecated asserts: - assertFileNotExists() -> assertFileDoesNotExist() * Update hierarchy of MediaWikiPHPUnitResultPrinter, since ResultPrinter is an interface in PHPUnit 9. * Remove temporary forward-compat methods. * Remove directories that don't exist from tests/phpunit/suite.xml, since they now make PHPUnit exit: - tests/phpunit/skins, it used to have SideBarTest, then moved to tests/phpunit/includes/skins - tests/phpunit/documentation, it used to have ReleaseNotesTest, then moved to tests/phpunit/unit/documentation * Update configuration with --migrate-configuration and reformat. * Avoid redefining getMockBuilder() in ActionModuleBasedHandlerTestTrait, use a @method annotation instead. * In RCCacheEntryFactoryTest, avoid using internal PHPUnit logic for HTML validation, and use native PHP methods instead. The code was copied from Xml::load (moved to \Xml\Loader::load in PHPUnit 9) and simplified for this use case. Bug: T243600 Bug: T262076 Change-Id: I851b9158b73d0cfc315eed9d63b15c54b05895e3
Diffstat (limited to 'tests/phpunit/includes/changes')
-rw-r--r--tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php18
1 files changed, 16 insertions, 2 deletions
diff --git a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
index ea68d1cb7e69..29974de98d16 100644
--- a/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
+++ b/tests/phpunit/includes/changes/RCCacheEntryFactoryTest.php
@@ -135,8 +135,22 @@ class RCCacheEntryFactoryTest extends MediaWikiLangTestCase {
}
private function assertValidHTML( $actual ) {
- // Throws if invalid
- $doc = \PHPUnit\Util\Xml::load( $actual, /* isHtml */ true );
+ $this->assertNotSame( '', $actual );
+ $document = new DOMDocument;
+
+ $oldUseInternalErrors = libxml_use_internal_errors( true );
+
+ try {
+ $loaded = $document->loadHTML( $actual );
+ $message = '';
+ foreach ( libxml_get_errors() as $error ) {
+ $message .= "\n" . $error->message;
+ }
+
+ $this->assertNotFalse( $loaded, $message ?: 'Invalid for unknown reason' );
+ } finally {
+ libxml_use_internal_errors( $oldUseInternalErrors );
+ }
}
private function assertUserLinks( $user, $cacheEntry ) {