Debian Codegraph @

tests/phpunit/mocks/content/DummyContentHandlerForTesting.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Content\Content;
4 use MediaWiki\Content\ContentHandler;
5 use MediaWiki\Content\Renderer\ContentParseParams;
6 use MediaWiki\Parser\ParserOutput;
7
8 class DummyContentHandlerForTesting extends ContentHandler {
9
10 public function __construct( $dataModel, $formats = [ DummyContentForTesting::MODEL_ID ] ) {
11 parent::__construct( $dataModel, $formats );
12 }
13
14 protected function getContentClass() {
15 return DummyContentForTesting::class;
16 }
17
18 /**
19 * @see ContentHandler::serializeContent
20 *
21 * @param Content $content
22 * @param string|null $format
23 *
24 * @return string
25 */
26 public function serializeContent( Content $content, $format = null ) {
27 return $content->serialize();
28 }
29
30 /**
31 * @see ContentHandler::unserializeContent
32 *
33 * @param string $blob
34 * @param string|null $format Unused.
35 *
36 * @return Content
37 */
38 public function unserializeContent( $blob, $format = null ) {
39 return new DummyContentForTesting( $blob );
40 }
41
42 /**
43 * Creates an empty Content object of the type supported by this ContentHandler.
44 * @return DummyContentForTesting
45 */
46 public function makeEmptyContent() {
47 return new DummyContentForTesting( '' );
48 }
49
50 public function generateHTMLOnEdit(): bool {
51 return false;
52 }
53
54 /**
55 * @see ContentHandler::fillParserOutput()
56 *
57 * @since 1.38
58 * @param Content $content
59 * @param ContentParseParams $cpoParams
60 * @param ParserOutput &$output The output object to fill (reference).
61 */
62 protected function fillParserOutput(
63 Content $content,
64 ContentParseParams $cpoParams,
65 ParserOutput &$output
66 ) {
67 '@phan-var DummyContentForTesting $content';
68 $output = new ParserOutput( $content->getNativeData() );
69 }
70 }