$this->setupUser();
}
- protected function doApiRequest( $params, $data = null ) {
+ protected function doApiRequest( $params, $data = null, $appendModule = false ) {
$_SESSION = isset( $data[2] ) ? $data[2] : array();
$req = new FauxRequest( $params, true, $_SESSION );
$data[0] = $module->getResultData();
$data[1] = $req;
$data[2] = $_SESSION;
+
+ if( $appendModule ) $data[3] = $module;
return $data;
}
--- /dev/null
+<?php
+
+require_once dirname( __FILE__ ) . '/ApiFormatTestBase.php';
+
+/**
+ * @group API
+ */
+class ApiFormatPhpTest extends ApiFormatTestBase {
+
+ /*function setUp() {
+ parent::setUp();
+ $this->doLogin();
+ }*/
+
+
+ function testValidPHPSyntax() {
+
+ $data = $this->apiRequest( 'php', array( 'action' => 'query', 'meta' => 'siteinfo' ) );
+
+ $this->assertInternalType( 'array', unserialize( $data ) );
+ $this->assertGreaterThan( 0, count( (array) $data ) );
+
+
+ }
+
+}
--- /dev/null
+<?php
+
+require_once dirname( dirname( __FILE__ ) ) . '/ApiSetup.php';
+
+abstract class ApiFormatTestBase extends ApiTestSetup {
+
+ protected function apiRequest( $format, $params, $data = null ) {
+
+ $data = parent::doApiRequest( $params, $data, true );
+
+ $module = $data[3];
+
+ $printer = $module->createPrinterByName( $format );
+ $printer->setUnescapeAmps(false);
+
+ $printer->initPrinter(false, true);
+
+ ob_start();
+ $printer->execute();
+ $out = ob_get_clean();
+
+ $printer->closePrinter();
+
+ return $out;
+ }
+
+}
+