Index: trunk/phase3/tests/phpunit/includes/api/ApiSetup.php |
— | — | @@ -17,7 +17,7 @@ |
18 | 18 | $this->setupUser(); |
19 | 19 | } |
20 | 20 | |
21 | | - protected function doApiRequest( $params, $data = null ) { |
| 21 | + protected function doApiRequest( $params, $data = null, $appendModule = false ) { |
22 | 22 | $_SESSION = isset( $data[2] ) ? $data[2] : array(); |
23 | 23 | |
24 | 24 | $req = new FauxRequest( $params, true, $_SESSION ); |
— | — | @@ -27,6 +27,8 @@ |
28 | 28 | $data[0] = $module->getResultData(); |
29 | 29 | $data[1] = $req; |
30 | 30 | $data[2] = $_SESSION; |
| 31 | + |
| 32 | + if( $appendModule ) $data[3] = $module; |
31 | 33 | |
32 | 34 | return $data; |
33 | 35 | } |
Index: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php |
— | — | @@ -0,0 +1,26 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once dirname( __FILE__ ) . '/ApiFormatTestBase.php'; |
| 5 | + |
| 6 | +/** |
| 7 | + * @group API |
| 8 | + */ |
| 9 | +class ApiFormatPhpTest extends ApiFormatTestBase { |
| 10 | + |
| 11 | + /*function setUp() { |
| 12 | + parent::setUp(); |
| 13 | + $this->doLogin(); |
| 14 | + }*/ |
| 15 | + |
| 16 | + |
| 17 | + function testValidPHPSyntax() { |
| 18 | + |
| 19 | + $data = $this->apiRequest( 'php', array( 'action' => 'query', 'meta' => 'siteinfo' ) ); |
| 20 | + |
| 21 | + $this->assertInternalType( 'array', unserialize( $data ) ); |
| 22 | + $this->assertGreaterThan( 0, count( (array) $data ) ); |
| 23 | + |
| 24 | + |
| 25 | + } |
| 26 | + |
| 27 | +} |
Property changes on: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatPhpTest.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 28 | + native |
Index: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php |
— | — | @@ -0,0 +1,28 @@ |
| 2 | +<?php |
| 3 | + |
| 4 | +require_once dirname( dirname( __FILE__ ) ) . '/ApiSetup.php'; |
| 5 | + |
| 6 | +abstract class ApiFormatTestBase extends ApiTestSetup { |
| 7 | + |
| 8 | + protected function apiRequest( $format, $params, $data = null ) { |
| 9 | + |
| 10 | + $data = parent::doApiRequest( $params, $data, true ); |
| 11 | + |
| 12 | + $module = $data[3]; |
| 13 | + |
| 14 | + $printer = $module->createPrinterByName( $format ); |
| 15 | + $printer->setUnescapeAmps(false); |
| 16 | + |
| 17 | + $printer->initPrinter(false, true); |
| 18 | + |
| 19 | + ob_start(); |
| 20 | + $printer->execute(); |
| 21 | + $out = ob_get_clean(); |
| 22 | + |
| 23 | + $printer->closePrinter(); |
| 24 | + |
| 25 | + return $out; |
| 26 | + } |
| 27 | + |
| 28 | +} |
| 29 | + |
Property changes on: trunk/phase3/tests/phpunit/includes/api/format/ApiFormatTestBase.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 30 | + native |