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 }