Page MenuHomePhabricator
Paste P7243

(An Untitled Masterwork)
ActivePublic

Authored by hashar on Jun 11 2018, 1:36 PM.
Tags
None
Referenced Files
F21789640:
Jun 11 2018, 1:36 PM
Subscribers
None
<?php
// Exercise https://gerrit.wikimedia.org/r/c/mediawiki/core/+/439289 for T191537
public function testPostSendJobDoesNotSetCookie() {
// Prevent updates from running
$this->setMwGlobals( 'wgCommandLineMode', false );
// A job that attempts to set a cookie
DeferredUpdates::addCallableUpdate( function () {
WebResponse::setCookie( 'JobCookie', 'yes' );
} );
$this->assertCount( 1,
DeferredUpdates::getPendingUpdates( DeferredUpdates::POSTSEND ) );
$mw = new MediaWiki();
$mw->doPostOutputShutdown();
$this->assertCount( 0,
DeferredUpdates::getPendingUpdates( DeferredUpdates::POSTSEND ),
'Cookie setting job must be run'
);
$this->assertFalse(
WebResponse::hasCookies(), 'Job must not set cookie in post-send' );
// stack traces because of headers already have been sent, but the code is good
}