Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4072806
JsonSchemaAssertionTraitTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
JsonSchemaAssertionTraitTest.php
View Options
<?php
use
PHPUnit\Framework\AssertionFailedError
;
/**
* @covers JsonSchemaAssertionTrait
* @group MediaWikiIntegrationTestCaseTest
*/
class
JsonSchemaAssertionTraitTest
extends
MediaWikiUnitTestCase
{
use
JsonSchemaAssertionTrait
;
public
static
function
provideValidJson
()
{
$dir
=
__DIR__
.
'/json'
;
yield
[
"$dir/valid1.json"
,
"$dir/schema1.json"
];
yield
[
"$dir/valid2.json"
,
"$dir/schema2.json"
];
}
/**
* @dataProvider provideValidJson
*/
public
function
testAssertMatchesJsonSchema_valid
(
$dataFile
,
$schemaFile
)
{
$jsonString
=
file_get_contents
(
$dataFile
);
$dir
=
__DIR__
.
'/json'
;
$this
->
assertMatchesJsonSchema
(
$schemaFile
,
$jsonString
,
[
'https://www.mediawiki.org/test-schema/test1#'
=>
"$dir/schema1.json"
,
'https://www.mediawiki.org/test-schema/test2#'
=>
"$dir/schema2.json"
,
'https://www.mediawiki.org/test-schema/test3#'
=>
"$dir/schema3.json"
,
]
);
}
public
static
function
provideInvalidJson
()
{
$dir
=
__DIR__
.
'/json'
;
// T391586 - Malformed JSON doesn't pass linting while making releases, so
// to have a txt file extension.
foreach
(
glob
(
__DIR__
.
'/json/invalid*.{txt,json}'
)
as
$file
)
{
yield
$file
=>
[
$file
,
"$dir/schema1.json"
];
}
}
/**
* @dataProvider provideInvalidJson
*/
public
function
testAssertMatchesJsonSchema_invalid
(
$dataFile
,
$schemaFile
)
{
$dir
=
__DIR__
.
'/json'
;
$jsonString
=
file_get_contents
(
$dataFile
);
$this
->
expectException
(
AssertionFailedError
::
class
);
$this
->
assertMatchesJsonSchema
(
$schemaFile
,
$jsonString
,
[
'https://www.mediawiki.org/test-schema/test1#'
=>
"$dir/schema1.json"
,
'https://www.mediawiki.org/test-schema/test2#'
=>
"$dir/schema2.json"
,
'https://www.mediawiki.org/test-schema/test3#'
=>
"$dir/schema3.json"
,
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Aug 17 2026, 08:49 (11 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b9/f7/9562d913b15d2d8cddf59f92b1f9
Default Alt Text
JsonSchemaAssertionTraitTest.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment