wiki.techinc.nl/tests/phpunit/unit/includes/cache/CacheKeyHelperTest.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

31 lines
975 B
PHP

<?php
use MediaWiki\Cache\CacheKeyHelper;
use MediaWiki\Page\PageIdentityValue;
use MediaWiki\Page\PageReference;
use MediaWiki\Page\PageReferenceValue;
use MediaWiki\Title\Title;
/**
* @group Cache
*/
class CacheKeyHelperTest extends MediaWikiUnitTestCase {
public static function provideKeyForPage() {
// NOTE: code changes that break these test cases
// will result in incompatible cache keys when deployed!
yield [ new PageReferenceValue( NS_USER, 'Yulduz', PageReference::LOCAL ), 'ns2:Yulduz' ];
yield [ new PageIdentityValue( 7, NS_USER, 'Yulduz', PageReference::LOCAL ), 'ns2:Yulduz' ];
yield [ Title::makeTitle( NS_USER, 'Yulduz' ), 'ns2:Yulduz' ];
yield [ new TitleValue( NS_USER, 'Yulduz' ), 'ns2:Yulduz' ];
}
/**
* @dataProvider provideKeyForPage
* @covers MediaWiki\Cache\CacheKeyHelper::getKeyForPage
*/
public function testKeyForPage( $page, $key ) {
$this->assertSame( $key, CacheKeyHelper::getKeyForPage( $page ) );
}
}