Debian Codegraph @

tests/phpunit/mocks/content/DummyContentForTesting.php

raw symbols SCIP
1 <?php
2
3 use MediaWiki\Content\AbstractContent;
4 use MediaWiki\Content\Content;
5
6 class DummyContentForTesting extends AbstractContent {
7
8 public const MODEL_ID = "testing";
9
10 /** @var mixed */
11 private $data;
12
13 public function __construct( $data ) {
14 parent::__construct( self::MODEL_ID );
15
16 $this->data = $data;
17 }
18
19 public function serialize( $format = null ) {
20 return $this->data;
21 }
22
23 /**
24 * @return string A string representing the content in a way useful for
25 * building a full text search index. If no useful representation exists,
26 * this method returns an empty string.
27 */
28 public function getTextForSearchIndex() {
29 return '';
30 }
31
32 /**
33 * @return string|bool The wikitext to include when another page includes this content,
34 * or false if the content is not includable in a wikitext page.
35 */
36 public function getWikitextForTransclusion() {
37 return false;
38 }
39
40 /**
41 * Returns a textual representation of the content suitable for use in edit
42 * summaries and log messages.
43 *
44 * @param int $maxlength Maximum length of the summary text.
45 * @return string The summary text.
46 */
47 public function getTextForSummary( $maxlength = 250 ) {
48 return '';
49 }
50
51 /**
52 * Returns native representation of the data. Interpretation depends on the data model used,
53 * as given by getDataModel().
54 *
55 * @return mixed The native representation of the content. Could be a string, a nested array
56 * structure, an object, a binary blob... anything, really.
57 */
58 public function getNativeData() {
59 return $this->data;
60 }
61
62 /**
63 * returns the content's nominal size in bogo-bytes.
64 *
65 * @return int
66 */
67 public function getSize() {
68 return strlen( $this->data );
69 }
70
71 /**
72 * Return a copy of this Content object. The following must be true for the object returned
73 * if $copy = $original->copy()
74 *
75 * * get_class($original) === get_class($copy)
76 * * $original->getModel() === $copy->getModel()
77 * * $original->equals( $copy )
78 *
79 * If and only if the Content object is immutable, the copy() method can and should
80 * return $this. That is, $copy === $original may be true, but only for imutable content
81 * objects.
82 *
83 * @return Content A copy of this object
84 */
85 public function copy() {
86 return $this;
87 }
88
89 /**
90 * Returns true if this content is countable as a "real" wiki page, provided
91 * that it's also in a countable location (e.g. a current revision in the main namespace).
92 *
93 * @param bool|null $hasLinks If it is known whether this content contains links,
94 * provide this information here, to avoid redundant parsing to find out.
95 * @return bool
96 */
97 public function isCountable( $hasLinks = null ) {
98 return false;
99 }
100 }