wiki.techinc.nl/tests/phpunit/includes/api/ApiEntryPointTest.php
daniel d79af914ff Move code from api.php into ApiEntryPoint class
The goal is to unify the high level control flow in entry points by
making them use a shared base class. Eventually, this will allow
us to test all aspects of request handling, including response
headers and output buffer handling. That will however require
us to move quite a bit of logic from ApiMain into ApiEntryPoint.

Bug: T354216
Change-Id: I4ea1cbb8b2786c24deade7d5029d95fe0c2abc57
2024-02-02 19:27:53 +00:00

39 lines
875 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->establishOutputBufferLevel();
$entryPoint->run();
$output = $entryPoint->captureOutput();
$this->assertStringContainsString( '<!DOCTYPE html>', $output );
$this->assertStringContainsString( '<title>(pagetitle: (api-help-title))</title>', $output );
// TODO: Check caching headers and such.
}
}