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

49 lines
983 B
PHP

<?php
use MediaWiki\Request\HeaderCallback;
/**
* @coversDefaultClass \MediaWiki\Request\HeaderCallback
*/
class HeaderCallbackTest extends MediaWikiUnitTestCase {
/**
* @dataProvider provideSanitizeSetCookie
* @covers ::sanitizeSetCookie
*/
public function testSanitizeSetCookie( $raw, $expectedSanitized ) {
$this->assertSame( $expectedSanitized, HeaderCallback::sanitizeSetCookie( $raw ) );
}
public static function provideSanitizeSetCookie() {
return [
[
[
'sessionId=38afes7a'
],
'sessionId=38afes7a',
],
[
[
'id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT'
],
'id=a3fWa; Expires=Wed, 21 Oct 2015 07:28:00 GMT',
],
[
[
'qwerty=219ffwef9w0f; Domain=somecompany.co.uk'
],
'qwerty=219ffwef...; Domain=somecompany.co.uk',
],
[
[
'sessionId=aaa',
'sessionId=bbbbbbbbbb',
'sessionId=ccc',
],
"sessionId=aaa\nsessionId=bbbbbbbb...\nsessionId=ccc",
],
];
}
}