summaryrefslogtreecommitdiff
path: root/tests/phpunit/includes/api/format/ApiFormatTestBase.php
blob: 5f6d53cedd9ff820897f994012be4d21d277c817 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php

abstract class ApiFormatTestBase extends ApiTestCase {

	/**
	 * @param string $format
	 * @param array $params
	 * @param array $data
	 *
	 * @return string
	 */
	protected function apiRequest( $format, $params, $data = null ) {
		$data = parent::doApiRequest( $params, $data, true );

		/** @var ApiMain $module */
		$module = $data[3];

		$printer = $module->createPrinterByName( $format );
		$printer->setUnescapeAmps( false );

		$printer->initPrinter( false );

		ob_start();
		$printer->execute();
		$out = ob_get_clean();

		$printer->closePrinter();

		return $out;
	}

}