ApiFormatRaw doesn't have tests
Closed, ResolvedPublic


In MediaWiki core, the ApiFormatRaw class is a bit special, it isn't exposed directly to users and basically spits out exactly whatever is passed to it. Regardless, we should still have tests for this functionality.

If you're not already familiar with PHPUnit tests, https://www.mediawiki.org/wiki/Manual:PHP_unit_testing/Writing_unit_tests has links to some good material on the basics of testing.

I would suggest creating something similar to ApiFormatNoneTest (instead of verifying there is no output, you'd verify the output is exactly the same...).

I'll mentor this for Google-Code-in-2017

Legoktm created this task.Dec 29 2017, 8:58 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptDec 29 2017, 8:58 AM
Aklapper updated the task description. (Show Details)Dec 29 2017, 4:23 PM
Anomie moved this task from Unsorted to Needs Code on the MediaWiki-API board.Dec 30 2017, 5:09 PM
Phantom42 claimed this task.Jan 1 2018, 5:15 PM
Phantom42 added a subscriber: Phantom42.

I will add tests for this!

Change 401405 had a related patch set uploaded (by Phantom42; owner: Phantom42):
[mediawiki/core@master] Add tests for ApiFormatRaw


I added tests to check that basic types are correctly encoded (ApiFormatRaw does not work with arrays or objects). I also added test case to check that exception is thrown if mime type or text are not given.

Please note that I didn't use parent encodeData function, but overrode it. That is because ApiFormatRaw can't be created using module manager and requires some custom ApiResult structure.

If anything needs fixing / improving, please tell and I will do it!

Change 401405 merged by jenkins-bot:
[mediawiki/core@master] Add tests for ApiFormatRaw


Legoktm closed this task as Resolved.Jan 4 2018, 9:29 PM