wiki.techinc.nl/tests/phpunit/includes/externalstore/ExternalStoreTest.php
Tim Starling 5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00

42 lines
1.2 KiB
PHP

<?php
class ExternalStoreTest extends MediaWikiIntegrationTestCase {
/**
* @covers ExternalStore::fetchFromURL
*/
public function testExternalFetchFromURL_noExternalStores() {
$this->setService(
'ExternalStoreFactory',
new ExternalStoreFactory( [], [], 'test-id' )
);
$this->assertFalse(
ExternalStore::fetchFromURL( 'ForTesting://cluster1/200' ),
'Deny if wgExternalStores is not set to a non-empty array'
);
}
public static function provideFetchFromURLWithStore() {
yield [ 'Hello', 'ForTesting://cluster1/200', 'Allow FOO://cluster1/200' ];
yield [ 'Hello', 'ForTesting://cluster1/300/0', 'Allow FOO://cluster1/300/0' ];
// cases for r68900
yield [ false, 'ftp.example.org', 'Deny domain ftp.example.org' ];
yield [ false, '/example.txt', 'Deny path /example.txt' ];
yield [ false, 'http://', 'Deny protocol http://' ];
}
/**
* @covers ExternalStore::fetchFromURL
* @dataProvider provideFetchFromURLWithStore
*/
public function testExternalFetchFromURL_someExternalStore( $expect, $url, $msg ) {
$this->setService(
'ExternalStoreFactory',
new ExternalStoreFactory( [ 'ForTesting' ], [ 'ForTesting://cluster1' ], 'test-id' )
);
$this->assertSame( $expect, ExternalStore::fetchFromURL( $url ), $msg );
}
}