wiki.techinc.nl/tests/phpunit/includes/api/ApiEntryPointTest.php
daniel 1b6e29d7af flushOutputBuffer: improve error handling
This improves handling of edge cases around flushing buffers:
- Distingush clearly between "headers sent" and "all output sent"
  states.
- Warn when trying to flush output after output was already sent to the
  client.
- Avoid looping indefinitely when failing to delete a buffer, to work
  around a quirk of PHP's zlib.compression buffer.

Follow-up: I4ea116d60030da92be14f0283ce4dc4877c4ca13
Bug: T356578
Change-Id: Iaf34a48b89e969b8e26328f0d2512ad22ef48212
2024-02-09 12:10:59 +01:00

39 lines
872 B
PHP

<?php
use MediaWiki\Api\ApiEntryPoint;
use MediaWiki\Request\FauxRequest;
use MediaWiki\Tests\MockEnvironment;
/**
* @group API
* @group Database
* @group medium
*
* @covers \MediaWiki\Api\ApiEntryPoint
*/
class ApiEntryPointTest extends ApiTestCase {
public function testSimpleRequest() {
$request = new FauxRequest();
$request->setRequestURL( '/w/api.php' );
$env = new MockEnvironment( $request );
$context = $env->makeFauxContext();
$entryPoint = new ApiEntryPoint(
$context,
$env,
$this->getServiceContainer()
);
$entryPoint->enableOutputCapture();
$entryPoint->run();
$output = $entryPoint->getCapturedOutput();
$this->assertStringContainsString( '<!DOCTYPE html>', $output );
$this->assertStringContainsString( '<title>(pagetitle: (api-help-title))</title>', $output );
// TODO: Check caching headers and such.
}
}