I7b37295e is going to be changing around how ApiResult works, which is going to need corresponding changes in the formatters. So it would probably be a good idea to have a decent starting point to catch any breakage. The non-backwards-compatible changes to ApiFormatTestBase shouldn't be a concern, as no extensions in Gerrit reference this class or any /ApiFormat.*Test/ class. This also fixes two small bugs in ApiFormatWddx (null handling and spacing for non-fm slow path) discovered during testing, and works around some HHVM wddx extension bugs. Bug: T85236 Change-Id: I9cdf896e7070ed51e42625d61609ad9ef91cd567
42 lines
1.1 KiB
PHP
42 lines
1.1 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group API
|
|
* @covers ApiFormatJson
|
|
*/
|
|
class ApiFormatJsonTest extends ApiFormatTestBase {
|
|
|
|
protected $printerName = 'json';
|
|
|
|
public static function provideGeneralEncoding() {
|
|
return array(
|
|
// Basic types
|
|
array( array( null ), '[null]' ),
|
|
array( array( true ), '[true]' ),
|
|
array( array( false ), '[false]' ),
|
|
array( array( 42 ), '[42]' ),
|
|
array( array( 42.5 ), '[42.5]' ),
|
|
array( array( 1e42 ), '[1.0e+42]' ),
|
|
array( array( 'foo' ), '["foo"]' ),
|
|
array( array( 'fóo' ), '["f\u00f3o"]' ),
|
|
array( array( 'fóo' ), '["fóo"]', array( 'utf8' => 1 ) ),
|
|
|
|
// Arrays and objects
|
|
array( array( array() ), '[[]]' ),
|
|
array( array( array( 1 ) ), '[[1]]' ),
|
|
array( array( array( 'x' => 1 ) ), '[{"x":1}]' ),
|
|
array( array( array( 2 => 1 ) ), '[{"2":1}]' ),
|
|
array( array( (object)array() ), '[{}]' ),
|
|
|
|
// Content
|
|
array( array( '*' => 'foo' ), '{"*":"foo"}' ),
|
|
|
|
// Callbacks
|
|
array( array( 1 ), '/**/myCallback([1])', array( 'callback' => 'myCallback' ) ),
|
|
|
|
// Cross-domain mangling
|
|
array( array( '< Cross-Domain-Policy >' ), '["\u003C Cross-Domain-Policy \u003E"]' ),
|
|
);
|
|
}
|
|
|
|
}
|