wiki.techinc.nl/tests/phpunit/integration/includes/export/WikiExporterFactoryTest.php
Tim Starling 6ccfe5d5c9 Fix PHP 8.0 failure of WikiExporterFactoryTest
In PHP 7, "some unlikely string 2" was a valid value for the $text
parameter to XmlDumpWriter::__construct(), because non-strict comparison
was used, so "some unlikely string 2" was coerced to integer 0 which is
equal to WRITE_CONTENT. In PHP 8.0, non-strict comparison has changed such
that "some unlikely string 2" != 0.

Pass strict=true to in_array() so that the test fails on both versions.
Please review for potential production impact.

Fix the test so that it passes after this change.

Bug: T283275
Change-Id: I5a84fb70db9d02ea10f87299eb41f80ba8fc787c
2022-01-21 15:20:57 +11:00

46 lines
966 B
PHP

<?php
namespace MediaWiki\Tests\Export;
use FactoryArgTestTrait;
use MediaWiki\Export\WikiExporterFactory;
use MediaWikiIntegrationTestCase;
use WikiExporter;
use XmlDumpWriter;
/**
* @covers \MediaWiki\Export\WikiExporterFactory
*/
class WikiExporterFactoryTest extends MediaWikiIntegrationTestCase {
use FactoryArgTestTrait;
protected function setUp(): void {
parent::setUp();
$this->setMwGlobals( [
'XmlDumpSchemaVersion' => XmlDumpWriter::$supportedSchemas[0],
] );
}
protected static function getFactoryClass() {
return WikiExporterFactory::class;
}
protected static function getInstanceClass() {
return WikiExporter::class;
}
protected static function getExtraClassArgCount() {
return 4;
}
protected function getFactoryMethodName() {
return 'getWikiExporter';
}
protected function getOverriddenMockValueForParam( $param ) {
if ( $param->getName() === 'text' ) {
return [ WikiExporter::TEXT ];
}
return [];
}
}