MediaWiki  master
FormatJsonTest Class Reference

FormatJson. More...

Inheritance diagram for FormatJsonTest:
Collaboration diagram for FormatJsonTest:

Public Member Functions

 testParseTryFixing ( $value, $expected, $jsoncParses=true, $expectedJsonc=null)
 provideParseTryFixing More...
 

Static Public Member Functions

static provideParseTryFixing ()
 Test data for testParseTryFixing. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MediaWikiUnitTestCase
 setUp ()
 
 tearDown ()
 

Detailed Description

FormatJson.

Definition at line 6 of file FormatJsonTest.php.

Member Function Documentation

◆ provideParseTryFixing()

static FormatJsonTest::provideParseTryFixing ( )
static

Test data for testParseTryFixing.

Some PHP interpreters use json-c rather than the JSON.org canonical parser to avoid being encumbered by the "shall be used for Good, not Evil" clause of the JSON.org parser's license. By default, json-c parses in a non-strict mode which allows trailing commas for array and object delarations among other things, so our JSON_ERROR_SYNTAX rescue block is not always triggered. It however isn't lenient in exactly the same ways as our TRY_FIXING mode, so the assertions in this test are a bit more complicated than they ideally would be:

Optional third argument: true if json-c parses the value without intervention, false otherwise. Defaults to true.

Optional fourth argument: expected cannonical JSON serialization of json-c parsed result. Defaults to the second argument's value.

Definition at line 26 of file FormatJsonTest.php.

References false.

◆ testParseTryFixing()

FormatJsonTest::testParseTryFixing (   $value,
  $expected,
  $jsoncParses = true,
  $expectedJsonc = null 
)

provideParseTryFixing

Parameters
string$value
string | bool$expectedExpected result with strict parser
bool$jsoncParsesWill json-c parse this value without TRY_FIXING?
string | bool$expectedJsoncExpected result with lenient parser if different from the strict expectation

Definition at line 53 of file FormatJsonTest.php.

References $value, FormatJson\ALL_OK, class, FormatJson\encode(), null, FormatJson\parse(), and FormatJson\TRY_FIXING.


The documentation for this class was generated from the following file: