3 use MediaWiki\Content\Content
;
4 use MediaWiki\Content\ContentHandler
;
5 use MediaWiki\Content\Renderer\ContentParseParams
;
6 use MediaWiki\Parser\ParserOutput
;
8 class DummyContentHandlerForTesting
extends ContentHandler
{
10 public function __construct( $dataModel, $formats = [ DummyContentForTesting
::MODEL_ID
] ) {
11 parent
::__construct( $dataModel, $formats );
14 protected function getContentClass() {
15 return DummyContentForTesting
::class;
19 * @see ContentHandler::serializeContent
21 * @param Content $content
22 * @param string|null $format
26 public function serializeContent( Content
$content, $format = null ) {
27 return $content->serialize();
31 * @see ContentHandler::unserializeContent
34 * @param string|null $format Unused.
38 public function unserializeContent( $blob, $format = null ) {
39 return new DummyContentForTesting( $blob );
43 * Creates an empty Content object of the type supported by this ContentHandler.
44 * @return DummyContentForTesting
46 public function makeEmptyContent() {
47 return new DummyContentForTesting( '' );
50 public function generateHTMLOnEdit(): bool {
55 * @see ContentHandler::fillParserOutput()
58 * @param Content $content
59 * @param ContentParseParams $cpoParams
60 * @param ParserOutput &$output The output object to fill (reference).
62 protected function fillParserOutput(
64 ContentParseParams
$cpoParams,
67 '@phan-var DummyContentForTesting $content';
68 $output = new ParserOutput( $content->getNativeData() );