ApiFormatRaw doesn't have tests
Closed, ResolvedPublic

Description

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.Fri, Dec 29, 8:58 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFri, Dec 29, 8:58 AM
Aklapper updated the task description. (Show Details)Fri, Dec 29, 4:23 PM
Anomie moved this task from Unsorted to Needs Code on the MediaWiki-API board.Sat, Dec 30, 5:09 PM
Phantom42 claimed this task.Mon, Jan 1, 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

https://gerrit.wikimedia.org/r/401405

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

https://gerrit.wikimedia.org/r/401405

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